Convert C function to Y86 function

1.4k Views Asked by At

first question here, please let me know if I did anything wrong.

Essentially, I'm having a bit of trouble converting C function to Y86 function. I don't know how to put the C function parameters in registers of Y86 (don't know if I described this correctly but please check my attempt below). Keep in mind I'm relatively new to C and Y86.

Say I have a function in C:

quad_t func(quad_t a0, quad_t a1) {
    return ( ( a1 + a0 ) - a1);
}

Now I try to put it in Y86:

func:
     irmovq 0xa0, %rax
     irmovq 0xa1, %rcx
     addq %rcx, %rax
     subq %rcx, %rax
     ret

I assume Y86 took my input literally as 0xa0 (in hex), but I don't know what to do.

0

There are 0 best solutions below