Hi Peter,

> > Using the following (on PIC14):
> >
> >     var_u_char_8_b = (unsigned char) (var_int_16 / 8);
> >
> > where:
> >     var_u_char_8_b is unsigned char
> >     var_int_16 is int
> >
> > var_u_char_8_b always seems to be zero.

I cannot reproduce this behaviour (unless I fail to initialize
var_int_16 to something != 0 that is...). I get beautiful results, gpsim
loops happily in my catch-all loop in 
<code filename="bDIV.c">
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;

__data __at (0x60) unsigned int  var_u_int_16;
__data __at (0x62) unsigned char var_u_char_8;
__data __at (0x30) unsigned char var_u_char_8_b;

uchar
div1(int b)
{
    var_u_int_16 = b;
    var_u_char_8_b = (unsigned char) (var_u_int_16 / 7);
    return var_u_char_8_b;
}

void
main(void)
{
    uchar res;

    res = div1(44);
    while (res != 6);
    res = div1(50);
    while (res != 7);
    res = div1(0);
    while (res != 0);

    while (1); /* gpsim reaches here */
}
</code>
sdcc -mpic14 -p16f877 bDIV.c

Could you post a more complete example showing your error?

> I was using the following so I could nail down where the offending 
> variables were in gpsim, I declaired the varibles as shown here:
> 
>  __data __at (0x60) unsigned int var_u_int_16;
> __data __at (0x62) unsigned char  var_u_char_8;
> __data __at (0x030) unsigned char var_u_char_8_b;
> 
> var_u_char_8 and var_u_char_8_b seem to end up where told but var_u_int_16 
> seems to end up at 0x63 & 0x64!

This was a bug, which is now (r4440) fixed: SDCC/pic14 emitted
_var_u_int_16 twice, once in its pinned location and again in udata. You
did get a warning from gplink about this though... (value of symbol
_var_u_int_16 changed in second pass).

-- 

Regards,
Raphael Neider



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to