Jump to content
Tuts 4 You

Printing int in assembly


dreambig2212

Recommended Posts

dreambig2212

Hi,

I am new to assembly and want to know how to print integers in assembly on stdout. As printing string is straight forward. But i am not able to find how to put integers on stdout.

I am using as and ld in linux to compile my program and run. I am not using HLA or MASM etc.

Thanks.

Link to comment

He's not, stdout is the universal terminology for standard output.

As for dreambig2212; you'll have to print each digit individually by converting them to a printable ascii character. For example, the hexadecimal value of the printable ascii character '1' is 31h. If your dl register contains a digit you'd like to print, adding 30h to it will make it a printable ascii character.

add dl, 30h

To print larger numbers you'll have to write a routine to seperate the integer into printable digits.

Link to comment
dreambig2212

He's not, stdout is the universal terminology for standard output.

As for dreambig2212; you'll have to print each digit individually by converting them to a printable ascii character. For example, the hexadecimal value of the printable ascii character '1' is 31h. If your dl register contains a digit you'd like to print, adding 30h to it will make it a printable ascii character.

add dl, 30h

To print larger numbers you'll have to write a routine to seperate the integer into printable digits.

Thanks Gushe. You are correct I am asking for the same. I will do as you suggested.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...