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         push    ar7
[...]

> what difference does the cast make?  the declaration is already
> uint8, so isn't the cast a no-op?  what am i missing?

As Maarten said, the cast inhibits automatic promotion to int:

> > 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 sdcc behavior bites us (bytes us?  :-) all the time -- i'm always
> having to go back to add "(uint)foo" casts when printing byte-wide
> values as %x or %d, to make the values show correctly.  unless there
> are new format chars for byte-wide parameters,

Not sure, but does our printf() support, say, "%hx" with "h" as a
size-modifier for byte-sized args?

> how does this save memory?
> what am i missing?

Look at the code above: Pushing one argument byte costs 6 byte code
space and 1 byte stack space. If we promote byte args to int, this
would cost 12 byte code space and 2 byte on the stack. At every
variadic call site. And for every variadic argument.

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
:-(


Best regards

Raphael

------------------------------------------------------------------------------
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