Mail Archives: djgpp/1998/02/18/08:09:23
>I need to get the absolute value of a registers (bx)
>How is this done in asm.(in one command, not using cmp)
There's many way, but best way might be test/jz combo that you rejected for
some unknown
reason.
CMPXCHG is 486+ instruction and it probably takes longer....
mov ax, bx
mov dx, bx
or ax, 8000h
neg dx
vcmpxchg bx, dx
IMUL is also slower
MOV dx,bx
mov AX,0
add dx,dx
rcl ax,2
dec ax
neg ax
imul bx,ax
IMO you shouldn't worry about these type of optimization unless you have deep
knowlege
of ASM.
My 686MX can handle jz in 2 cycles on average..
test bx, 8000h
... do other stuff
jz short skip
neg bx
skip:
waist your time optimizing unless you
Aloha
- Raw text -