ho riscritto il codice e l'ho verificato...
codice:
; Prototipo: int atoi ( char* numericValue );
; Descrizione: converte una stringa numerica decimale in un intero con segno
; Valori accettati: ^\s*(+|-|)[0-9]*
; Esempi validi: +8532, -731, 32642, 000423, 40gatti, -600nonne
;
; Attenzione: controllo overflow non implementato
atoi:
push esi
mov esi, dword ptr ss:[esp+8]
xor eax, eax
xor ecx, ecx
xor edx, edx
cld
_lTrimString:
lodsb
cmp al, ' '
je _lTrimString
cmp al, ' '
je _lTrimString
cmp al, '-'
jne _notNegative
or ecx, 1
jmp _getNextDigit
_notNegative:
cmp al, '+'
je _getNextDigit
_parseNextDigit:
sub al, '0'
cmp al, 9
ja _gotNumber
push eax
mov eax, edx
shl edx, 3
add edx, eax
add edx, eax
pop eax
add edx, eax
_getNextDigit:
lodsb
jmp _parseNextDigit
_gotNumber:
test ecx, 1
jz _dontAdjust
neg edx
_dontAdjust:
mov eax, edx
pop esi
retn 4
se ti puo' servire...