Assembly code snippets
Details
Title | ASCII to DWORD (2) |
---|---|
Author | The Svin |
Submitted by: | bitRAKE |
Date added: | 2002-02-27 18:07:46 |
Date modified: | 2002-02-27 18:07:46 |
Comments
This is a modified version of Svin's atodw algo - three changes were made to make it faster on newer processors, and not save registers used by windows.
Snippet
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
atodw proc FORCENOFRAME
;----------------------------------------
; Convert decimal string into dword value
; return value in eax
;----------------------------------------
; String EQU [esp+4]
mov edx, [esp+4]
xor eax, eax
cmp BYTE PTR [edx], 2Eh
sbb [esp+4], edx
adc edx, eax
jmp @F
again:
lea eax, [eax+4*eax]
inc edx
lea eax, [ecx+2*eax-30h]
@@: movzx ecx, BYTE PTR [edx]
cmp BYTE PTR [edx], 30h
jns again
add eax, [esp+4]
xor eax, [esp+4]
retn 4
atodw ENDP
OPTION PROLOGUE:DefaultOption
OPTION EPILOGUE:DefaultOption
OPTION EPILOGUE:NONE
atodw proc FORCENOFRAME
;----------------------------------------
; Convert decimal string into dword value
; return value in eax
;----------------------------------------
; String EQU [esp+4]
mov edx, [esp+4]
xor eax, eax
cmp BYTE PTR [edx], 2Eh
sbb [esp+4], edx
adc edx, eax
jmp @F
again:
lea eax, [eax+4*eax]
inc edx
lea eax, [ecx+2*eax-30h]
@@: movzx ecx, BYTE PTR [edx]
cmp BYTE PTR [edx], 30h
jns again
add eax, [esp+4]
xor eax, [esp+4]
retn 4
atodw ENDP
OPTION PROLOGUE:DefaultOption
OPTION EPILOGUE:DefaultOption