Finally managed to create "my own" routine to convert the number and print.
Although the logic is the same for everyone.
Get the number, divide by 10, get the Reminder, add 30h (or 48) to the character (ascii code for the number), save it, print it later.
Used stack to save the numbers, saved them later onto a variable and printed.
Not much i know, but I'm still a nab at this.
Code:
.386
.model flat, stdcall
option casemap:none
include E:\masm32\include\windows.inc
include E:\masm32\include\kernel32.inc
include E:\masm32\include\masm32.inc
include E:\masm32\include\user32.inc
includelib E:\masm32\lib\user32.lib
includelib E:\masm32\lib\kernel32.lib
includelib E:\masm32\lib\masm32.lib
.data
messageStr dd 1337,0
hStd dd ?
bytesOut dd ?
number db ?
.code
START:
;OUTPUT
push -11
call GetStdHandle
MOV hStd, EAX
MOV ECX, 10
MOV EAX, messageStr
MOV EBX, 0
convertNum:
MOV EDX, 0
DIV ECX
CMP EDX, 0
JE convertEnd
push EDX
INC EBX
JMP convertNum
convertEnd:
;This will now have the number on the stack (1,3,3,7,...)
;EBX will have the number lengh
MOV ECX, EBX
MOV EDX, offset number
saveNumber:
POP EAX ;recover one number from the stack to EAX and then save it
ADD EAX, 48 ;To convert it into the correct ASCII code
MOV BYTE PTR [EDX], AL ;Save the number to the byte pointed by EDX
INC EDX ;Next byte to save the next number
DEC EBX ;Counter--
CMP EBX, 0
JNE saveNumber
saveEnd:
push 0
push offset bytesOut
push ECX
push offset number
push hStd
call WriteConsole
push 0
call ExitProcess
END START