Okay a fresh new look at this little program.
I removed ebp as a general purpose register. Also using StrLen, to obtain of course the length of the strings.
include \masm32\include\masm32rt.inc
asciiadder PROTO :DWORD, :DWORD, :DWORD
.data
ss1 db "1", 0
ss2 db "99999999999999999999999999999999999", 0
dd1 db 40h dup (0)
.code
start:
invoke asciiadder, addr ss2, addr ss1, addr dd1
invoke MessageBoxA, 0, addr dd1, 0, 0
invoke ExitProcess, 0
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
asciiadder proc src1:dword, src2:dword, dst:dword
push ebx
push esi
push edi
mov esi, [esp+10h]
mov ebx, [esp+14h]
mov edi, [esp+18h]
invoke StrLen, esi
dec eax
push eax
invoke StrLen, ebx
dec eax
mov edx, eax
pop ecx
cmp ecx, edx
jl edxgr
add edi, ecx
jmp setdst
edxgr:
add edi, edx
setdst:
inc edi
; ---------------------- main loop
calc:
mov al, 0
cmp ecx, -1
js @f
mov al, byte ptr [esi+ecx]
@@:
cmp edx, -1
js @f
add al, byte ptr [ebx+edx]
@@:
sub al, 30h
cmp al, 0Ah
jl @f
sub al, 30h
@@:
cmp al, 0Ah
jl @f
sub al, 0Ah
inc byte ptr [edi-1]
@@:
add al, 30h
add al, byte ptr [edi]
cmp al, 39h
jng @f
sub al, 0Ah
inc byte ptr [edi-1]
@@:
mov byte ptr [edi], al
dec edi
dec edx
dec ecx
cmp edi, [esp+18h]
ja calc
; ---------------------- end main loop
cmp byte ptr [edi], 30h
jg @f
add byte ptr [edi], 30h
@@:
pop edi
pop esi
pop ebx
ret 12
asciiadder endp
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
end start
Now I will once again concentrate on optimizing the main loop. Or at least try to minimize the number of jumps in this thing.