www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/18/08:09:23

From: knakasato AT aol DOT com (KNakasato)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: !!Absolute value with inline ASM!!
Date: 18 Feb 1998 08:07:18 GMT
Lines: 44
Message-ID: <19980218080701.DAA03384@ladder03.news.aol.com>
NNTP-Posting-Host: ladder03.news.aol.com
References: <34E859F8 DOT ADB0A110 AT mail DOT htk DOT fi>
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019