I want to generate assembly code from a function call like : (* 2 3).
it worked for the example of : (+ 7 3) like this :
.text
.globl _main
.globl main
_main:
main:
push $7
push $3
pop %rax
add %rax,(%rsp)
call print_word_dec
push $10
call putchar
mov $0, %rax
and when I want to apply that to multiplication :
.text
.globl _main
.globl main
_main:
main:
push $2
push $3
pop %rbx
imulq %rbx
call print_word_dec
push $10
call putchar
mov $0, %rax
ret
I always get the same result : 2 (the first operand) like if the multiplication didn't work.
I did some research and understood that a function is using the register rax for stocking the return value.
So in the multiplication example : it stocks 2 and 3 in rax register, when I call pop %rbx, it moves 3 to %rbx and it multiply %rbx with what's on %rax so it should be 6.
I think I misunderstood something.
Thanks for the help
PS: the functions putchar and print_word_dec are utilities and they are already tested