What was the other error?

psllq mm0,4
I already showed it in my post.
In new code (code is much better) the same error again.
Check in debugger and change psllq mm0,4 to
psllq mm1,4
Posted on 2002-03-23 18:57:44 by The Svin
Thank you, I see now.
Algo works for lowercase letters, too. :)
StrHex2bin PROC

_CONST SEGMENT
lpString db "89aBcDeF"
_CONST ENDS

movq mm0,QWORD PTR [lpString]
pcmpeqb mm2,mm2 ; mxc(<FF>[b][/b])

psubusb mm0,mxc(<30>[b][/b]) ; "0" = 0
psrlw mm2,12 ; mxc(<000F>[b][/b])

movq mm1,mm0
pcmpgtb mm0,mxc(<09>[b][/b]) ; letter?

pand mm0,mxc(<07>[b][/b])

psubusb mm1,mm0 ; fix letters

movq mm0,mm1 ; .F.E.D.C.B.A.9.8
psrlq mm1,8 ; ...F.E.D.C.B.A.9

pand mm0,mm2 ; ...E...C...A...8
pand mm1,mm2 ; ...F...D...B...9

packuswb mm0,mm0 ; .E.C.A.8
packuswb mm1,mm1 ; .F.D.B.9

psllq mm0,4 ; E.C.A.8.

por mm0,mm1 ; EFCDAB89

movd eax,mm0 ; EFCDAB89

bswap eax ; 89ABCDEF

ret
StrHex2bin ENDP
My tests show that in the best case this algo is three times faster than buliaNaza's, but 40x slower in the worst case. The worst case occurs when the MMX mask data isn't in the cache - my processor is taking 20 cycles to load a cache line, and 5 cycles for MOVD to complete. :(

These tests assumed the hex string is in the cache - which is a safe assumption, IMO. This algo has very limited use.
Posted on 2002-03-23 20:06:03 by bitRAKE
hi!

That's the code, which I've done before some months :



hexstr2dw PROC lpString:DWORD
push ebx

mov eax, lpString
mov edx, dword ptr [eax]
mov eax, dword ptr [eax + 4]

mov ebx, edx
mov ecx, edx
shr ebx, 3
shr ecx, 6
and ebx, 00001000000010000000100000001000b
and ecx, 00000001000000010000000100000001b

or edx, ebx
add edx, ecx

and edx, 00001111000011110000111100001111b

mov ebx, edx
shl ebx, 12
or edx, ebx

mov bl, dh
shr edx, 24
mov dh, bl

shl edx, 16

;-----

mov ebx, eax
mov ecx, eax
shr ebx, 3
shr ecx, 6

and ebx, 00001000000010000000100000001000b
and ecx, 00000001000000010000000100000001b

or eax, ebx
add eax, ecx

and eax, 00001111000011110000111100001111b

mov ebx, eax
shl ebx, 12
or eax, ebx

mov dh, ah
shr eax, 24
mov dl, al

mov eax, edx

pop ebx
ret
hexstr2dw ENDP


It works without any jumps and without MMX and looks a bit unusual :) ... but works.

Cu, JNS
Posted on 2002-03-24 03:14:38 by Jens Duttke

These tests assumed the hex string is in the cache - which is a safe assumption, IMO. This algo has very limited use.

:)
Don't be sad,Rickey. Change logic - push those values as immidiate into stack and then work with stack - they all will be in chache. Then read at least one of it into mmreg

Jens,
Thanks, for your code!
Posted on 2002-03-24 05:56:07 by The Svin
bitRAKE,
I figured out how to generate those values you use from memory without any memory access in runtime :)
So you don't need memory access at all.
I think - it's good exersize for to do it yourself, so I don't say how
to do it for a while :)
Posted on 2002-03-24 06:32:33 by The Svin
This is Stepan Polovnikov post to fido7.talks.asm:
mmxbC9      dq 0C9C9C9C9C9C9C9C9h

mmxb39 dq '99999999'
mmxb07 dq 0707070707070707h

;<esi-string (upper or lower case)

;>eax-number

movq mm0,[esi]
movq mm1,mm0
paddb mm0,[mmxbC9]
pcmpgtb mm1,[mmxb39]
pandn mm1,[mmxb07]
paddb mm0,mm1
movq mm1,mm0
psllw mm0,12
psllw mm1,4
psrlw mm0,12
psrlw mm1,12
packuswb mm0,mm0
packuswb mm1,mm1
psllq mm0,4
paddb mm0,mm1
movd eax,mm0
bswap eax

Stepan
I guess he doesn't frequent this board?
Posted on 2002-03-24 12:14:36 by bitRAKE
Thanks bitRake!

Very nice code...
Posted on 2002-03-24 12:57:42 by buliaNaza
I guess he doesn't frequent this board?

I was dreaming for a long time, that the algo section could gather
creative asm programmers.
Now it becomes reality, I would be happy if Stepan could apear here, last time I asked him he said that unfortunatly he has not
time. I hope one day he will be able to come here.
For now I 'm happy to have ablility to communicate with talanted people such as Naza, Jens, Nexo, Eyen and many others. Did I mention you?
I think that if progression of creativity in the algo section grow Fog and the others will appear here sooner or later too.
Sure they will.
Posted on 2002-03-24 14:03:02 by The Svin
I found a way how to short Stepan's algo by one redantant instruction:


