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
In assembly masm use the code below! Write a program that reverse a string using indirect...
In assembly masm use the code below! Write a program that reverse a string using indirect addressing (may not use the stack - push/pop). The string will be given by the user and be up to 64 characters long INCLUDE Irvine32.inc INCLUDE macros.inc MAX = 64 .data source BYTE MAX DUP('#'),0 destination BYTE LENGTHOF source DUP('*'),0 actual_length DWORD ? ask BYTE "Enter a String: ",0 .code main proc ; ask user for input mov edx, OFFSET ask call WriteString ;...
phase 2 of binary bomb. what is the loop in assembly? Dump of assembler code for...
phase 2 of binary bomb. what is the loop in assembly? Dump of assembler code for function phase_2: => 0x0000555555555754 <+0>: push %rbp    0x0000555555555755 <+1>: push %rbx    0x0000555555555756 <+2>: sub $0x28,%rsp    0x000055555555575a <+6>: mov %fs:0x28,%rax    0x0000555555555763 <+15>: mov %rax,0x18(%rsp)    0x0000555555555768 <+20>: xor %eax,%eax    0x000055555555576a <+22>: mov %rsp,%rsi    0x000055555555576d <+25>: callq 0x555555555f56 <read_six_numbers>    0x0000555555555772 <+30>: cmpl $0x1,(%rsp)    0x0000555555555776 <+34>: jne 0x555555555781 <phase_2+45>    0x0000555555555778 <+36>: mov %rsp,%rbx    0x000055555555577b <+39>: lea 0x14(%rbx),%rbp...
Question1 At the beginning of a procedure in Assembly, right after it is called, which of...
Question1 At the beginning of a procedure in Assembly, right after it is called, which of the following will work to put the value of the 7th argument into %rax? movq (%rsp), %rax movq 8(%rsp), %rax leaq (%rsp), %rax leaq 8(%rsp), %rax Question2 Given the following code: question2 Address: Instruction 400510: mov %rsp,%rdi 400513: callq 4004cd <sum> 400518: add $0x28,%rsp When the callq instruction executes, what value will be pushed on to the Stack by call? Question3 Given this following...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in BL. Bits 6-7 in BL should be cleared, and AL should be unchanged             Mov al, bl       And 00111111, bl       Write a sequence of two instructions that copies the integer in bits 4-7 from AL register into bits 0-3 of the BL register. Upper 4 bits of AL and BL will be cleared             Shr al, 4       Mov bl,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT