共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电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】STM32的硬件通讯调试过程的“坑”被打赏50分 | |
【我踩过的那些坑】晶振使用的问题被打赏100分 | |
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 |