flat assembler
Message board for the users of flat assembler.

Index > Windows > Apply ascii text numbers without converting to int.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 17 Oct 2023, 11:52
I want add three ascii numbers.
547+44+325

And I not want converting all this numbers to integer then converting result to ascii
Post 17 Oct 2023, 11:52
View user's profile Send private message Reply with quote
FlierMate7



Joined: 06 Sep 2023
Posts: 12
FlierMate7 17 Oct 2023, 12:17
What a co-incidence, I am about to ask exactly the same question, is there any conversion routine? I don't care if it is inefficient, as last time I end up searching optimized bin_to_int routine (no loops) which is very difficult to understand.
Post 17 Oct 2023, 12:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20205
Location: In your JS exploiting you and your system
revolution 17 Oct 2023, 12:23
x86 has two instructions for this. AAA and AAS
Post 17 Oct 2023, 12:23
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2467
Furs 17 Oct 2023, 12:54
You're gonna have to code them manually like you would do additions by hand (like in school if you still remember). Wink
Post 17 Oct 2023, 12:54
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 17 Oct 2023, 13:26
mov ax,0005h
add ax,0006h ;AX=000Bh
aaa ;AX=0101h

Only 32 bit, not for 64 bit and apply short numbers only two symbols
Post 17 Oct 2023, 13:26
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 17 Oct 2023, 15:12
How remove AAA on flag carry?

Code:
T1 db "4733"
T2 db "7477"

Mov eax, dword [T1] 
And eax, 0x0f0f0f0f
Mov ebx, dword [T2] 
And ebx, 0x0f0f0f0f
Add eax, ebx

;shr eax to flag carry
    
Post 17 Oct 2023, 15:12
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 17 Oct 2023, 15:37
Code:
txt22 db '4322','7829'
        hah   db 32 dup(48),0,0 

mov  ebx,txt22
         mov  esi,hah
         mov  ecx,3
.2:      mov al,[ebx+ecx]
         sub al,48
         mov dl,[ebx+ecx+4]
         sub dl,48
         add al,dl
         mov ah,[esi]
         sub ah,48
         aaa
         add ax,0x3030
         mov [esi],ah
         mov [esi+1],al
         inc esi
         ;cmp ah,48
         ;jz  .3
         ;inc esi
.3:

         dec ecx
         cmp ecx,-1
         jnz .2  
    

i get: 12511 must be 12151
Post 17 Oct 2023, 15:37
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3971
Location: vpcmipstrm
bitRAKE 17 Oct 2023, 22:10
Raymond Filiatreault has a number (pun intended) of resources - in this instance the BCD intro is quite useful. There is example code and explanations for each of the instructions.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 17 Oct 2023, 22:10
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 18 Oct 2023, 00:00
in x86, decimal operations are made with very basic instructions all named with opcodes starting with A.
A cause it's ascii, but it is decimal.

then, since the first 8086 you have what you want
Post 18 Oct 2023, 00:00
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.