Assembly code doesn't seem to return the memory address stored in rbx [duplicate]
Sophia Terry
I wrote this simple assembly code (nasm on linux) and expected to have rbx storing the address of the memory space that saved a multiplication of floats:
section .data
real1: dq 25.665544
real2: dq 10.000
section .text
global _start
_start:
fld qword [real1] ; load real1 in the float stack, st0
fld qword [real2] ; st0 now holds real2, real1 in st1
fmul st0, st1 ; st0 *= st1
fstp qword [real1] ; save st0 in real1 and pop, real1 has the result
fstp qword [real2] ; save st1 in real2 and pop, float stack is empty
mov rbx, qword real1 ; store the address of real1 in rbx
mov rax, 1
int 80hAfter compiling the program and running, I do an "echo $?" to see its return value. Well, it shows 224 on my terminal, but I was expecting to see something like the memory address, which I believe is saved in rbx at the end. Or maybe my expectation is wrong. Can you clarify what is happening?
31 Answer
Linux exit codes are only 8 bits long, so the number you're returning is being truncated from 64 bits to 8.
1