        name    driver
        page    55,132
        title   'DRIVER --- installable driver template'

;
; This is a "template" for a MS-DOS installable device driver.
; The actual driver subroutines are stubs only and have
; no effect but to return a non-error "done" status.
; 
; Ray Duncan
; Laboratory Microsystems Inc.
; April 1985

code    segment public 'CODE'

driver  proc    far

        assume  cs:code,ds:code,es:code

        org     0


Max_Cmd equ     15              ; MS-DOS command code maximum
                                ; this is 15 for MS-DOS 3.x
                                ; and 12 for MS-DOS 2.x 


cr      equ     0dh             ; ASCII carriage return
lf      equ     0ah             ; ASCII line feed


;
; Device Driver Header
;
Header  dd      -1              ;link to next device,-1= end of list

        dw      8000h           ;attribute word
                                ;bit 15=1 for character devices

        dw      Strat           ;device "Strategy" entry point

        dw      Intr            ;device "Interrupt" entry point

        db      'DENEME  '      ;char device name, 8 char, or
                                ;if block device, no. of units
                                ;in first byte followed by 
                                ;7 don't care bytes     



; Interpretation of Attribute word:
; 
; Bit           Significance
;
; 15            =1 for character drivers
; 14            =1 if driver can handle IOCTL
; 13            =1 if block device & non-IBM format
; 12            0
; 11            open/close/RM supported (DOS 3.x)
; 10            0
;  9            0
;  8            0
;  7            0
;  6            0
;  5            0
;  4            0
;  3            =1 if CLOCK device
;  2            =1 if NUL device
;  1            =1 if Standard Output
;  0            =1 if Standard Input


;
; local variables for use by driver
;
RH_Ptr  dd      ?               ; pointer to request header
                                ; passed to Strat by BDOS

Ident   db      cr,lf,lf
        db      'Device Driver Draft'
        db      cr,lf
        db      'by Erdogan Tan '
        db      cr,lf,lf, 0

Strat   proc    far     
                                ; save address of Request Header
        mov     word ptr cs:[RH_Ptr],bx
        mov     word ptr cs:[RH_Ptr+2],es

        ret                     ; back to BDOS

Strat   endp


; Device Driver "Interrupt Routine"

; This entry point is called by the BDOS immediately after 
; the call to the "Strategy Routine", which saved the long
; address of the Request Header in the local variable "RH_Ptr".

; The "Interrupt Routine" uses the Command Code passed in
; the Request Header to transfer to the appropriate device
; handling routine.  Each command code routine is responsible
; for any necessary return information into the Request Header,
; then transfers to Error or Exit to set the Return Status code.

Intr    proc  far
          
        push ds

        push cs
        pop ds  

        mov si, offset Ident
        mov BX, 07h
loc_print:
	lodsb                           ; Load byte at DS:SI to AL
	and     AL,AL            
	jz      short loc_return        ; If AL = 00h then return
	mov     AH,0Eh                  
	int     10h                     ; BIOS Service func ( ah ) = 0Eh
					; Write char as TTY
					;AL-char BH-page BL-color
	jmp     short loc_print           
loc_return:
        pop ds  
	ret

Intr    endp

Driver  endp

code    ends
        
        end
