flat assembler
Message board for the users of flat assembler.

Index > Main > MMX convert text to byte value.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 2129
Roman 08 Sep 2026, 16:38
I write code but its big code. I want three or 4 asm commands.
Code:
txtV db '16' ; i have many numbers
intV db 0

tt2 db 48,48,48,48
tt3 db 10,0,0,0 

;do some mmx operations and get intV=16

movd mm0,dword [txtV]
psubb mm0,qword [tt2]
movd ecx,mm0
pmullw mm0,qword[tt3]
movd eax,mm0
add al,ch 
mov [intV],al ;intV=16

    
Post 08 Sep 2026, 16:38
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2129
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
    
Post 08 Sep 2026, 18:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 21091
Location: In your JS exploiting you and your system
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 ?    
There ia also aad designed exactly for this task.
Post 08 Sep 2026, 18:30
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2129
Roman 08 Sep 2026, 18:50
Quote:

mov ax,word[bcd]
sub ax,'00'
imul ax,0x10a
mov [result],ah

Wrong result.
Post 08 Sep 2026, 18:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 21091
Location: In your JS exploiting you and your system
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 ?    
Post 08 Sep 2026, 18:53
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2129
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
    
Post 08 Sep 2026, 19:12
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.