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

Convert this x86-64 code shown above to Y86-64 code. Function main: Calling arit

ID: 3850218 • Letter: C

Question

Convert this x86-64 code shown above to Y86-64 code.

Function main: Calling arithEx() long arithEx (long, long, long, long, long, long, long, long): long main() { long a, b, c, d, e, f, g, h, w: a = 100: b = 12345: c = 98765: d = 23: e = 25: f = 27: g = 29: h = 31: w = arithEx(a, b, c, d, e, f, g, h): w++: return w: } Compilation command: gcc -O1 -S main.arithEX.c generated this x86-64 assembly code (with minor changes in red): main: subq exist24, %rsp movq exist31, 8 (%rsp) movq exist29, (%rsp) movq exist27, %r9 movq exist25, %r8 movq exist23, %rcx movq exist98765, %rdx movq exist12345, %rsi movq exist100, %rdi call arithEx addq exist1, %rax addq exist24, %rsp ret

Explanation / Answer

The Y86 is a machine that is similar to the x86 . It is an assembly level programming, simpler than the x86. it has just a few instructions as opposed to hundreds for the x86 with few addressing modes

gcc -01 -s main.arithEX.c //it's a compilation caommand.

the code in y-86 machine can be:

main

subq $24, $rsp

irmovl $31, 8(%rsp) // moves constant value to register

irmovl $29, (%rsp)

irmovl $27, %r9

irmovl $25, %r8

irmovl $23, %rcx

irmovl $98765, %rdx

irmovl $12345, %rsi

irmovl $100, %rdi //%rdi %rsi %rdx %rcx %r8 %r9,%rsp are register to store the value

call arithEX

addl $1, %rax // increment the value by 1

addl $24, %rsp

ret