Write an installable DOS device driver for printers.
; TITLE : WRITE AN INSTALLABLE DOS DEVICE DRIVER FOR PRINTER
.model small
.code
org 00h
device_header:
link dd -1 ;end of device driver
attr dw 08000h ;char device driver printer
strat dw strgy ;define strategy(data structure)
intr dw intpt ;interrupt routine entry point
logicalname db 'PRINTF ' ;logical device name
;end of device header
;request header
req_header_off dw ?
req_header_seg dw ?
msg db 10,13, 'PRINTER DRIVER INSTALLED$'
strgy proc far ; procedure for strategy routine
mov cs:req_header_off,bx ; get address from es:bx
mov cs:req_header_seg,es
retf ;used to return from system function
endp
;*******************************************************
intpt proc far ; procedure for interrupt routine
pushf
push ax ; push all the contents on to the stack
push bx
push cx
push dx
push ds
push es
push ss
push si
push di
push sp
push bp
mov bx,cs:req_header_off ; restore the address of systems device drivers
mov es,cs:req_header_seg
mov al,es:[bx+2] ; get command word in al
cmp al,00h ; if 00 then need to initialize the printer
jne next ; else already installed
call init ; call initialization procedure
next: cmp al,08h ; if equal printer ready to write
jne next1
call write ; call write procedure
next1: mov ax,0100h
mov es:[bx+3],ax
pop bp
pop sp
pop di ; pop all the contents
pop si ; in proper order
pop ss
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
popf
retf ; return from system function
intpt endp
;*******************************************************
write proc near ; procedure for printing the contents
mov cx,es:[bx+18]
mov si,es:[bx+14]
mov ds,es:[bx+16]
again: mov ah,00h ; function for writing character to printer
mov al,ds:[si] ; character to be printed
mov dx,00h ; printer number (LPT1=0, LPT2=1....)
int 17h
inc si ; points to next character
loop again ; loop untill value in cx register
ret
write endp ; end of write procedure
;*******************************************************
init proc near ; procedure for initialization of printer
lea dx,cs:msg ; print message
mov ah,09h
int 21h
mov ah,01h ; function for printer port initialization
mov dx,00h ; printer name (LPT1=0)
int 17h
lea ax,init
mov es:[bx+14],ax
push cs
pop ax
mov es:[bx+16],ax
ret
init endp
end
; output
;Microsoft Windows XP [Version 5.1.2600]
;(C) Copyright 1985-2001 Microsoft Corp.
;C:\Documents and Settings\mmcoe>cd\
;C:\>cd tasm
;C:\tasm>tasm printer.asm
;Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland International
;Assembling file: printer.asm
;Error messages: None
;Warning messages: None
;Passes: 1
;Remaining memory: 476k
;C:\tasm>tlink printer.obj
;Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
;Warning: No stack
;C:\tasm>exe2bin printer.exe printer.com
;C:\tasm>
0 comments:
Post a Comment