this code was written by me for my projects. all it does is increments by 1 the string which is passed to the function.
if you have any improvements to my code ill be glad to hear from you ;)
increment an ascii string by 1
szinc proc strin : DWORD
xor ecx, ecx
mov eax, -1
mov ebx, strin
@@:
inc eax
cmp byte ptr[ebx + eax], 0h
je lblret
cmp byte ptr[ebx + eax], 39h
jnz lbl1
inc ecx
jmp @B
lbl1:
xor ecx, ecx
jmp @B
lblret:
or eax, eax
jz lblret2
or ecx, ecx
jnz lbl3
inc byte ptr[(ebx + eax)-1]
ret
lbl3:
cmp ecx, eax
jne lbl2
mov byte ptr[ebx], '1'
inc eax
jmp @F
lbl2:
lea edx, [ebx + eax]
sub edx, ecx
inc byte ptr[edx - 1]
@@:
lea edx, [ebx + eax]
sub edx, ecx
mov byte ptr[edx], '0'
dec ecx
jnz @B
mov byte ptr[ebx + eax], 0h
lblret2:
ret
szinc endp
low_coder 26 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.