0

I am assembly debugging C code in Codewarrior. It assigns the value I defined with int to a location with rsp. for example:

//C code                    //Assembly code
int a = 80;                 li r9,80 
int b = 45;                 stw r9, 8(rsp) 
                            li r9,45 
                            stw r9, 12(rsp) 

Also what is 8(rsp) and 12(rsp)? How can i see these two values ​​on compiler? Thanks in advance for your answers.

umt
  • 7
  • 2
  • 1
    `rsp` is the *stack pointer*, and `8(rsp)` is an offset of 8 bytes from where `rsp` is pointing. It's a common way to store local variables, on the stack. – Some programmer dude Aug 11 '22 at 12:52
  • I'm afraid that you need to learn some basics of assembly language, including the processor model, before you can make some sense of assembly code. Unfortunately (for you and this issue) SO is not a tutorial site, it is a Q&A site. – the busybee Aug 11 '22 at 13:14
  • You did not say which CPU architecture you are using. Some CPU architectures use virtual stack pointers or similar. – Martin Rosenau Aug 11 '22 at 17:36
  • You're seeing the 2 values in the compiler's asm output. I found a couple duplicate Q&As about how compilers use stack memory for locals; it's not significantly different across most ISAs. – Peter Cordes Aug 11 '22 at 17:49

0 Answers0