Re: [Sdcc-user] An 8051 printf question

2011-09-24 Thread Maarten Brock
> > 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! > > Since int and short int are identical in SDCC the 'h' modifier is > not needed. And apparently printf_large.c does not support it. pri

Re: [Sdcc-user] An 8051 printf question

2011-09-23 Thread Peter Van Epp
On Fri, Sep 23, 2011 at 11:22:47PM +0200, Maarten Brock wrote: > > If you want to print a pointer, wouldn't it be wise to use the > pointer format specifier (%p)? > Yes that does the trick without the cast. I'm just from the dark ages when there weren't pointer formats in prin

Re: [Sdcc-user] An 8051 printf question

2011-09-23 Thread Maarten Brock
> 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 50706 lcall _lcd_print > 707 ; main.c:107: sprintf (str,"

Re: [Sdcc-user] An 8051 printf question

2011-09-23 Thread Peter Van Epp
On Fri, Sep 23, 2011 at 08:06:49AM +0200, Maarten Brock wrote: > Hello Peter, > > > 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

Re: [Sdcc-user] An 8051 printf question

2011-09-23 Thread Philipp Klaus Krause
Am 23.09.2011 21:04, schrieb Maarten Brock: >> Am 23.09.2011 19:03, schrieb Raphael Neider: >> >>> >>> We had discussed this problem when it was implemented and did not >>> find *the* ideal solution back then. Not sure if we can find one now >>> :-( >> >> Where can I find this discussion? Not doing

Re: [Sdcc-user] An 8051 printf question

2011-09-23 Thread Maarten Brock
> Am 23.09.2011 19:03, schrieb Raphael Neider: > > > > > We had discussed this problem when it was implemented and did not > > find *the* ideal solution back then. Not sure if we can find one now > > :-( > > Where can I find this discussion? Not doing the argument promotions > (i.e. float to dou

Re: [Sdcc-user] An 8051 printf question

2011-09-23 Thread Philipp Klaus Krause
Am 23.09.2011 19:03, schrieb Raphael Neider: > > We had discussed this problem when it was implemented and did not > find *the* ideal solution back then. Not sure if we can find one now > :-( Where can I find this discussion? Not doing the argument promotions (i.e. float to double, small thing l

Re: [Sdcc-user] An 8051 printf question

2011-09-23 Thread Raphael Neider
Hi, > > >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 pushar7 [...] > what difference does the cast

Re: [Sdcc-user] An 8051 printf question

2011-09-23 Thread Paul Fox
maarten wrote: > Hello Peter, > > > 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) *

Re: [Sdcc-user] An 8051 printf question

2011-09-22 Thread Maarten Brock
Hello Peter, > 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); > > ge

[Sdcc-user] An 8051 printf question

2011-09-22 Thread Peter Van Epp
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 sta