Am 02.04.2018 um 14:35 schrieb Maarten Brock:
> 
> In the generated code I see that the lower 16 bits are loaded into x, not
> the upper. And the most significant byte is loaded into a by using #<sym,
> but that seems to fail. If you instead use #(sym>>16) it seems alright to
> me.
> 
> Maarten

void f(void)
{
        void (*p)(void) = &f;
        (*p)();
}

compiles to:

        ld      a, #<_f
        ldw     x, #_f
;       test.c: 4: (*p)();
        push    #(00103$)
        push    #(00103$ >> 8)
        push    #(00103$ >> 16)
        push    a
        ld      a, xl
        push    a
        ld      a, xh
        push    a
        retf
00103$:
;       test.c: 5: }
        retf

The lower 16 bits are loaded into x (but it should be the upper 16
bits). The lower 8 bits get loaded into a correctly.

I guess I'll implement some workaround that makes the register allocator
not want to use x for the upper 16 bits in such an assignment (but I
don't like having code geneation need workarounds for assembler issues).

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

Reply via email to