MSC 5.1 bug ??

Kevin D. Quitt kdq at demott.COM
Thu Feb 22 03:20:31 AEST 1990


    Your head was on right; I couldn't believe it either.  I suspected
then disproved: 1) -1 generated 0x0000FFFF instead of 0xFFFFFFFF, 2) an
unsigned comparison.

    The generated test code is completely bogus.  In fact, it is such a lose
that the optimiser COMPLETELY ELIMINATES THE TEST!



              Code generated with optimization disabled:


$SG106  DB      'yes',  00H
$SG108  DB      'no',  00H

;|***   int             i = 0;
        mov     WORD PTR [bp-2],0       ;i

;|***   long    l = -1;
        mov     WORD PTR [bp-6],-1      ;l
        mov     WORD PTR [bp-4],-1

;|***   if ( l  >=  (i & 1 ) )
        mov     al,BYTE PTR [bp-2]      ;i
        and     ax,1
        sub     dx,dx
        cmp     dx,WORD PTR [bp-4]
        jbe     $JCC37
        jmp     $I104
$JCC37:
        jae     $JCC42
        jmp     $L20001
$JCC42:
        cmp     ax,WORD PTR [bp-6]      ;l
        jbe     $JCC50
        jmp     $I104
$JCC50:
$L20001:
;|***           puts( "yes" );
        mov     ax,OFFSET DGROUP:$SG106
        push    ax
        call    _puts
        add     sp,2

;|***   else
        jmp     $I107
                                $I104:
;|***           puts( "no" );
        mov     ax,OFFSET DGROUP:$SG108
        push    ax
        call    _puts
        add     sp,2
$I107:
;|***    }
$EX101:



              Code generated from optimised compilation:


$SG143  DB      'yes',  00H
$SG145  DB      'no',  00H

;|***   int             i = 0;
        mov     WORD PTR [bp-2],0       ;i

;|***   long    l = -1;
        mov     WORD PTR [bp-6],-1      ;l
        mov     WORD PTR [bp-4],-1
 
;|***   if ( l  >=  (i & 1 ) )
;|***           puts( "yes" );
        mov     ax,OFFSET DGROUP:$SG143
        push    ax
        call    _puts
;|***   else
;|***           puts( "no" );
;|***    }


    Amazing (shake of the head).

kdq
-- 



Kevin D. Quitt                          Manager, Software Development
DeMott Electronics Co.                  VOICE (818) 988-4975
14707 Keswick St.                       FAX   (818) 997-1190
Van Nuys, CA  91405-1266                MODEM (818) 997-4496 Telebit PEP last
34 12 N  118 27 W                       srhqla!demott!kdq   kdq at demott.com



More information about the Comp.lang.c mailing list