Question

;Assembly x86-64 ;Q9: What is the value of eax (in decimal) after the function call in...

;Assembly x86-64

;Q9:

What is the value of eax (in decimal) after the function call in _start returns?

global _start
_start:
  mov edi, 4
  call function1

global function1
function1:
  push rdi
  inc edi
  mov esi, 2
  call function2
  pop rdi
  mul edi
ret

global function2
function2:
  mov eax, edi
  mov edx, 0
  div esi
  add eax, edi
  add eax, edx
ret

;Q10:

A function uses 10 integer arguments. What is the appropriate value for the blank operand to clear the arguments off the stack after the call?

add rsp, __________________

Homework Answers

Answer #1

In global start instrctions

first command value of edi become 4.

after that function 1 is call

In function 1 in

step1 :- rdi is push onto the stack

step2:-increamenet edi by 1 which now 5 .

step3:-function 2 is calling

in function 2

step1:-edi values moves into eax value.

step2:- edx value become 0

step3:- eax and edi is added

step4:- eax and edx is added

after function return goes to function 1

execute the remaining command

pop the rdi from the stack and multiply with edi

the final value of eax is 10

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT