In this code %edi, %esi, %ebx are 32 bit general purpose
registers of x86 processor,
edi and esi are known as destination index and source index
respectively, which are probably useful while working on strings or
arrays.
% ebx is 32 bit general purpose register which is used in the
subroutine operations to return the result.
So while performing multiple function programs, %edi, %esi, %ebx
are saved in stack (in the lines 4,5,6) before calling the
subroutine.
#define SIZE 10 prob3: void prob3 (int mat [SIZE] [SIZE]) int r, c pushl movl tebp...
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);...
Suppose we have C program, int foo(long s, long d) { char arr_a[11]; int i; arr_a[10] = 0; arr_s[10] = 0; for (i = 0; i < 5; i++) { if ((s == 1) && (d == 2)) { arr_a[i] = hello[4-i]; arr_s[i] = hello[4-i]; arr_a[i+5] = world[i]; arr_s[i+5] = world[i]; } else { arr_a[i+5] = hello[4-i]; arr_s[i+5] = hello[4-i]; arr_a[i] = world[i]; arr_s[i] =...
the answer is movl 8(%ebp),
%edx or movl 4(%ebp), %edx?
Consider the following C and assembly code: int increment(int x){ return x+1; } increment: 1 push? 2 movl 3 movl 4 addl 5 6 popl ret %ebp %esp, %ebp 8(%ebp), %eax $1, %eax %ebp Suppose we want to move the return address into register %edx on line 5. Write 1 line of assembly code to perform this action. (Write your answer with exactly 2 spaces: one after the instruction, and...
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...
Write the C Code for the Intel assembley below. Note: Don't copy and paste anything from github because it won't be the right answer. .file "mystery.c" .comm num,1600,32 .text .globl add .type add, @function add: .LFB2: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movq %rdi, -8(%rbp) movq %rsi, -16(%rbp) movq -16(%rbp), %rax movq -8(%rbp), %rdx addq %rdx, %rax popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE2: .size add, .-add .globl dothething .type dothething, @function...
You know the following assembly code snippet is from a recursive function in C. You also know that the stack contents at a particular point in time when we are in the recursive function are shown on the next page. Answer the following questions: a) how many Foo stack frames are on the stack? b) what is the return address back to the function that called Foo for the first time? c) what is the return address back into the...