Reputation:
I was testing the following assembly code:
.data
msg1: .ascii "HOW YOOOU DOOIN?"
msg2: .ascii "JOEY DOESN'T SHARE FOOD!"
msg1_len: .quad msg2-msg1
msg2_len: .quad msg1_len-msg2
all_msg_len: .quad msg1_len-msg1
.text
.global main
main:
mov $msg1, %rsi
mov $1, %rdi
mov $1, %rdx
mov $1, %rax
mov $0, %rbx
mov all_msg_len, %r9
call exm
exm:
cmp %rbx, %r9
je end
addb $0x20, (%rsi)
test $1, %rbx
jnz skip
syscall
skip:
inc %rsi
inc %rbx
call exm
end:
ret
I changed the 2 usages of register r9 with register rbp and my code worked fine. why is that?
Isn't rbp a pointer to the base of the stack's frame? I expected that changing its value would cause a catastrophic but it seems my expectations were wrong. why is that?
Upvotes: 0
Views: 423
Reputation: 39166
Isn't rbp a pointer to the base of the stack's frame?
The %rbp
register only becomes special once you start using it for function prologue/epilogue. Your exm doesn't use it that way and so the %rbp
register is no different from %r9
.
Upvotes: 1