Hi Nelder,

I never tried the simulator, but I will give it a shot later. I checked out
the SDCC 2.6.4 r4570 yesterday but it didn't compile... just now I tried
r4573 and it still didn't compile. I get "Caught signal 11: SIGSEGV" when it
tries to compile the device libs... Anyway I think it would be more
appropriate to discuss compilation problem in a different thread.

I use two LEDs to debug my program in the device. I have one green LED in
RA4 and another orange LED in RB4. The green LED goes on with PORTA = 0x00
and goes off when PORTA = 0x10. The same for the orange LED with PORTB.

I initialize both PORTA and PORTB with 0x10 and then I did something like
this to test the value in *p:
   if (*p == 0x34)
   {
       PORTA = 0x00; // green
   }
   if (*p == 0x12)
   {
       PORTB = 0x00; // orange
   }
   while (1);

When the assignment is commented out the green is on. When the assignment is
put in there both LEDs remain off. On the other hand, if I declare the
pointer as (data unsigned char *) then the orange goes on (suggestion of
Ernst). Nevertheless, that same solution does not work with function
arguments:

void change_value(data unsigned char *pointer)
{
   *pointer = 0x12;
}

void main(void)
{
   unsigned char c = 0x34;
   data unsigned char *p;

   p = &c;

   change_value(p);
(...)

Both LEDs remain off. I already tested the function with generic pointers
before, and also tried to cast before assignmend of address "p = (data
unsigned char)&c;" but neither worked.

I am sure the value is neither 0x34 nor 0x12 after assignment with general
pointer. I also suspect there was some data memory corruption because when I
first noticed the problem in the actual application some very unrelated
variable seemed messed up... but I didn't isolate that problem to be sure...
(difficult to reproduce).

Regards,
Guerra

On 1/14/07, Raphael Neider <[EMAIL PROTECTED]> wrote:

Hi Rodrigo,

> void main(void)
> {
>      unsigned char c = 0x34;
>      unsigned char *p;
>
>      p = &c;
>      *p = 0x12;
}

> Any help appreciated.

The above code snippet compiles fine with SDCC 2.6.4, r4570.
_main_c_1_1 (alias c) ends up at 0x80, p=&c makes p=(0x80, 0x00, 0x80),
the first 0x80 (MSB) being the pointer type (0x80 --> __data), and
0x0080 being the address of c in data memory.
*p=0x12 assigns 0x12 to memory location 0x80 (alias c), which seems to
be perfectly fine. Tested with gpsim. Even reading back *p (glo = *p;
with a global `char glo;' declared before main()) works nicely.

Could you give more information? How did you `test *p' after the last
line of code? What did you perceive?

--

Regards,
Raphael Neider



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user




--
Rodrigo da Silva Guerra
PhD Student

Department of Adaptive Machine Systems
Graduate School of Engineering
Osaka University - Japan
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to