Intel 8XC196K Series User Manual page 81

Table of Contents

Advertisement

8XC196K x , J x , CA USER'S MANUAL
4.1.7.1
General-purpose Register RAM
The lower register file contains general-purpose register RAM. The stack pointer locations can
also be used as general-purpose register RAM when stack operations are not being performed.
The RALU can access this memory directly, using register-direct addressing.
The upper register file also contains general-purpose register RAM. The RALU normally uses
indirect or indexed addressing to access the RAM in the upper register file. Windowing enables
the RALU to use register-direct addressing to access this memory. (See Chapter 3, "Programming
ConsiderAtions," for a discussion of addressing modes.) Windowing can provide for fast context
switching of interrupt tasks and faster program execution. (See "Windowing" on page 4-13.) PTS
control blocks and the stack are most efficient when located in the upper register file.
The 8XC196JV has additional register RAM in locations 1C00–1DFFH. Like the general-pur-
pose register RAM in the upper register file, this register RAM can be windowed and is accessed
directly, without the use of the memory controller.
4.1.7.2
Stack Pointer (SP)
Memory locations 0018H and 0019H contain the stack pointer (SP). The SP contains the address
of the stack. The SP must point to a word (even) address that is two bytes greater than the desired
starting address. Before the CPU executes a subroutine call or interrupt service routine, it decre-
ments the SP by two and copies (PUSHes) the address of the next instruction from the program
counter onto the stack. It then loads the address of the subroutine or interrupt service routine into
the program counter. When it executes the return-from-subroutine (RET) instruction at the end of
the subroutine or interrupt service routine, the CPU loads (POPs) the contents of the top of the
stack (that is, the return address) into the program counter and increments the SP by two.
Subroutines may be nested. That is, each subroutine may call other subroutines. The CPU
PUSHes the contents of the program counter onto the stack each time it executes a subroutine call.
The stack grows downward as entries are added. The only limit to the nesting depth is the amount
of available memory. As the CPU returns from each nested subroutine, it POPs the address off
the top of the stack, and the next return address moves to the top of the stack.
Your program must load a word-aligned (even) address into the stack pointer. Select an address
that is two bytes greater than the desired starting address because the CPU automatically decre-
ments the stack pointer before it pushes the first byte of the return address onto the stack. Remem-
ber that the stack grows downward, so allow sufficient room for the maximum number of stack
entries. The stack must be located in either the internal register file or external RAM. The stack
can be used most efficiently when it is located in the register file.
4-12

Advertisement

Table of Contents
loading

Table of Contents