;///////asci to integer proc aka atoi() ;///////Coded by fakedminded/berniee (2008) ;///////ass-koder.de.vu ||fakedminded.wordpress.com ;///////Details: This manage to get char (decimal) into integer through several loops! ;/////// NOT OPTIMIZED! ;|---------___________________________________________----------------| ;| | ;| assembeler atoi() | ;| | ;|--------___________________________________________-----------------| .586 .model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib .data string1 db "5567112",0 .code atoi: mov ebp,esp push esi invoke lstrlen,esi pop esi mov ecx,eax add esi,eax xor edx,edx xor eax,eax dec esi @@: push ecx ;loop counter push edx ;digit counter push eax ;result--addition call seek_order xor eax,eax mov al,byte ptr[esi] sub al,30h cmp al,0 jb err xor edx,edx mul ecx xchg ecx,eax pop eax add eax,ecx pop edx pop ecx inc edx dec esi loop @b mov esp,ebp ret err: xor eax,eax dec eax mov esp,ebp ret seek_order: or edx,edx jz exit_sk mov ecx,edx mov edx,1 @@: push ecx push edx xor ecx,ecx mov ecx,edx xor edx,edx mov eax,10 mul ecx pop edx mov edx,eax pop ecx loop @b xchg ecx,eax ret exit_sk: xor ecx,ecx inc ecx ret start: mov esi,offset string1 call atoi invoke ExitProcess,0 end start