Return Value on the Stack in x86 Assembly

Viewed 176

For an assignment I had to create a function in x86 ASM, which should calculate the determinante of a matrix and return its result over the stack to the main function.

My question is now how can I push the result to the stack.

I know the standard for return values is the register %rax, but the assignment stated to use the stack.

So in the main it looks something like this:

    pushq a
    pushq b
    pushq c
    pushq d
    call determinante
    popq %r12

wheras a, b, c, d are the values for the matrix and determinante should now push the result in the stackframe of main and with popq %r12, we want to write it to the register r12.

Not literally push it to the stack but the Assignment said:

determinant: # returns the result in the last parameter in stack

Just a small tip on how to push a value to the stack in a function would help a lot.

Thanks, Justin

0 Answers
Related