On Fri, Sep 23, 2011 at 08:06:49AM +0200, Maarten Brock wrote: > Hello Peter, > <snip> > > 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). > > Since you use an explicit cast to char on the parameter passed to a > varargs function (sprintf) the value is not passed as an int as normal. > This is an extension to save memory. But then your formatter must also > tell it to expect a char instead of an int as %x does. Maybe it's better > to just remove the inline cast. > > HTH, > Maarten >
Sorry, my bad I originally had sprintf (str,"%x", *sys_rstack); and that gives 61 on the lcd, however 61 isn't the correct value, 45 is. But I see wbere my problem is, because 61 is what is in 45 of data (i.e. what 10 is pointing to and what I asked for). What I really want is sprintf (str,"%x", sys_rstack); which is the contents of Data 10h. However the above gets 4000 on the LCD because its a pointer. 01B1 12 48 50 706 lcall _lcd_print 707 ; main.c:107: sprintf (str,"%x", sys_rstac k); 01B4 AD 10 708 mov r5,_sys_rstack 01B6 7E 00 709 mov r6,#0x00 01B8 7F 40 710 mov r7,#0x40 01BA C0 05 711 push ar5 01BC C0 06 712 push ar6 01BE C0 07 713 push ar7 however sprintf (str,"%x", (int) sys_rstack); does what I wish and displays the (truncated) pointer value correctly. As I expected my problem was an incorrect understanding of what I wanted :-) By the way sprintf (str,"%hx", *sys_rstack); displays Hx on the lcd not the now expected 61. In any case thanks for the help! 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