flat assembler
Message board for the users of flat assembler.
Index
> Main > MMX convert text to byte value. |
| Author |
|
|
Roman 08 Sep 2026, 18:12
Code: ttt db '16' intV db 0 sub word [ttt],0x3030 movzx eax,byte [ttt] imul eax,10 add al,[ttt+1] mov [intV],al |
|||
|
|
revolution 08 Sep 2026, 18:30
Dor the limited set of two digit bcd inputs.
Code: mov ax,word[bcd] sub ax,'00' imul ax,0x10a mov [result],ah bcd db '16' result db ? |
|||
|
|
Roman 08 Sep 2026, 18:50
Quote:
Wrong result. |
|||
|
|
revolution 08 Sep 2026, 18:53
Wrong multiplier.
Code: mov ax,word[bcd] sub ax,'00' imul ax,0xa01 mov [result],ah bcd db '16' result db ? |
|||
|
|
Roman 08 Sep 2026, 19:12
Intel was supposed to do it this way AAD
Code: aad al,ah,0x30 ;= sub al,0x30 and sub ah,0x30 and p1*10+p2. p1=al and p2=ah |
|||
|
|
Roman 09 Sep 2026, 07:04
from 0 to 9999
Code: ttt db '4687' intVal dw 0 movzx eax,word [ttt] sub ax,'00' imul ax,0xa01 sub al,al imul eax,100 movzx ecx,word [ttt+2] sub cx,'00' imul cx,0xa01 sub cl,cl add eax,ecx ;as integer value. EAX=0x00124F00 shr eax,8 mov [intVal],ax ;eax=4687 |
|||
|
|
revolution 09 Sep 2026, 12:09
Now convert to MMX
|
|||
|
|
Roman 09 Sep 2026, 13:45
Quote: Now convert to MMX I not any idea how do this. especially this imul ax,0xa01 |
|||
|
|
revolution 09 Sep 2026, 14:15
Roman wrote: ... imul ax,0xa01 |
|||
|
|
Roman 09 Sep 2026, 16:24
I do this but code size as prevision
Code: tt db '4687' ;this variant good for two numbers like as '4687' and '1635' tt2 db 48,48,48,48 tt3 dw 0xa01,0xa01 tt4 db 0,255,0,255,0,0,0,0 result dd 0,0 movd mm0,dword [tt] psubb mm0,qword [tt2] pmullw mm0,qword[tt3] pand mm0,qword [tt4] movd ecx,mm0 shr ecx,8 movzx eax,cl imul eax,100 shr ecx,16 add ax,cx ;eax=4687 ;second variant movd mm0,dword [tt] psubb mm0,qword [tt2] pmullw mm0,qword[tt3] pand mm0,qword [tt4] movq qword [result],mm0 movzx eax,byte [result+1] imul eax,100 add ax,word [result+3] ;eax=4687 ;theerd variant tt db '96878687' tt2 db 48,48,48,48, 48,48,48,48 tt3 dw 0xa01,0xa01,0xa01,0xa01 tt4 db 0,255,0,255,0,255,0,255 movq mm0,qword [tt] psubb mm0,qword [tt2] pmullw mm0,qword[tt3] pand mm0,qword [tt4] movq qword [result],mm0 movzx eax,byte [result+1] imul eax,100 add ax,word [result+3] imul eax,10000 movzx ecx,byte [result+5] imul ecx,100 add cx,word [result+7] add eax,ecx ;eax=96878687 integer Last edited by Roman on 11 Sep 2026, 05:37; edited 7 times in total |
|||
|
|
revolution 09 Sep 2026, 16:50
Multiplying the constant 100 can be done inside MMX.
|
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.