共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 跳转至页
回复
有奖活动 | |
---|---|
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
【有奖活动】震撼来袭!这场直播将直击工程师的心灵! | |
“我想要一部加热台”活动,不花钱赢取开发好工具!活动开始了哦 | |
【有奖活动】伙伴们:您的“需求”解决了吗? | |
抽奖了,抽奖了,金升阳医疗电源 |
打赏帖 | |
---|---|
【换取手持数字示波器】+与同事对定时器输出相位可调PWM移相全桥控制分享被打赏50分 | |
【换取手持数字示波器】+LP-MSPM0L1306开发板试用体验+串口被打赏40分 | |
CC-RL编译器相关问题求助被打赏10分 | |
【换取手持数字示波器】+与同事对ESP-12开发调试经验分享被打赏50分 | |
【换取手持数字示波器】+同事tek示波器调试spi解析被打赏50分 | |
【换取手持数字示波器】+2.6寸墨水屏调试经验被打赏50分 | |
换取手持数字示波器+个人开关电源的设计经验被打赏50分 | |
【换取手持数字示波器】+【APT32F173测评】+URAT被打赏20分 | |
【换取手持数字示波器】CH32X035的定时器以及外部中断体验被打赏50分 | |
【换取手持数字示波器】CH32X035搭建开发环境(RISC-V)被打赏50分 |