To print using int 0x80
and code 4
you need ECX
to be the address of the byte to print. You added '0'
to the address of num
that was in ECX
before you called the print
routine, so it was the address of something else out in memory somewhere.
You may want something like this. I created a separate area, numout
to hold the ASCII version of num
:
numout resb 1
....
mov EAX,4
mov EBX,0
mov CL,[num]
add CL,'0'
mov [numout],CL
mov ECX,numout
mov EDX,1
int 0x80