Question
Reverse compile question1.asm (obtain a possible source C program for question1.asm). The original program does not do any meaningful computation. You can assume all 4
Reverse compile question1.asm (obtain a possible source C program for question1.asm). The original program does not do any meaningful computation. You can assume all 4 byte variables to be of type (signed) int Determine the types of 2-byte and 1-byte variables from the code Hint: pay attention to integral promoted values of these variables Draw a memory image of the execution of the program. You must write the offsets of all the local variables and parameters But you do not need to simulate the execution or write values of any variable. (I do not even know if the program terminates)
=================== question1.asm =================
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.12.25834.0
TITLE c:\K-State\cis450 uns\2018S\Assignment2\question1.c
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES
PUBLIC _s1
_DATA SEGMENT
COMM _ui:DWORD
_DATA ENDS
_DATA SEGMENT
_i DD 018H
_s1 DW 0cH
_DATA ENDS
PUBLIC _main
_BSS SEGMENT
_u2 DW 01H DUP (?)
_BSS ENDS
_TEXT SEGMENT
_y$ = -12 ; size = 4
_x$ = -8 ; size = 4
_c$ = -1 ; size = 1
_argc$ = 8 ; size = 4
_argv$ = 12 ; size = 4
_envp$ = 16 ; size = 4
_main PROC
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 83 ec 0c sub esp, 12 ; 0000000cH
00006 0f bf 05 00 00
00 00 movsx eax, WORD PTR _s1
0000d 6b 0d 00 00 00
00 03 imul ecx, DWORD PTR _i, 3 ; imul: signed integer multipy
; ecx <= i * 3
00014 03 c1 add eax, ecx
00016 89 45 f8 mov DWORD PTR _x$[ebp], eax
00019 8b 55 f8 mov edx, DWORD PTR _x$[ebp]
0001c 83 c2 06 add edx, 6
0001f 66 89 15 00 00
00 00 mov WORD PTR _u2, dx
00026 0f bf 05 00 00
00 00 movsx eax, WORD PTR _s1
0002d 83 c0 0f add eax, 15 ; 0000000fH
00030 a3 00 00 00 00 mov DWORD PTR _ui, eax
00035 c6 45 ff 05 mov BYTE PTR _c$[ebp], 5
00039 c7 45 f4 00 00
00 00 mov DWORD PTR _y$[ebp], 0
$LN2@main:
00040 83 7d f8 00 cmp DWORD PTR _x$[ebp], 0
00044 7e 20 jle SHORT $LN3@main ; jle: jump if less than equal to
00046 8b 4d f4 mov ecx, DWORD PTR _y$[ebp]
00049 83 c1 01 add ecx, 1
0004c 89 4d f4 mov DWORD PTR _y$[ebp], ecx
0004f 0f b7 15 00 00
00 00 movzx edx, WORD PTR _u2
00056 8b 45 f8 mov eax, DWORD PTR _x$[ebp]
00059 2b c2 sub eax, edx
0005b 0f be 4d ff movsx ecx, BYTE PTR _c$[ebp]
0005f 2b c1 sub eax, ecx
00061 89 45 f8 mov DWORD PTR _x$[ebp], eax
00064 eb da jmp SHORT $LN2@main
$LN3@main:
00066 8b 15 00 00 00
00 mov edx, DWORD PTR _i
0006c d1 e2 shl edx, 1 ; shl : shift left (1 bit)
0006e 39 55 f8 cmp DWORD PTR _x$[ebp], edx
00071 7d 17 jge SHORT $LN4@main ; jump if greater than equal to
00073 0f be 45 ff movsx eax, BYTE PTR _c$[ebp]
00077 0f b7 0d 00 00
00 00 movzx ecx, WORD PTR _u2
0007e 8d 54 88 2d lea edx, DWORD PTR [eax+ecx*4+45] ; lea: load effective address
; edx <= eax * ecx * 4 + 45
00082 89 15 00 00 00
00 mov DWORD PTR _ui, edx
00088 eb 13 jmp SHORT $LN1@main
$LN4@main:
0008a 8b 45 f8 mov eax, DWORD PTR _x$[ebp]
0008d 03 45 f4 add eax, DWORD PTR _y$[ebp]
00090 0f be 4d ff movsx ecx, BYTE PTR _c$[ebp]
00094 d1 e1 shl ecx, 1
00096 2b c1 sub eax, ecx
00098 a3 00 00 00 00 mov DWORD PTR _i, eax
$LN1@main:
0009d 33 c0 xor eax, eax
0009f 8b e5 mov esp, ebp
000a1 5d pop ebp
000a2 c3 ret 0
_main ENDP
_TEXT ENDS
END
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started