Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Translate function your_function into LEGv8 assembly instructions. Since externa

ID: 3726867 • Letter: T

Question

Translate function your_function into LEGv8 assembly instructions. Since external_function is not under your control, you must obey LEGv8 function calling conventions regarding registers and stack usage. The function declaration for the external function is:

int64_t external_function(int64_t x, int64_t y);

The code for your function is as follows:

int64_t your_function(int64_t a, int64_t b, int64_t c, int64_t d) {

int64_t tmp1 = external_function(a,b);

int64_t tmp2 = external_function(c,d);

return tmp1 + tmp2;

}

Explanation / Answer

square:

push rbp

mov rbp,rsp

mov DWORD PTR [rbp-0x4],edi

mov eax,DWORD PTR [rbp-0x4]

imul eax,DWORD PTR [rbp-0x4]

pop rbp

ret

main:

push rbp

mov rbp,rsp

mov eax,0x0

pop rbp

ret

nop WORD PTR cs:[rax+rax*1+0x0]

nop DWORD PTR [rax+0x0]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote