Thread View: borland.public.delphi.basm
3 messages
3 total messages
Started by Dennis
Mon, 02 Sep 2002 08:15
Abs
Author: Dennis
Date: Mon, 02 Sep 2002 08:15
Date: Mon, 02 Sep 2002 08:15
7 lines
1054 bytes
1054 bytes
Hi How do i find the absolute value of an signed integer the fastest way? 8 bit, 16 bit & 32 bit integers. Dennis
Re: Abs
Author: Guido Gybels
Date: Mon, 02 Sep 2002 09:22
Date: Mon, 02 Sep 2002 09:22
21 lines
1565 bytes
1565 bytes
"Dennis" <marianndennis@email.dk> wrote in message
news:3D731E35.519D3AF5@email.dk...
> How do i find the absolute value of an signed integer the fastest way?
Use Pascal. Abs is not a real function and the compiler will generate the
appropriate code inline. That will always be faster than any call to a
separate assembly function. Besides there is not much to be optimised about
something like:
cdq
xor eax,{some register}
sub eax,{same register}
Guido
--
Guido Gybels
http://www.optimalcode.com/Guido
(Disclaimer: all remarks made apply to Intel processors unless specified
otherwise)
Re: Abs
Author: Pierre Maurette
Date: Tue, 03 Sep 2002 03:32
Date: Tue, 03 Sep 2002 03:32
28 lines
1430 bytes
1430 bytes
"Guido Gybels" <guido.gybels@rnid.org.uk> a οΏ½crit dans le message de news:
3d732d53@newsgroups.borland.com...
> "Dennis" <marianndennis@email.dk> wrote in message
> news:3D731E35.519D3AF5@email.dk...
> cdq
> xor eax,{some register}
> sub eax,{same register}
>
32:
[{some register} is edx]
cdq
xor eax, edx
sub eax, edx
16:
cwd
xor ax, dx
sub ax, dx
8:
cbw
xor al, ah
sub al, ah
[Search for Q31810 in Microsoft's knowledge base]
Pierre
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads