Freescale 9s08gb stack and indexing

Apr 30, 2006 3 Replies

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 206.301.8986, fax 206.363.4367 Seattle, Washington 98155 USA

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

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:

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 206.301.8986, fax 206.363.4367 Seattle, Washington 98155 USA

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required