Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help!!

Status
Not open for further replies.

davidsnave

Programmer
Jan 27, 2003
1
0
0
US
I'm finishing up an electronics course at a technical colllege. This is my last quarter (thank god).

I'm taking microprocessors right now. I need to alter an assembly language program to get it to print a sentence.
Seems simple enough but I am pulling my hair out.

This is the program:

MOV AH,9
MOV DX, OFFSET(MSG)
INT 21H
INT 20H
MSG DB 'Hey this is fun...and it works!','$'

This program simply prints the sentence to the screen. I need it to print that same sentence with the printer.

I know the 17H interupt is used for this but I'm lost as to how exactly. I know I shouldn't have add too much to the code.

Is there a way I could use the sub-function AH, 05H? I tried this with different variations but no luck.

I'm not sure why we have this asignment when we were not taught this language, but there ain't much I can do about that.

If anyone can help me I swear I'll remember you when I get rich.

Thanks

 
comments: (assuming this all applies to DOS, which it looks like)

Subfunction ah=5 of int021h is listed in my little reference book as print a character. The ascii code of the character should be in dl, and it prints a single character.

Int 017h is also supposed to print things. Like Int 021h it has subfunctions. Subfunction ah=1 is initialise printer port (port No. in dx, 0=LPT1 etc).
Int 017h ah=0 is write character, printer No. in dx, character in al. It returns the printer status in ah, bit0=timeout, bit3=i/o error etc...

Since all these routines are print a character rather than print a $-terminated string, you are going to have to read the string character by character in a loop and call the interrupt as many times as you need... I'm not sure if DOS provides a string print thingy.

I've never got deeply into printing things, so I might be telling you rubbish...

Int 020h as program termination has been considered obsolete since DOS version 2.0!!! Int 021h ah=04Ch is more up to date, but I don't know the pros and cons of each approach. Maybe you should ask whoever runs the course (if they're using int 020h simply because that was what got written into the course notes a long time ago, then that's not a good reason)
 
another option can be opening device PRN as a file and writing the string to it
 
msg db 'Hey this is fun...and it works!',10,13,'$'

mov dx,offset msg
mov ah,9
int 21h
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top