flat assembler
Message board for the users of flat assembler.
Index
> Main > fast print byte in binary string |
Author |
|
edfed 09 Jan 2008, 13:15
Code: b2bin: mov ah,al mov bx,ax shl eax,16 mov ax,bx movd mm0,eax punpckldq mm0,mm0 pand mm0,[.01] pcmpeqb mm0,[.01] pand mm0,[.02] paddb mm0,[.03] movq [edi],mm0 ;... align 8 .01 dq 0x0102040810204080 .02 dq 0x0101010101010101 .03 dq 0x3030303030303030 working with little register is faster. align Qword data on qword boundary improve the speed giving shorter label makes the compilation faster too. |
|||
09 Jan 2008, 13:15 |
|
Octavio 09 Jan 2008, 16:25
using a lookup table will be faster
but better don't waste time optimizing everything. >working with little register is faster. mixing 8-16bit instructions with 32bit instructions is slower. |
|||
09 Jan 2008, 16:25 |
|
edfed 09 Jan 2008, 19:43
ok, modification:
Code: and eax,0ffh ;movzx eax,al mov ah,al ;or ah,al mov ebx,eax shl eax,16 add eax,ebx ;or eax,ebx ... i agree with look up table. it's the faster way to obtain a byte to string conversion. and changing the lookup table changes the conversion type. look up tables are commonly used in embeded DSP applications, to improve treatment speed. |
|||
09 Jan 2008, 19:43 |
|
bitRAKE 09 Jan 2008, 21:03
Code: shl ax,9 repeat 7 adc al,$30 stosb salc shl ax,1 end repeat adc al,$30 stosb maybe use : pshufw mm0,mm0,0 ? |
|||
09 Jan 2008, 21:03 |
|
Octavio 10 Jan 2008, 09:13
Code: mov eax,al imul eax,1010101h |
|||
10 Jan 2008, 09:13 |
|
Madis731 10 Jan 2008, 10:33
Pure 64-bit, 74 bytes, unoptimized, 5.4-5.5 clocks in a repetitive loop.
One-shot is around 132-RDTSC time (which is around 29 clocks+64 latency) Code: mov eax, (not 101) and 0FFh mov rbx, 0101010101010101h mov r10, 8080808080808080h mov r11, 3030303030303030h mov rcx, 0102040810204080h imul rax,rbx and rax,rcx mov rdx,rax not rax sub rdx,rbx and rax,r10 and rax,rdx shr rax,7 add rax,r11 Btw, isn't there a *magic* value? AL_BIN*MAGIC=AL_ASCII EDIT: No there isn't its not linear, but exponential. |
|||
10 Jan 2008, 10:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.