Hardware Reference
In-Depth Information
Low address
Top element
SP
High address
Bottom element
Figure 4.1 Diagram of the HCS12 stack
the stack pointer. There are six push instructions: psha, pshb, pshc, pshd, pshx, and pshy .
A pull instruction loads data from the top of the stack to a register and then increments the
stack pointer. There are also six pull instructions: pula, pulb, pulc, puld, pulx, and puly . These
instructions have equivalent store and load instructions combined with predecrement and
postincrement index addressing modes, as shown in Table 4.1.
Mnemonic
Function
Equivalent Instruction
psha
pshb
pshc
pshd
pshx
pshy
pula
pulb
pulc
puld
pulx
puly
push A into the stack
push B into the stack
push CCR into the stack
push D into stack
push X into the stack
push Y into the stack
pull A from the stack
pull B from the stack
pull CCR from the stack
pull D from the stack
pull X from the stack
pull Y from the stack
staa 1, 2 SP
stab 1, 2 SP
none
std 2, 2 SP
stx 2, 2 SP
sty 2, 2 SP
ldaa 1, SP 1
ldab 1, SP 1
none
ldd 2, SP 1
ldx 2, SP 1
ldy 2, SP 1
Table 4.1 HCS12 push and pull instructions and their
equivalent load and store instructions
Sometimes the programmer may need to push a value into the stack directly. He or she
may use one of the following instructions to do that:
movb
#val1, 1, 2 SP
; push the 8-bit val1 into the stack
movw
#val2, 2, 2 SP
; push the 16-bit val2 into the stack
Example 4.1
Assuming that we have the following instruction sequence to be executed by the HCS12,
what would be the contents of the stack after the execution of these instructions?
lds
#$1500
ldaa
#$20
psha
 
 
Search WWH ::




Custom Search