Convert this x86-64 code shown above to Y86-64 code. Function main: Calling swap
ID: 3850217 • Letter: C
Question
Convert this x86-64 code shown above to Y86-64 code.
Function main: Calling swap() void swap (long *, long *): long main() { long x = 123: long y = 456: swap (&x;, &y;): return 1: } Compilation command: gcc -O1 -S main.swap.c generated this x86-64 assembly code (with minor changes in red): main: subq exist24, %rsp movq exist123, 8(%rsp) movq exist456, (%rsp) movq %rsp, %rsi leaq 8(%rsp), %rdi call swap movq exist1, %rax addq exist24, %rsp ret Instruction subI exist24, %rsp enlargers stack for 24 bytes, for local variables x and y, plus 8 bytes as a recommended memory alignment. Before return, addq adjusts stack for ret instruction.Explanation / Answer
Main : nop
Subq $24, %rsp
irMovq $123, 8(%rsp)
irMovq $456, (%rsp)
irMovq $456, (%rsp)
Leaq 8(%rsp), %rdi
Call swap
irMovq $1, %rax
Addq $24, %rsp
ret