Author Topic: ascii adder  (Read 19208 times)

TWell

  • Member
  • ****
  • Posts: 748
Re: ascii adder
« Reply #60 on: September 27, 2015, 08:35:19 PM »
AMD E450
Code: [Select]
newstyle --- *
6770
6780
6806
6771
6769
original old style
5607
5678
5683
5669
5706

zedd151

  • Member
  • ****
  • Posts: 871
Re: ascii adder
« Reply #61 on: October 07, 2015, 06:45:57 AM »
Project aborted.  ::)

Too many inconsistencies involving certain lengths.
I'm not always the sharpest knife in the drawer, but I have my moments.  :P

rrr314159

  • Member
  • *****
  • Posts: 1382
Re: ascii adder
« Reply #62 on: October 07, 2015, 08:50:17 AM »
Heck that's too bad. Well if you get bored tackle the more-standard way to do it, as dedndave said, convert to binary first, etc. That's a lot of work but, in a way, more straightforward
I am NaN ;)

zedd151

  • Member
  • ****
  • Posts: 871
Success!
« Reply #63 on: July 26, 2018, 09:12:31 AM »
Based on some of jimg's ideas, I now have a working ascii adder procedure, and it so far seems very accurate.
 
Code: [Select]
        ascii_adder proc src1:dword, src2:dword, dst:dword, lent:dword
        local carrie:dword
            push esi
            push edi
            push ebx
            mov esi, src1
            mov edi, src2
            mov ebx, dst
            mov ecx, lent
            mov carrie, 0
            top:
                mov eax,0
                mov al,byte ptr [esi+ecx-1]
                mov dl,byte ptr [edi+ecx-1]
                add al,dl
                sub al, 30h
                add eax, carrie
                mov carrie, 0
                cmp al, 39h
               
                jbe @f
                    mov carrie, 1
                    sub al, 10
                @@:
               
                mov [ebx+ecx-1], al
                dec ecx
                cmp ecx, 0
            jnz top
            pop ebx
            pop edi
            pop esi
            ret
        ascii_adder endp


Jim posted a routine in felipes' fibonacci thread, and it reminded me of this project.
So, I stripped out the essential parts and put them into their own procedure. Works well
for generating a fibonacci sequence.
I'm not always the sharpest knife in the drawer, but I have my moments.  :P