Dear Phillipp,

Yes, you are absolutely right: for relocatable symbols things go awry. When
attempting my previous tests on a relocatable symbol more issues can be
seen:

      010050                        123 _test1:
                                    124 ;       test.c: 126: __endasm;
                                    125 ;       Assembler test: loading
0xhhmmll (high, mid, low) bytes into x and a.
                           332211   126         pattern = 0x332211

                                    127 ;       Load mid and low.
      010050 AE 00 50         [ 2]  128         ldw     x, #_test1
      010053 9D               [ 1]  129         nop
      010054 9D               [ 1]  130         nop

                                    131 ;       Load low byte (xh is set to
0).
                                    132 ;       Does not seem to work with
relocatable symbol (relocation error).
      010055 AE 00 11         [ 2]  133         ldw     x, #<pattern
      010058 9D               [ 1]  134         nop
      010059 9D               [ 1]  135         nop

                                    136 ;       Load mid byte (xl is set to
0).
                                    137 ;       Does not seem to work with
relocatable symbol (relocation error).
      01005A AE 00 22         [ 2]  138         ldw     x, #>pattern
      01005D 9D               [ 1]  139         nop
      01005E 9D               [ 1]  140         nop

                                    141 ;       Load high and mid. Gives
incorrect result and overwrites next memory location.
      01005F AE 80 AB         [ 2]  142         ldw     x, #(_test1>>8)
      010062 C2               [ 1]  143         nop
      010063 9D               [ 1]  144         nop

                                    145 ;       Load high (xh is set to 0).
Gives incorrect result.
      010064 AE 00 50         [ 2]  146         ldw     x, #(_test1>>16)
      010067 9D               [ 1]  147         nop
      010068 9D               [ 1]  148         nop

                                    149 ;       Load low.
      010069 A6 50            [ 1]  150         ld      a, #_test1
      01006B 9D               [ 1]  151         nop
      01006C 9D               [ 1]  152         nop

                                    153 ;       Load mid (2 methods).
      01006D A6 00            [ 1]  154         ld      a, #(_test1>>8)
      01006F 9D               [ 1]  155         nop
      010070 9D               [ 1]  156         nop
      010071 A6 00            [ 1]  157         ld      a, #>_test1
      010073 9D               [ 1]  158         nop
      010074 9D               [ 1]  159         nop

                                    160 ;       Load high.
      010075 A6 01            [ 1]  161         ld      a, #(_test1>>16)
      010077 9D               [ 1]  162         nop
      010078 9D               [ 1]  163         nop

Still a few challenges left...

 Eric



> -----Oorspronkelijk bericht-----
> Van: Philipp Klaus Krause [mailto:p...@spth.de]
> Verzonden: vrijdag 6 april 2018 14:24
> Aan: sdcc-user@lists.sourceforge.net
> Onderwerp: Re: [Sdcc-user] How to deal bytewise with 24-bit symbols in
> asxxx x?
> 
> 
> Am 06.04.2018 um 14:12 schrieb Eric Rullens:
> > Dear Philipp,
> > 
> > Apologies for bumping into this conversation (and thank you 
> very much for
> > all the work!), but I think the assembler does what it should do.
> > 
> > Please consider the following:
> > 
> > […]
> > 
> >                               124 ; Load high and mid.
> > 00804E AE 33 22         [ 2]  125   ldw     x, #(pattern>>8)
> 
> This one is the problem.
> 
> void main(void)
> {
> __asm
>       nop
>       ldw     x, #(_main >> 8)
>       nop
> __endasm;
> }
> 
> results in this listing (comments removed):
> 
> _main:
>       000000 9D               [ 1]   87       nop
>       000001 AEr00r00         [ 2]   88       ldw     x, #(_main >> 8)
>       000004 9D               [ 1]   89       nop
>       000005 87               [ 5]   94       retf
> 
> And this binary:
> 
> :04F000008200F00892
> :1DF00800AE00002707724F00005A26F9AE00002709D6F02AD700005A26F7CCF004F9
> :04F00400AC00F02547
> :06F025009DAE00F0C28761
> :00000001FF
> 
> As you can see, the second nop got overwritten by 0xc2. Whenever I use
> #(sym >> 8) where a 16-bit value is expected, I see the following
> instruction being overwritten.
> 
> Philipp
> 
> --------------------------------------------------------------
> ----------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to