help on saving SP (HC08)

help on saving SP (HC08)

Post by ciald » Fri, 07 May 2004 21:25:48


I use MC68HC908QY4 and codewarrior 3.0.

In a C funtion I need to save the SP in a variable:

void dummy(void)
{
u16_t stack_ptr;

asm {
TSX
STHX @stack_ptr
}
}

I tried in every way suggested by manuals but I always obtain an error
(C18107 or C18700) for STHX instruction.

How can I "read" SP in a local variable.

thanks
 
 
 

help on saving SP (HC08)

Post by DS » Sat, 08 May 2004 02:41:47

try this:

#pragma DATA_SEG _DATA_ZEROPAGE
unsigned int near stack_ptr;
#pragma DATA_SEG DEFAULT

void dummy(void)
{
asm {
TSX
STHX stack_ptr;
}
}

 
 
 

help on saving SP (HC08)

Post by Daniel Fri » Sun, 09 May 2004 01:28:26

Or this:
void test(void) {
unsigned int sp;
__asm {
TSX
STX sp:1
PSHH
PULX
STX sp:0
}
}


Bye

Daniel