My apologies for yet another off-topic post - I hope I am not polluting the 
list.

Unfortunately I am still struggling with stage2 of gcc-4.4 and 4.6 on the NeXT. 
 I think I have everything configured correctly and the stage1 compiler 
produces good executables as long as they do not include jump tables.  
Unfortunately I get bus errors and segmentation faults with jump tables.  I 
think the issue here might be with the limitations of the native NEXTSTEP 
assembler based on gas-1.38.

When I compile the following test program:

int main( void )
{
    int i, value, sum;
    
    i = 2;
    sum = 0;

    switch( i ) 
    {
        case 1:
            value = 1;
            break;
        case 2:
            value = 2;
            break;
        case 3:
            value = 3;
            break;
        case 4:
            value = 4;
            break;
        case 5:
            value = 5;
            break;
        default:
            value = 0;
            break;
    }
        
    sum += value;
    printf( "Sum = %d (case %d)\n", sum, i );
    
    return (0);
}

The stage1 gcc-4.6.3 compiler produces the following assembly:

        .cstring
LC0:
        .ascii "Sum = %d (case %d)\12\0"
        .text
        .align 1
        .globl _main
_main:
        link a6,#-12
        moveq #2,d0
        movel d0,a6@(-8)
        clrl a6@(-12)
        moveq #5,d0
        cmpl a6@(-8),d0
        jcs L2
        movel a6@(-8),d0
        lsll #2,d0
        movel pc@(L8,d0:l),d0
        movel d0,a0
        jmp a0@
        .const
        .align 1
L8:
        .long L2
        .long L3
        .long L4
        .long L5
        .long L6
        .long L7
        .text
L3:
        moveq #1,d0
        movel d0,a6@(-4)
        jra L9
L4:
        moveq #2,d0
        movel d0,a6@(-4)
        jra L9
L5:
        moveq #3,d0
        movel d0,a6@(-4)
        jra L9
L6:
        moveq #4,d0
        movel d0,a6@(-4)
        jra L9
L7:
        moveq #5,d0
        movel d0,a6@(-4)
        jra L9
L2:
        clrl a6@(-4)
        nop
L9:
        movel a6@(-4),d0
        addl d0,a6@(-12)
        movel a6@(-8),sp@-
        movel a6@(-12),sp@-
        pea LC0
        jsr _printf
        addw #12,sp
        clrl d0
        unlk a6
        rts

Could someone please kindly confirm that the above assembly source is good?  
Unfortunately I hardly remember anything at all from my m68k assembly 
adventures 20+ years ago and I have been struggling to decipher it...

Thank you very much!
t-rexky

--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive: http://lists.debian.org/[email protected]

Reply via email to