944,184 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 2547
  • Assembly RSS
Jul 11th, 2006
0

Displaying numeric data

Expand Post »
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:
Assembly Syntax (Toggle Plain Text)
  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:
Assembly Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vov4ik is offline Offline
16 posts
since Jul 2006
Jul 12th, 2006
0

Re: Displaying numeric data

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
Quote ...
data db 2dup(0)

mov [data],31h
mov [data+1],37h
lea dx,data
mov ah,09h
int 21h
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thandermax is offline Offline
14 posts
since Jun 2005
Jul 12th, 2006
0

Re: Displaying numeric data

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thandermax is offline Offline
14 posts
since Jun 2005
Jul 13th, 2006
0

Re: Displaying numeric data

Thank thandermax for your reply... i think i got idea...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vov4ik is offline Offline
16 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: hardware interrupt hangs
Next Thread in Assembly Forum Timeline: LC3 Calculator





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC