
MaximIntegrated 19-16
MAX31782 User’s Guide
Revision 0; 8/11
19.9AccessingtheStack
The hardware stack is used automatically by the CALL, RET and RETI instructions, but it can also be used explicitly to
store and retrieve data . All values stored on the stack are 16 bits wide .
The PUSH instruction increments the stack pointer SP and then stores a value on the stack . When pushing a 16-bit value
onto the stack, the entire value is stored . However, when pushing an 8-bit value onto the stack, the high byte stored on
the stack comes from the pre- fix register . The @++SP stack access mnemonic is the associated destination specifier
that generates this push behavior, thus the following two instruction sequences are equivalent:
move
PFX[0], IC
push
PSF
; stored on stack: IC:PSF
move
PFX[0], IC
move
@++SP, PSF
; stored on stack: IC:PSF
The POP instruction removes a value from the stack and then decrements the stack pointer . The @SP-- stack access mne-
monic is the associated source specifier that generates this behavior, thus the following two instructions are equivalent:
pop
PSF
move
PSF, @SP--
The POPI instruction is equivalent to the POP instruction but additionally clears the INS bit to 0 . Thus, the following two
instructions would be equivalent:
popi
IP
reti
The @SP-- mnemonic can be used by the MAX31782 so that stack values may be used directly by ALU operations (e .g .
ADD src, XOR src, etc .) without requiring that the value be first popped into an intermediate register or accumulator .
add
@SP--
; sum the last three words pushed onto the stack
add
@SP--
; with Acc, disregarding overflow
add
@SP--
The stack pointer SP can be set explicitly, however only the lowest four bits are used and setting SP to 0Fh will return
it to its reset state .
Since the stack is 16 bits wide, it is possible to store two 8-bit register values on it in a single location . This allows more
efficient use of the stack if it is being used to save and restore registers at the start and end of a subroutine .
SubOne:
move
PFX[0], IC
push
PSF
; store IC:PSF on the stack
...
pop
GR
; 16-bit register
move
IC, GRH
; IC was stored as high byte
move
PSF, GRL
; PSF was stored as low byte ret
19.10AccessingDataMemory
Data memory is accessed through the data pointer registers DP[0] and DP[1] or the Frame Pointer BP[OFFS] . Once one
of these registers is set to a location in data memory, that location can be read or written as follows, using the mnemonic
@DP[0], @DP[1] or @BP[OFFS] as a source or destination .
move
DP[0], #0000h
; set pointer to location 0000h
move
A[0], @DP[0]
; read from data memory
move
@DP[0], #55h
; write to data memory