This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

volatile pointer bug with h8300 target


before applying the egcs-1.1.1-19990103-expr.patch to fix the
volatile pointer bug, I checked my h8300-hitachi-hms-gcc's output.

It's been ok but I was using -Os flag so I removed it and recompiled.
Here's the results:

Test1:
     62 write_device(unsigned char *addr, int val)
     63 {
     64         volatile unsigned char *ptr = addr;
     65         *ptr = val;
     66 }

result1.1: no -O flag

    551         mov.w   r0,@(-2,r6)     ;addr to @(-2,r6)
    552         mov.w   r1,@(-4,r6)     ;val to @(-4,r6)
    553         .ln     2
    554         .def    _ptr
    555         .val    -6
    556         .scl    1
    557         .type   034
    558         .endef
    559         mov.w   @(-2,r6),r2     ;addr in @(-2,r6) to r2
    560         mov.w   r2,@(-6,r6)     ;addr in r2 to _ptr at @(-6,r6)
    561         .ln     3
    562         mov.w   @(-6,r6),r2     ;addr in _ptr at @(-6,r6) to r2
    563         mov.b   @(-3,r6),r3l    ;low byte of _val in @(-4,r6) to
r3l
    564         mov.b   r3l,@r2         ;WRITE low byte of _val in r3l
to addr in r2 here!!!
    565         mov.b   @r2,r3l         ;read it back again <this is
bogus>
    566         mov.b   r3l,@r2         ;write it back again <this is
bogus>

result1.2: with -Os flag

    537         mov.b   r1l,@r0 


Oh yeah, let's hear it for optimisation!!!!!


I did some other tests with volatile ptrs but it's only with
the function with two args passed in that exhibited the
problem:

Test2:
     62         BYTE b = 0x12;
     63         volatile unsigned char *ptr = 0xFFC6;
     64         *ptr = b;

result 2.1, no -O option

    483         mov.b   #18,r2l
    484         mov.b   r2l,@(-2,r6)
    485         .ln     21
    486         mov.w   #-58,r2
    487         mov.w   r2,@(-4,r6)
    488         .ln     22
    489         mov.w   @(-4,r6),r2
    490         mov.b   @(-2,r6),r3l
    491         mov.b   r3l,@r2

result 2.2, -O option

    481         mov.b   #18,r3l
    482         .ln     21
    483         mov.w   #-58,r2
    484         .ln     22
    485         mov.b   r3l,@r2

Test3:
     62         volatile unsigned char *ptr = 0xFFC6;
     63         *ptr = 0x12;

result 3.1 no -O option
    478         mov.w   #-58,r2
    479         mov.w   r2,@(-4,r6)
    480         .ln     21
    481         mov.w   @(-4,r6),r2
    482         mov.b   #18,r3l
    483         mov.b   r3l,@r2

result 3.2 -O option
    476         mov.w   #-58,r3
    477         .ln     21
    478         mov.b   #18,r2l
    479         mov.b   r2l,@r3


I tried another pair of tests with a read instead of write (val = *ptr)
and it worked the same.....no further double read/write troubles.

During this exercise, I also discovered a bug in
h8300-hitachi-hms-objdump
so the outputs above were made by gcc -S.

I'll report the objdump thing later, I need to actually spend some time
on
my project instead of just playing with my tools ;).


--
|\/|
|/\|  randall@elgar.com
|\/|  rsl@zanshinsys.com http://www.zanshinsys.com
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.