Printing out a number in assembly language?

Kristina Brooks picture Kristina Brooks · Dec 17, 2009 · Viewed 166k times · Source
mov al,10
add al,15

How do I print the value of 'al'?

Answer

mrkj picture mrkj · Dec 17, 2009

Have you tried int 21h service 2? DL is the character to print.

mov dl,'A' ; print 'A'
mov ah,2
int 21h

To print the integer value, you'll have to write a loop to decompose the integer to individual characters. If you're okay with printing the value in hex, this is pretty trivial.

If you can't rely on DOS services, you might also be able to use the BIOS int 10h with AL set to 0Eh or 0Ah.