Notes On Stack Usage - Hitachi H8/3022 Hardware Manual

H8/3022 series hitachi single-chip microcomputer
Table of Contents

Advertisement

4.6 Notes on Stack Usage

When accessing word data or longword data, the H8/3022 Series regards the lowest address bit as
0. The stack should always be accessed by word access or longword access, and the value of the
stack pointer (SP, ER7) should always be kept even. Use the following instructions to save
registers:
PUSH.W Rn
PUSH.L ERn
Use the following instructions to restore registers:
POP.W Rn
POP.L ERn
Setting SP to an odd value may lead to a malfunction. Figure 4-5 shows an example of what
happens when the SP value is odd.
SP
SP set to H'FFEFF
Legend
CCR:
Condition code register
PC:
Program counter
R1L:
General register R1L
SP:
Stack pointer
Note: The diagram illustrates modes 1, 3, 5, 6, and 7.
76
(or MOV.W Rn, @–SP)
(or MOV.L ERn, @–SP)
(or MOV.W @SP+, Rn)
(or MOV.L @SP+, ERn)
SP
TRAPA instruction executed
Data saved above SP
Figure 4-5 Operation when SP Value is Odd
CCR
SP
PC
MOV. B R1L, @-ER7
R1L
H'FFEFA
H'FFEFB
PC
H'FFEFC
H'FFEFD
H'FFEFF
CCR contents lost

Advertisement

Table of Contents
loading

This manual is also suitable for:

H8/3021H8/3020H8/3022 f-ztat

Table of Contents