All pastes #720489 Raw Edit

Mine

public text v1 · immutable
#720489 ·published 2007-09-30 11:24 UTC
rendered paste body
; Task: Getting the absolute value of EAX


; Approach 1
cwd			; sign-extend into edx
xor	eax, edx	; eax is negated if negative
sub	eax, edx	; one is added (-1 is subtracted) to eax


; Approach 2
cwd			; sign-extend into edx
shl	edx, 1		; ensure least significant bit is zero (0->0, -1->-2)
xor	eax, edx	; negate eax if it was negative