Switch keyword problem at 8051

Help
Anonymous
2012-01-25
2013-03-12
  • Anonymous - 2012-01-25

    __pdata unsigned char test = 1;
    int main()
    {
        switch( test )
        {
            case 0 : return 0;
            case 1 : return 1;
            case 2 : return 2;
            case 3 : return 3;
            case 4 : return 3;
            case 5 : return 3;
            case 6 : return 3;
            case 7 : return 3;
            case 8 : return 0;
            case 9 : return 1;
            case 10 : return 2;
            case 11 : return 3;
            case 12 : return 3;
            case 13 : return 3;
            case 14 : return 3;
            case 15 : return 3;
            case 16 : return 3;
            case 17 : return 3;
        }
        return 0;
    }

    this c program gives next asm code

    [...]
    ;   main.c:5: switch( test )
        mov r0,#_test
        clr c
        movx    a,@r0
        mov b,a
        mov a,#0x11
        subb    a,b
        jnc 00123$
        ljmp    00119$
    00123$:
        mov r0,#_test
        movx    a,@r0
        add a,#(00124$-3-.)
        movc    a,@a+pc
        push    acc
    >
        add a,#(00125$-3-.)
        movc    a,@a+pc
        push    acc
        ret
    00124$:
        .db 00101$
    [...]
    

    and it looks like instruction "movx a,@r0" is missed at the line I marked with '>'
    please help me to fix this error

     
  • Anonymous - 2012-01-25

    I use sdcc 3.1.0, but sdcc-snapshot-i586-mingw32msvc-20120123-7250.zip produces similar asm code.

     
  • Maarten Brock

    Maarten Brock - 2012-01-27

    You've found a bug in SDCC. Please post it in the bug tracker.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks