HtoD2 - mov esi, edi .while (eax > 0) mov ebx,eax mul...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
.386 .model flat,stdcall option casemap:none o include \masm32\include\ include \masm32\include\ include \masm32\include\ i includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib i dwtoa proto dwValue:DWORD, lpBuffer:DWORD d .data? szOut db 256 dup(?) .data str1 db "10",0 str2 db "5",0 .code start: push offset str1 call ustr2dw push eax push offset str2 call ustr2dw pop ecx add eax, ecx push offset szOut push eax call dwtoa push MB_OK push offset szOut push offset szOut push NULL call MessageBox push NULL call ExitProcess dwtoa proc dwValue:DWORD, lpBuffer:DWORD d push ebx push esi push edi mov eax, dwValue mov edi, [lpBuffer] test eax,eax jnz sign zero: mov word ptr [edi],30h jmp dtaexit sign: jns pos mov byte ptr [edi],'-' neg eax add edi, 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
pos: mov ecx, 3435973837
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: mov esi, edi .while (eax > 0) mov ebx,eax mul ecx shr edx, 3 mov eax,edx lea edx,[edx*4+edx] add edx,edx sub ebx,edx add bl,'0' mov [edi],bl add edi, 1 .endw mov byte ptr [edi], 0 ; terminate the string ; We now have all the digits, but in reverse order. .while (esi < edi) sub edi, 1 mov al, [esi] mov ah, [edi] mov [edi], al mov [esi], ah add esi, 1 .endw dtaexit: pop edi pop esi pop ebx ret dwtoa endp d ustr2dw proc pszString:DWORD u push esi mov esi, [pszString] xor eax, eax xor edx, edx jmp @@chkz @@redo: sub dl, "0" mov ecx, eax add eax, eax shl ecx, 3 inc esi add eax, ecx add eax, edx @@chkz: mov dl, [esi] test dl, dl jnz @@redo pop esi ret ustr2dw endp u end start...
View Full Document

This note was uploaded on 11/15/2010 for the course ECE 265 taught by Professor N /a during the Spring '08 term at Ohio State.

Page1 / 3

HtoD2 - mov esi, edi .while (eax > 0) mov ebx,eax mul...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online