Stack, Tack – Maxim Integrated High-Speed Microcontroller Users Guide: DS80C390 Supplement User Manual
Page 7

High-Speed Microcontroller User’s Guide: DS80C390 Supplement
7 of 158
register. Since there are four banks, the currently selected bank will be used by any instruction using R0-
R7. This allows software to change context by simply switching banks. The Working Registers also
allow their contents to be used for indirect addressing of the upper 128 bytes of RAM. Thus an instruction
can designate the value stored in R0 (for example) to address the upper RAM. This value might be the
result of another calculation.
STACK
Another use of the Scratchpad area is for the programmer’s stack. This area is selected using the Stack
Pointer (SP,81h) SFR. Whenever a call or interrupt is invoked, the return address is placed on the stack. It
also is available to the programmer for variables, etc. The Stack Pointer will default to 07h on reset, but
can be relocated as needed. A convenient location would be the upper RAM area (>7Fh) since this is only
available indirectly. The SP will point to the last used value. Therefore, the next value placed on the Stack
is put at SP + 1. Each PUSH or CALL will increment the SP by the appropriate value. Each POP or RET
will decrement as well.
The DS80C390 supports an optional 10-bit (1kB) stack. This greatly increases programming efficiency
and allows the device to support large programs. When enabled by setting the Stack Address (SA) bit in
the ACON register, the lower 1kB of the 4kB internal SRAM becomes the memory location used by all
instructions that affect the stack. The 10-bit address is formed by concatenating the lower 2 bits of the
Extended Stack Pointer (ESP;9Bh) and the 8-bit Stack Pointer (SP;81h). The exact address of the 1kB is
dependent on the setting of the IDM1-0 bits. The 10-bit stack feature is not supported when the 4kB
SRAM is configured as combined program/data memory (IDM1 = IDM0 = 1).