mmxbC9 dq 0C9C9C9C9C9C9C9C9h
mmxb39 dq '99999999'
mmxb07 dq 0707070707070707h;
;<esi-string (upper or lower case);>eax-number
movq mm0,[esi]
movq mm1,mm0
paddb mm0,[mmxbC9]
pcmpgtb mm1,[mmxb39]
pandn mm1,[mmxb07]
paddb mm0,mm1
movq mm1,mm0
psllw mm0,12 ;all needless garbage allready cleared here
psllw mm1,4
;! psrlw mm0,12
psrlw mm0,8 ;! put in right place odd tetrada
psrlw mm1,12
packuswb mm0,mm0
packuswb mm1,mm1
;! psllq mm0,4 ;odd tetrada is already in right place
;we can leave out this instruction
paddb mm0,mm1
movd eax,mm0
bswap eax
Posted on 2002-03-30 13:12:33 by The Svin
This is impressive, Svin! Wonder how I missed it. ;)
Posted on 2002-03-30 13:30:13 by bitRAKE
hi
Jens Duttke 's code



mov ebx, edx
mov ecx, edx
shr ebx, 3
shr ecx, 6
can i put this code instead ?

mov ecx, edx
shr ecx, 6 ;/ 2^6
lea ebx,[ecx*8]


bye
eko
Posted on 2002-03-30 18:03:16 by eko
About one year the knowledge base from Stepan was not updated. But now why that has passed upgrade on a current subject:

mmxbC9 dq 0C9C9C9C9C9C9C9C9h
mmxb39 dq '99999999'
mmxb07 dq 0707070707070707h

; < esi-string (upper or lower case)
; > eax-number
movq mm0,
movq mm1, mm0
paddb mm0,
pcmpgtb mm1,
pandn mm1,
paddb mm0, mm1
movq mm1, mm0
psllw mm0,12
psllw mm1,4
psrlw mm0,8
psrlw mm1,12
paddb mm0, mm1
packuswb mm0, mm0
movd eax, mm0
bswap eax
Posted on 2002-03-31 04:29:37 by Nexo
Nexo, where can one obtain 'knowledge base from Stepan'?
Posted on 2002-03-31 04:36:04 by bitRAKE
Maybe he means FidoNet? :)
bitRake, the proc your posted from FidoNet, was answer to my question to Polovnikov and dated 3.24.2002
Yesterday I send him fidomail with correction, result is "base update" :)
Posted on 2002-03-31 05:12:26 by The Svin
I asked him by fidomail about "base", he said that after our disscusion of some algos he took decison to revise and correct his pocs collections, but since a lot of work involved his is going to do it in his vacation. After that it's upto him if he decide to make it piblic. Stepan IMHO one of most creative x86 asm coders of present time, so if he submit it you can see not only fast and reliable routins but also new ideas in it that can be applyed to defferent cases.
Posted on 2002-03-31 05:45:19 by The Svin
bitRAKE, it is the closed knowledge base of ours developers group. All members are given warning on variations in the knowledge base on our network. The last variation was marked, as " public release ". Stepan is engaged in creation and optimization of base procedures and update the knowledge base. After the warning of variations others execute rebuild the projects. At creation of the program the retrieval mechanism in the knowledge base uses. It allows to spare a time at development and allows to create the most power programs. In structure some levels of the knowledge base use. The last instance was from the low level are base procedures. It varies very seldom. Some hundreds procedures generally represented. It is result assiduous 11 years Stepan's work in this area. He adheres to policy of non-distribution of the solutions, but recently occur softening conditions for the out-of-date and widely widespread technologies.
Posted on 2002-03-31 08:20:06 by Nexo
Stange way we get info about our freinds :)
For a long time we were exchanging ideas and procs he never mentioned of this magic library ...
Well I can understand it,
though some sad thoughts came to me when you mentioned of
"most powerfull progs".
It reminds me of Babayan team and Elbrus-2. (Not only of course,
they did all general optimal bynary algos that now used in all computers,they were published starting 1956)
Though it was first superscalar 12 years before West one, and still most powerfull almost nobody here knows it. It's funny hearing here of latest "powerfull" stones like superscalar Althon with ability to handle almost 3 execution per circle while Elbrus-2 was
able make 25 executions per circle already in 1985.
I mean, were is our powerfull progs? I don't mean military research, but commersials. Only known mostly some reverse tools
like Hiew, IDA etc.
We is still country of oil and wood, no matter of great brains and hard job we do in sientific researches.
Sasha Usov also talking of being buzy making "most powerfull progs" but where are all this powerfull progs ?

It was nothing ...
Just forget it.
Posted on 2002-03-31 09:12:36 by The Svin
Nexo, that was my first assumption - that it was private. After reading some of Stepan's code, my mouth waters for more. I have a deep respect for his work even though it is quite new to me, and hope to see greater softening of the conditions of the library (or to join your developers group :)).
Posted on 2002-03-31 10:58:43 by bitRAKE
The Svin, do not touch Babayan. It is my idol:) E2K (Elbrus2000) should appear this year with frequency of 2200 MHz. Power programs are created on power algorithms. Try to think up power algorithm for the following task:
http://www.asmcommunity.net/board/index.php?topic=4553
Posted on 2002-03-31 12:53:09 by Nexo
"The Svin, do not touch Babayan. "

My idol too. Without his example it's hard to cotninue what we do.
Posted on 2002-03-31 13:00:58 by The Svin