Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/22/02 06:03
Read: times


 
#27679 - RE: declaring variables and registers
I (Dan Henry) wrote:
-------------------------------
The SP (stack pointer) defaults to 0x08, which is the address of R0 in register bank 1.

Of course everybody knows that the stack defaults to starting at address 0x08, not the stack pointer (which defaults to 0x07). Sorry if I confused anybody momentarily.

In any case, I agree with pranav and would start the stack after bit-addressable memory, but I would take it one step further. Over estimate the the size of the stack you think you'll need and locate it at the end of internal RAM memory. That way you can add more variables when you application requires it and not have to change where the stack starts all the time. Let's say you anticipate using nothing but calls (that is, not pushing anything else but return addresses) and you anticipate 8 levels of function nesting. That's 16 bytes of stack space required. Now let's double that for good measure to 32 bytes. If you are using an 8051 derivative (128 bytes internal RAM), you would initialize the stack pointer using:
    MOV SP,#07FH-32

If you are using an 8052 derivative (256 bytes internal RAM), you would initialize the stack pointer using:
    MOV SP,#0FFH-32



List of 19 messages in thread
TopicAuthorDate
declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      
RE: declaring variables and registers            01/01/70 00:00      

Back to Subject List