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

Reply via email to