Freescale 9s08gb stack and indexing

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.

--
Steven D. Swift, novatech@eskimo.com, http://www.novatech-instr.com
NOVATECH INSTRUMENTS, INC.      P.O. Box 55997
 Click to see the full signature
Reply to
Steven Swift
Loading thread data ...

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.

Bill

Reply to
Bill A.

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..

Steven Swift wrote:

Reply to
Walter Banks

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.

--
Steven D. Swift, novatech@eskimo.com, http://www.novatech-instr.com
NOVATECH INSTRUMENTS, INC.      P.O. Box 55997
 Click to see the full signature
Reply to
Steven Swift

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.