Está en la página 1de 16

m  



m 
m 




INTERRUPT
u Interrupts are used for multiple purposes on the
PC system architecture.
u Interrupts force the processor to stop its normal
execution path and, temporarily execute another
path. Once the interrupt path is completed,
execution returns to the normal path that was
interrupted.
x There are three types of interrupts.
¦  !
÷ External interrupts.
3 Internal interrupts.
"# $ %
  ! !& 
'(¦"' m   !
'("'   !
)'(*"' !+,
-'("' m
"¦'(""' !,
0ENERAL HARDWARE DESI0N
u The CPU and memory sections appear much the same
to software, as long as the CPU supports the program
instructions and enough memory exists the program
can be executed.
u The Input/Output section connects the computer to
the outside world and must operate with a wide
variety of computer interfacing hardware (mice, touch
pads, NIC, video, sounds, virtual reality headsets,
gloves, etc. many not conceived when the computer
rolled of the production line.
u Software must be adaptable to changes in the
hardware attached to the system. On the PC
architecture, these hardware differences are handled
primarily by the BIOS (Basic Input/Output System
abstraction.
INT 17H (BIOS PRINTER CONTROL
u Instruction: int 17h
u BIOS Operation: Print data and test the printer
status
u Parameters: ax,dx

u Int 17h provides three subfunctions specified by


the value in the ah register.

1 unction 0: writes character to the printer


÷ unction 1: initializes a printer port
3 unction ÷: gets printer status
u The printer port services allow you to specify
which of the three printers installed in the
system you wish to use (LPT1: LPT÷: or LPT3: .
The value in the dx register (0..÷ specifies which
printer port is to be used.
 ¦*./
 ( #   
u AH = 00h
u AL = character to write
u DX = printer number (00h-0÷h
u  AH = printer status
u ›ost printers respect the printable ASCII character
set and a few control characters. ›any printers will
also print all the symbols in the IB›/ASCII character
set.
u ›ost printers treat control characters (especially
ESC sequences in completely different manners.
Therefore if you intend to print something other than
standard ASCII characters be forewarned that your
software may not work on printers other than the
brand you're developing your software on.
¦*./¦
 (   
0
u AH = 01h
u DX = printer number (00h-0÷h

u  AH = printer status

u Executing this call sends an electrical impulse to


the printer telling it to initialize itself. On return
the ah register contains the printer status as per
function number two.
¦*./
 ( 1$
u AH = 0÷h
u DX = printer number (00h-0÷h

u  AH = printer status

u This function call checks the printer status and


returns it in the ah register.
PRINTER STATUS IN AH
AH: Bit ›eaning
u7 1=Printer busy
0=printer not busy
u6 1=Acknowledge from printer
u5 1=Out of paper signal
u4 1=Printer selected
u3 1=I/O error
u÷ Not used
u1 Not used
u0 Time out error
u Note that certain peripheral devices (other than
printers also interface to the parallel port often
in addition to a parallel printer.
u Some of these devices use the error/status signal
lines to return data to the PC.
u The software controlling such devices often takes
over the int 17h and always returns a "no error"
status or "time out error" status if an error occurs
on the printing device.
u Therefore you should take care not to depend too
heavily on these signals changing when you
make the int 17h BIOS calls.
SOTWARE ›ODULE
.model small
.stack 100h
; Printer ID numbers:
LPT1 = 0
LPT÷ = 1
LPT3 = ÷
; Printer status bit masks:
timeout = 1b
IOerror = 1000b
printerSelected = 10000b
outOfPaper = 00100000b
acknowledge = 01000000b
notBusy = 10000000b
.data
status BYTE 1 dup (? ; printer status byte
error›essage BYTE "Printer I/O erroroccurred"
outputString BYTE "Send this string to the printerµ
STRIN0 SIZE = ($ - outputString

.code
extrn WriteString:proc
main PROC
mov ax,@data
mov ds,ax ;
mov ah,1 ; initialize printer port
mov dx,LPT1 ; printer ID
int 17h ; call BIOS
mov status,ah ; returns the status
test status,notBusy
jz quit ; ;printer is busy
; Write a string to the printer:
mov si,OSET outputString
mov cx,STRIN0 SIZE
L1: mov ah,0 ; write character to printer
mov al,[si] ; character to be written
mov dx,LPT1 ; printer ID
int 17h ; call BIOS
mov ah,÷ ; get printer status
mov dx,LPT1 ; printer ID
int 17h ; call BIOS
test status,Ioerror ; I/O error?
jnz L÷ ; yes: show error
inc si ; next character
loop L1 ; no: loop again
jmp quit
L÷: mov dx,OSET error›essage
call WriteString
quit: .exit
main ENDP
END main