the answer is movl 8(%ebp), %edx or movl 4(%ebp), %edx?
Answer:---------
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
addl $1, %eax
movl 8(%ebp), %edx
popl %ebd
ret
the answer is movl 8(%ebp), %edx or movl 4(%ebp), %edx? Consider the following C and assembly...
WHAT is the value of A,B, and C Consider the following code fragment where the right-hand side of the assignments in func are to be completed by answering this question: typedef struct point { float *p; struct { float x; float y; }s; struct point* next; } point; void func(point *sp1, point* sp2) { sp2->p = A; sp2->S.X = B; sp2->s.y = c; int maino { point *init, *final; // assume init has been initialized to some value; func(init, final);...
Exercise 3 [Conditionals] Consider the following assembly code for a function F3 with two integer arguments: F3: push EBP mov EBP, ESP mov EDX, DWORD PTR [ebp+12] mov EAX, DWORD PTR [ebp+8] cmp EAX, EDX # setup stack #if # goto .L1 #EAX- mov EAX, EDX # ignore for now mov DWORD PTR [EBP-4], EAX mov ESP, EBP pop EBE ret # cleanup stack To the right of each instruction, show the contents of the register whose value changes as...
For the C code 1 int loop while(int a, int b) int result 1; while (a < b) t result (atb); return result; Gcc generates the following assembly code: %ebp+8, mov1 movl movl %ebp+12 at 8(%ebp) ,%ecx 12(%ebp) ,%ebx $1,%eax a at b 5 jge L11 leal (%ebx, %ecx), Xodx 8 L12: inull %eax , %eax addl $1,%ecx addl $1, edx cmp1 %ecx , %ebx 9 10 12 13 J8 14 ·L11: .L12 In generating this code, occ makes an...
#define SIZE 10 prob3: void prob3 (int mat [SIZE] [SIZE]) int r, c pushl movl tebp esp, ebp edi 2 pushl esi pushl ebx pushl $4, esp 8 (ebp), eax $1, (eax) subl movl mat [0] [0] 1; movl leal 40 (teax), Sebx movl $1, 40 (teax) 11 addl $80, teax 12 eax, -16 (tebp) movl 13 movl $1, tedi .L2 14 jmp 15 for (r 1; r<SIZE; r++) ( L5: 16 -16 (ebp), tebx movl 17 mat [r] [0]...
0x401050 : push %ebp 0x401051 : mov %esp,%ebp 0x401053 : sub $0xc,%esp 0x401056 : mov 0x8(%ebp),%eax 0x401059 : add $0x4,%eax 0x40105c : mov %eax,0xfffffffc(%ebp) 0x40105f : mov 0x8(%ebp),%eax 0x401062 : imul 0xc(%ebp),%eax 0x401066 : mov %eax,0xfffffff8(%ebp) 0x401069 : mov 0xc(%ebp),%edx 0x40106c : mov 0x8(%ebp),%eax 0x40106f : sub %edx,%eax 0x401071 : mov %eax,0xfffffff4(%ebp) 0x401074 : mov 0xfffffff8(%ebp),%eax 0x401077 : add 0xfffffffc(%ebp),%eax 0x40107a : add 0xfffffff4(%ebp),%eax 0x40107d : leave 0x40107e : ret 0x401089 : push %ebp 0x40108a : mov %esp,%ebp 0x40108c :...
And also when recursive(5). Consider the following funtion int recursive(int n) f The assembly code equivalent of the above function is: recursive push %ebp mov %esp,%ebp push %ebx sub $0x14,%esp cmpl $0x1,0x8(%ebp) je L1 cmpl $0x2,0x8(%ebp) jne L2 L1 mov 0x8 (%ebp),%eax jmp L3 L2 mov 0x8 (%ebp),%eax sub $0x1,%eax mov %eax, (%esp call recursive mov %eax,%ebx mov ox8(%ebp),%eax sub $0x2,%eax mov %eax, (%esp call recursive imul %ebx,%eax L3 add $0x14,%esp pop %ebx pop %ebp ret
A C function fun has the following code body: *p -d; return x-c; The IA32 code implementing this body is as follows 12 (%ebp) ,%eax 16(%ebp) , movabl nov1 nov1 %edx ,(%eax) movsw1 8(%ebp),%eax movl 20 (ebp), %edx subi %eax,%edx movi %edx, %eax 2 %eax 4 7 Write a prototype for function fun, showing the types and ordering of the arguments p, d, x, and c. A C function fun has the following code body: *p -d; return x-c; The...
A function, fun_a, has the following overall structure: int fun_a(unsigned x) I int val 0 while retura Th e Gcc Ccompiler generates the following assembly code: %ebp+8 novi movl test1 x at 8 (%ebp), %eax 80, %eax %edx, %eax 2 L.7 5 .L10 %eax, %edx し10 xor1 %eax shr1 Shift right by1 ne 9.L7 10 andl $1, %eax Reverse engineer the operation of this code and then do the following: A. Use the assembly-code version to fill in the missing...
You are charged with maintaining a large C rogram and you come across the following code typedef struct int left a-struct a [CNT] int right b-struct; void testlint i, b-struct *bp) int n bp- left bp-rights a-struct ap &bp- ali] ap- Cap- idx] n; The declaration of the compile time constant CNT and the structure a struct are in a file for which you don't have necessary access privilege. Fortunately you have a copy of the o' version of code,...
Write full code in microsoft virtual studio ASM only Remember to use step into when tracing a procure's call Convention el proc program mple1 Problem 2: Write and run the following program. Will the program crash? Why? push 6 push 5 call addtwo add esp,4 comment this line and see what happen ret example1 endp C Calling Convention main proc call example1 add al, 1 invoke ExitProcess, e main endp addtwo proc push ebp mov ebp,esp mov eax, [ebp+12] add...