OpenVINOTM,给你看得见的未来!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » DOS 求助DOS编写驱动程序的问题

共2条 1/1 1 跳转至

DOS 求助DOS编写驱动程序的问题

院士
2006-12-22 22:43:00    评分
DOS 求助DOS编写驱动程序的问题



关键词: 求助     编写     驱动程序     问题    

院士
2006-12-22 22:43:00    评分
2楼
问 最近需要编写一个DOS的驱动程序,在看“DOS程序员参考手册”,里面有一个驱动程序的例子,程序如下,但是开机后显示完“Sample Device Driver..Version”,系统就没有反应了,不能返回DOS提示符了,这里有人做过dos驱动的朋友吗,能不能帮我解决这个问题。
; drvr.asm

CR EQU 0Dh                 
LF EQU 0Ah
MAXCMD EQU 16
ERROR EQU 8000h
BUSY EQU 0200h
DONE EQU 0100h
UNKNOWN EQU 8003h
            cseg segment public 'code'   
org 0
assume cs : cseg , ds : cseg , es : cseg
; ============================================================
drvr proc far
dD -1
dw 8000h
dw strategy
dw interrupt
db 'Driver01'
; =========================================================
rh_seg dw ?
rh_off dw ?
strategy :
mov cs : rh_seg , es
mov cs : rh_off , bx
ret
; ========================================================
; dispatch table
; ===============================================================
d_tbl:
dw s_init ; Initialization
dw s_mchk ;Media Check
dw s_bpb ;BIOS parameter block
dw s_ird ; IOCTL read
dw s_read ; Read
dw s_nrd ; Nondestructive read
dw s_inst ;Current input status
dw s_infl ;Flush input buffer
dw s_write ;Write
dw s_vwrite ;Write with verify
dw s_ostat ;Current output status
dw s_oflush ;Flush output buffers
dw s_iwrt ; IOCTL write
dw s_open ; open
dw s_close ; Close
dw s_media ; Removable media
dw s_busy;output until busy
; ==============================================================
; interrupt routine
; ==============================================================
interrupt proc far
cld
push es
push ds
push ax
push bx
push cx
push dx
push si
push di
push bp
mov dx,cs: rh_seg
mov es , dx
mov bx,cs: rh_off
mov al,es:[bx]+2
xor ah,ah
cmp ax,MAXCMD
jle ok
mov ax,UNKNOWN
jmp finish
ok:
shl aX,1
mov bx,ax
jmp word ptr[bx+d_tbl]
finish:
mov dx,cs:rh_seg
mov es,dx
mov bx,cs:rh_off
or ax,DONE
mov es:[bx]+3,ax
pop bp
pop di
pop Si
pop dx
pop cx
pop bx
pop ax
pop ds
pop es
iret ;Back to DOS
interrupt endp
;======================================================================================================
; main body of driver
;======================================================================================================
s_mchk: ;Media check
s_bpb: ;BIOS parameter block
S_ird: ;IOCTL read
S_read: ;Read
s_nrd: ;Nondestructive read
s_inst: ;Current input status
s_infl: ;Flush input buffers
S_vwrite: ;Current output status
S_ostat:  ;Current Output Status
s_oflush: ;Flush output buffers
S_iwrt: ;IOCTL write
s_open: ;open
s_close:;Close
s_media:;Removable media
s_busy: ;output until busy
MOV AX, UNKNOWN ;Set error bits
jmp finish
ident:
db CR,LF
db 'Sample Device Driver..Version'
db '0,1'
db CR,LF,LF,'$'
s_init:
mov ah,9 ;Print String
mov dx,offset ident
int 21h
mov dx,CS:rh_seg
mov es,dX
mov bx,CS:rh_off
lea aX,end_driver         ;Get end of driver address
mov es:[bX]+14,ax
mov es:[bX]+16,cx
xor aX,ax                           ;Zero the AX register
jmp finish
s_write:
xor ax,ax                
jmp finish
end_driver:
        drvr endp
        cseg ends
              end
1: 这年代还玩这个呀?恐怕玩这个的人不多了………… 2: 提示:1。 INT 20H      2。MOV AX, 3100H / INT 21H   ; 还要把中断router装到内存

    MOV AX, 3100H ; ah=31h, al=return code
    mov dx, ????h ; ---# of paragraphs of memory to keep resident
    INT 21H       ; CALL DOS FUNCTION 31H
3: dengm可不可以说的详细点哈 4: CALL DOS FUNCTION 31H to keep the driver resident

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]