| | |
Displaying numeric data
![]() |
•
•
Join Date: Jul 2006
Posts: 16
Reputation:
Solved Threads: 0
Hi, I'm new to 80x86 Assembler...
My question is very simple one: how should i print number on screen?
I used the following code to print ascii data:
When i needed to define numeric data, i changed this to:
and used the same sequence to print as it was with the string data. But program printed out only unreadable set of ascii characters
What's wrong with my code?
Also,how i could print data stored in one of the registers?
Thank you in advance
My question is very simple one: how should i print number on screen?
I used the following code to print ascii data:
Assembly Syntax (Toggle Plain Text)
mov ah,09h ;load code of print function lea dx, Var ;load address of variable to be printed int 21h ;DOS call .......................... Var db 'SOME_DATA','$'
When i needed to define numeric data, i changed this to:
Assembly Syntax (Toggle Plain Text)
Var db 4 ; an integer to be printed
What's wrong with my code?
Also,how i could print data stored in one of the registers?
Thank you in advance
•
•
Join Date: Jun 2005
Posts: 14
Reputation:
Solved Threads: 0
Var contains data which will be evaluated as ASCII , but as 4 is in deciaml it will be evaluated as ASCII value 4 , which is a nonprintable chracter.
You need to convert 4 to ASCII "4" . To convert 4 to ASCII "4" you need to add 30(deciaml) . AS in ASCII "0" starts from 30 and "9" at 39.
You need to separate each digit and change that to ASCII ( in range 30 to 39).
that is to print 17 (decimal) you have to separate 1 and 7 and change it to 1 => 31h and 7 => 37h.
And print as
You need to convert 4 to ASCII "4" . To convert 4 to ASCII "4" you need to add 30(deciaml) . AS in ASCII "0" starts from 30 and "9" at 39.
You need to separate each digit and change that to ASCII ( in range 30 to 39).
that is to print 17 (decimal) you have to separate 1 and 7 and change it to 1 => 31h and 7 => 37h.
And print as
•
•
•
•
data db 2dup(0)
mov [data],31h
mov [data+1],37h
lea dx,data
mov ah,09h
int 21h
![]() |
Similar Threads
- Extract Numbers from Data Stream (Python)
- Help with storing data in structure (C++)
- I need help with Threshold data values (Visual Basic 4 / 5 / 6)
- WHERE field *has a numeric value?* (MS SQL)
- Dynamically displaying fields in data report!! (Visual Basic 4 / 5 / 6)
- accessing private data members (C++)
Other Threads in the Assembly Forum
- Previous Thread: hardware interrupt hangs
- Next Thread: LC3 Calculator
| Thread Tools | Search this Thread |





