The 8051 has a total of 128 bytes of RAM. These 128 bytes are divided into three different groups as follows.
Stack: The stack is a section of RAM used by the CPU to store information temporarily. This information could be data or an address. The CPU needs this storage area since there are only a limited number of registers. The register used to access the stack is called the SP (stack pointer) register. The stack pointer is 8 bits wide and it can take values of 00 to FFH. When the 8051 is powered up, the SP register contains value 07. This means that RAM location 08 is the first location used for the stack by the 8051. The storing of a CPU register in the stack is called a PUSH, and pulling the contents off the stack back into a CPU register is called a POP.
For example,
- 00H – 1FH (32 bytes): Register Bank and Stack
- 20H – 2FH (16 bytes): Bit addressable read/write memory
- 30H – 7FH (80 bytes): Scratch Pad - read/write storage
Stack: The stack is a section of RAM used by the CPU to store information temporarily. This information could be data or an address. The CPU needs this storage area since there are only a limited number of registers. The register used to access the stack is called the SP (stack pointer) register. The stack pointer is 8 bits wide and it can take values of 00 to FFH. When the 8051 is powered up, the SP register contains value 07. This means that RAM location 08 is the first location used for the stack by the 8051. The storing of a CPU register in the stack is called a PUSH, and pulling the contents off the stack back into a CPU register is called a POP.
For example,
ORG 00H
MOV R1, #25H
MOV R4, #45H
PUSH 1
PUSH 4
POP 3
POP 6
END
- the instruction “PUSH 1″ increments SP to 08H and pushes register R1 onto the stack location 08H.
- the “PUSH 4″ increments SP to 09H and pushes register R4 onto the stack location 09H.
- the instruction “POP 3″ copies the top of stack (location 09H) to register R3 and decrements SP to 08H.
- the “POP 6″ copies the top of stack (location 08H) to register R6 and decrements SP to 07H.
Related topics:
8051 Flags Bits | 8051 Program Flow | 8051 Timers | 8051 Serial Port | 8051 Interrupts
List of topics: 8051
No comments:
Post a Comment