共2条
1/1 1 跳转至页
DOS 求助DOS编写驱动程序的问题
问
最近需要编写一个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
; 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 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 | |
【FRDM-MCXN947评测】核间通信MUTEX被打赏50分 |