Displaying numeric data

Reply

Join Date: Jul 2006
Posts: 16
Reputation: vov4ik is an unknown quantity at this point 
Solved Threads: 0
vov4ik vov4ik is offline Offline
Newbie Poster

Displaying numeric data

 
0
  #1
Jul 11th, 2006
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:
  1. mov ah,09h ;load code of print function
  2. lea dx, Var ;load address of variable to be printed
  3. int 21h ;DOS call
  4.  
  5. ..........................
  6. Var db 'SOME_DATA','$'

When i needed to define numeric data, i changed this to:
  1. Var db 4 ; an integer to be printed
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 14
Reputation: thandermax is an unknown quantity at this point 
Solved Threads: 0
thandermax thandermax is offline Offline
Newbie Poster

Re: Displaying numeric data

 
0
  #2
Jul 12th, 2006
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
data db 2dup(0)

mov [data],31h
mov [data+1],37h
lea dx,data
mov ah,09h
int 21h
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 14
Reputation: thandermax is an unknown quantity at this point 
Solved Threads: 0
thandermax thandermax is offline Offline
Newbie Poster

Re: Displaying numeric data

 
0
  #3
Jul 12th, 2006
Separation code you need to develop .

It's easy, just mask the upper nibble(4 bit) and get lower nibble .
mask the lower nibble and shift 4 times to left and get the upper nibble.


AND the data with 0fh to mask upper nibble, and with f0h to mask lower nibble.


Hope you got the idea
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 16
Reputation: vov4ik is an unknown quantity at this point 
Solved Threads: 0
vov4ik vov4ik is offline Offline
Newbie Poster

Re: Displaying numeric data

 
0
  #4
Jul 13th, 2006
Thank thandermax for your reply... i think i got idea...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC