Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- .model flat,stdcall
- option casemap:none
- include masm32includewindows.inc
- include masm32includeuser32.inc
- includelib masm32libuser32.lib
- include masm32includekernel32.inc
- includelib masm32libkernel32.lib
- include masm32includemasm32.inc
- includelib masm32libmasm32.lib
- .data
- textNum dd "c",0 ;variable i use to display every single digit (initialized with a casual character)
- num dd 25678 ;number to print
- divisor dd 10
- .code
- start:
- mov eax, num
- xor ecx,ecx ;ecx is the digits counter
- lea esi, textNum ;mov in esi the adress of textNum
- ciclo:
- cmp eax,0 ;when the dividend is 0 exit
- jbe print
- xor edx,edx ;reset edx to take the remainder
- div divisor
- push edx ;push the remainder
- add cl,1 ;increase digits counter
- jmp ciclo
- print:
- cmp cl,0 ;since the counter is greater than 0
- jbe return
- xor eax,eax
- pop eax ;pop in eax the digit i want to print
- add eax,48 ;add 48 (ascii value)
- mov [esi], eax ;move the digit inside the variable
- invoke StdOut, addr textNum ;print the variable
- sub cl, 1 ;dec counter
- jmp print
- return:
- invoke ExitProcess, 0
- end start
- ;textNum dd "c",0 ;variable i use to display every single digit (initialized with a casual character)
- textNum dd 2 dup(0)
Add Comment
Please, Sign In to add comment