Maker Pro
Maker Pro

Freescale 9s08gb stack and indexing

S

Steven Swift

Freescale recommends:

LDHX #RAMLAST+1
TXS

at the start of the reset handler for 9s08gb micros so that stack will
use high ram, freeing up zero page for direct addressing.

How this messes up simple minded single-byte X-indexed addressing as a
command like:

LDA junk,X

now uses H:X for the index. For the GB32, H=0x08.

Short of clearing H (CLRH) and using zero page for stack, is there
a clean way to use high stack and still maintain the simple 8-bit
indexing mode.

TIA.

Steve.
 
W

Walter Banks

S08 parts have many extended 16bit stack instructions that make the code
as easy as page zero date stack frames. There is a code size hit of 1 byte
as is all non page zero references.

w..
 
S

Steven Swift

H is not related to the stack pointer. CLRH and use page 0 for data and the
stack will continue to be happy at page non-0.

Thanks. I was confused by the debugger returning a different value for:


lda junk,x ;junk in zero page, x=0, H= #RAMLAST+1

and

clrh
lda junk,x

Steve.
 
Top