Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

Dominikus Dittes Scherkl via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 9 11:11:12 PDT 2014


On Wednesday, 9 July 2014 at 17:13:21 UTC, H. S. Teoh via 
Digitalmars-d-learn wrote:
> The branched version would look something like this:
>
> 	mov	eax, [<address of u>]
> 	mov	ebx, [<address of s>]
> 	cmp	ebx, $#0
> 	jge	label1		; first branch
> 	mov	eax, $#FFFFFFFF
> 	jmp	label2		; 2nd branch
> label1:
> 	sub	eax, ebx
> label2:
> 	(ret)
Why?

I would say:
         mov     eax, [<adress of s>] ; mov directly compares to 
zero
         jl      lable                ; less -> jump to return
         sub     eax, [<adress of u>]
         neg     eax                  ; because we subtracted in 
the wrong order
lable:  ret


More information about the Digitalmars-d-learn mailing list