Can anyone shed light on this problem? with a relatively recent (within
the last few weeks) snap of SDCC the following code misbehaves (at least as 
far as printing goes):

// start of running stack (in DATA memory)
__data uint8 * __data sys_rstack;

...

        // get the start of the stack
        __asm
        mov     a,#__start__stack
        mov     _sys_rstack,a
        __endasm;


as expected (dumping memory with a debugger) sys_rstack contains the hex 
value of the intitial stack (0x45 in this case). In the main routine a 
printf gets the wrong value:

extern __data uint8 * __data sys_rstack;

// string for LCD output
#define STR_LEN 80
__xdata uint8 str[STR_LEN];
...

main()
{
 ...


        sprintf (str,"%x", (uint8) *sys_rstack);
        lcd_print(2, str);

        generates:
                            707 ;       main.c:107: sprintf (str,"%x", (uint8) *
sys_rstack);
   01B4 A9 10               708         mov     r1,_sys_rstack
   01B6 87 07               709         mov     ar7,@r1
   01B8 C0 07               710         push    ar7
   01BA 74 53               711         mov     a,#__str_3
   01BC C0 E0               712         push    acc
   01BE 74 7E               713         mov     a,#(__str_3 >> 8)
   01C0 C0 E0               714         push    acc
   01C2 74 80               715         mov     a,#0x80
   01C4 C0 E0               716         push    acc
   01C6 74 DC               717         mov     a,#_str
   01C8 C0 E0               718         push    acc
   01CA 74 01               719         mov     a,#(_str >> 8)
   01CC C0 E0               720         push    acc
   01CE E4                  721         clr     a
   01CF C0 E0               722         push    acc
   01D1 12 7D 15            723         lcall   _sprintf
   01D4 E5 81               724         mov     a,sp
   01D6 24 F9               725         add     a,#0xf9
   01D8 F5 81               726         mov     sp,a
                            727 ;       main.c:108: lcd_print(2, str);

but displays on the LCD 6100 rather than the expected (because thats whats in
data location 10H) 45. The code above appears to be loading the contents of 
sys_rstack (at 0x10 in data) in to r7 but something undesirable happens after 
that (which may well be operator error on my part). 

debug cmd> d D:0000 24
0000: 00 00 02 03 00 40 1E 00 C1 0F 15 00 6F 03 18 18
0010: 45 2F 01 05 5D 02 00 00 DE 10 00 02 04 08 00 00
0020: 51 0A 04 01

Peter Van Epp


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to