COMPARE HLL/ASM
- From: "Wolfgang Kern" <nowhere@xxxxxxxx>
- Date: Tue, 25 Dec 2007 18:13:01 +0100
santosh suggested (in reply to Wannabee):
....
Tell you what, if you are up to it, lets do a routine to convert an
hexadecimal string (without '0x' prefix or 'h' suffix) into the
corresponding 64 bit numerical value. You do yours in assembler and
I'll do mine in C and lets compare the relative speed for a few million
passes over the test string. We can use C's clock() function or RDTSC,
whichever you prefer. Respond if you are up to it and I'll post my
version's source and test run on my machine.
I think we've done something similar a few years ago.
But I like the idea so let's start with it:
If you don't mind, I specify in more detail:
* string is zero-padded fix-sized, no leading spaces ,no end-mark and
UPPERCASE ie: "FEDCBA98"
* no error indication if any non hex-characters are found.
* just for compatibilty with oldies: no SSE-instructions allowed.
* there are no C-functions available on most ASM tools,
so RDTSC seems to be the only choice.
* running it several million times will just measure back-ground
noise from the OS, and STI/CLI may not work on every OS.
I'd recommend to run it three to four times and report the smallest
time interval.
* the choosen algos may be a main timing issue ...
Myhex2bin:
MOV esi,string ;8 bytes
MOV eax,[esi]
MOV edx,[esi+4]
hex2bin: ;** edx:eax to eax **
BSWAP eax ;assuming strings LSD is rightmost
BSWAP edx
SUB eax,30303030h
SUB edx,30303030h
MOV ebx,eax ;copy low
MOV ecx,edx ;copy high
AND eax,10101010h
AND edx,10101010h
SHR eax,4
SHR edx,4
IMUL eax,7
IMUL edx,7
SUB ebx,eax
SUB ecx,edx
; we got unpacked BCD with leftmost MSD in ebx:ecx yet.
packBCD:
...
Sorry, interrupted by these obligatory holyday visitors yet :)
I'll post the rest later ...
__
wolfgang
.
- Follow-Ups:
- Re: COMPARE HLL/ASM
- From: Wolfgang Kern
- Re: COMPARE HLL/ASM
- From: santosh
- Re: COMPARE HLL/ASM
- From: Charles Crayne
- Re: COMPARE HLL/ASM
- References:
- Re: Is PSHUFW instruction MMX or SSE or SSE2? Is NASM manual correct?
- From: //\\\\o//\\\\annabee
- Re: Is PSHUFW instruction MMX or SSE or SSE2? Is NASM manual correct?
- From: santosh
- Re: Is PSHUFW instruction MMX or SSE or SSE2? Is NASM manual correct?
- Prev by Date: Re: Is PSHUFW instruction MMX or SSE or SSE2? Is NASM manual correct?
- Next by Date: Re: Is PSHUFW instruction MMX or SSE or SSE2? Is NASM manual correct?
- Previous by thread: Re: Is PSHUFW instruction MMX or SSE or SSE2? Is NASM manual correct?
- Next by thread: Re: COMPARE HLL/ASM
- Index(es):
Relevant Pages
|