Application Notes; Notes On Stack Area Use - Renesas H8/38024 Hardware Manual

8-bit single-chip microcomputer h8 family/h8/300l super low power series
Hide thumbs Also See for H8/38024:
Table of Contents

Advertisement

3.4

Application Notes

3.4.1

Notes on Stack Area Use

When word data is accessed in the LSI, the least significant bit of the address is regarded as 0.
Access to the stack always takes place in word size, so the stack pointer (SP: R7) should never
indicate an odd address. Use PUSH Rn (MOV.W Rn, @–SP) or POP Rn (MOV.W @SP+, Rn) to
save or restore register values.
Setting an odd address in SP may cause a program to crash. An example is shown in figure 3.6.
SP
SP set to H'FEFF
[Legend]
PC
:
Upper byte of program counter
H
PC
:
Lower byte of program counter
L
R1L:
General register R1L
SP:
Stack pointer
Figure 3.6 Operation when Odd Address is Set in SP
When CCR contents are saved to the stack during interrupt exception handling or restored when
RTE is executed, this also takes place in word size. Both the upper and lower bytes of word data
are saved to the stack; on return, the even address contents are restored to CCR while the odd
address contents are ignored.
SP
BSR instruction
Stack accessed beyond SP
PC
SP
H
PC
L
MOV. B R1L, @−R7
Contents of PC are lost
Rev. 6.00, 08/04, page 95 of 628
R1L
H'FEFC
PC
H'FEFD
L
H'FEFF
H

Advertisement

Table of Contents
loading

This manual is also suitable for:

H8/38024f-ztatH8/38124H8/38024s

Table of Contents