0
  • My program reads data from a file,counts the number of words and correctly increments a counter variable.

How can I print this counter variable which contains a decimal number.Which would be the best way.

This is the code:

      mov dx,offset counter
      mov ah,09h
      int 21h
Lind
  • 233
  • 1
  • 5
  • 14
  • Can you be more clear? When you say `counter` contains a decimal number do you mean a string representation of a decimal number, terminating in `$`? That's what that interrupt wants. What exactly is in `counter`? – lurker Jan 19 '14 at 19:37
  • in the counter there is a decimal number.example 10 – Lind Jan 20 '14 at 19:55

1 Answers1

0
or counter,30h   

and close the string seems to be working fine

Lind
  • 233
  • 1
  • 5
  • 14
  • That will work if `counter` is less than 10 (decimal). – lurker Jan 19 '14 at 19:38
  • so you are saying if the counter is 11 it doesn't work.I will test it tomorrow ... – Lind Jan 20 '14 at 19:56
  • 1
    That is correct. If the counter is `11` (decimal) which is `Bh` then adding `30h` gives `3Bh` which is equivalent to `;`. So that's what you'll see. To display a bigger number, you need to divide/mod each decimal digit out and add `30h` to each decimal digit to make an ASCII digit. Form an array of those ending in `$`, then call your soft interrupt to print the string. – lurker Jan 20 '14 at 20:04