Jump to content
Tuts 4 You

Printing int in assembly


dreambig2212

Recommended Posts

dreambig2212
Posted

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.

cyb3rl0rd1867
Posted

I don't program on Linux but I think you're confusing C and assembly.

Posted

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.

dreambig2212
Posted

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.

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...