iAPX86 code for ABS (using Microsof
mcdonald at uxe.cso.uiuc.edu
mcdonald at uxe.cso.uiuc.edu
Mon Jun 19 22:30:00 AEST 1989
>I remember a review of Microsoft's C compiler for MS-DOS that stated it
>produced no-conditional-jump-abs-code. The function to convert an integer
>to a positive integer was performed without a conditional jump (i.e. JS or
>something). I'm very interested in this piece of code, so if someone
>who does have a Microsoft C-compiler could try something like
> main()
> { int a,b;
> a=-10;
> b=abs(a);
> }
Here is the result of cl -c -Ox -Fa test.c, excluding the header and trailer:
; a = -10
mov WORD PTR [bp-2],-10 ;a
; b = abs(a)
mov ax,-10
cwd
xor ax,dx
sub ax,dx
mov WORD PTR [bp-4],ax ;b
So your review was correct! I assume that they do this odd thing in
order to not empty instruction prefetch queues????????????????
Doug McDonald
More information about the Comp.lang.c
mailing list