⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io.asm

📁 开源DOS的C代码源程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
                xor     ax,ax
                jmp     short LptCmnIntr

Lpt1Intr:
                push    si
                push    ax
                xor     al,al
                mov     ah,1
                jmp     short LptCmnIntr

Lpt2Intr:
                push    si
                push    ax
                mov     al,1
                mov     ah,2
                jmp     short LptCmnIntr

Lpt3Intr:
                push    si
                push    ax
                mov     al,2
                mov     ah,3

LptCmnIntr:
                mov     si,LptTable
                mov     [cs:uPrtNo],ah
                jmp     short DiskIntrEntry


AuxIntr:
                push    si
                push    ax
                xor     al,al
                jmp     short ComCmnIntr

Com2Intr:
                push    si
                push    ax
                mov     al,1
                jmp     short ComCmnIntr

Com3Intr:
                push    si
                push    ax
                mov     al,2
                jmp     short ComCmnIntr

Com4Intr:
                push    si
                push    ax
                mov     al,3
                jmp     short ComCmnIntr

ComCmnIntr:
                mov     si,ComTable
                jmp     short DiskIntrEntry


DskIntr:
                push    si
                mov     si,DiskTable
CharIntrEntry:
                push    ax
DiskIntrEntry:
                push    cx
                push    dx
                push    di
                push    bp
                push    ds
                push    es
                push    bx
                mov     byte [cs:uUnitNumber],al
                lds     bx,[cs:_ReqPktPtr]
                test    byte [cs:si],80h
                je      AsmType

                mov     al,[bx+cmd]
                cmp     al,[cs:si]
                ja      _IOCommandError
                cbw
                shl     ax,1
                add     si,ax
                xchg    di,ax

                push    ds
                push    bx
                mov     bp,sp
                mov	ds,[cs:_TEXT_DGROUP]
                cld
                call    word [cs:si+1]
                pop     cx
                pop     cx
                jmp     short StoreStatus

AsmType:        mov     al,[bx+unit]
                mov     ah,[bx+media]
                mov     cx,[bx+count]
                mov     dx,[bx+start]
                xchg    di,ax
                mov     al,[bx+cmd]
                cmp     al,[cs:si]
                ja      _IOCommandError
                cbw
                shl     ax,1
                add     si,ax
                xchg    di,ax

                les     di,[bx+trans]
                mov     ds,[cs:_TEXT_DGROUP]
                cld
                jmp     word [cs:si+1]

;
; Name:
;       _IOXXXXXXX
;
; Function:
;       Exit routines for internal device drivers.
;
; Description:
;       These routines are the exit for internal device drivers.  _IOSuccess 
;       is for read/write functions and correctly returns for a successful 
;       read/write operation by setting the remainng count to zero.  _IOExit 
;       simply sets success bit and returns.  _IODone returns complete and 
;       busy status.  _IOCommandError returns and error status for invalid 
;       commands.  _IOErrCnt corrects the remaining bytes for errors that 
;       occurred during partial read/write operation.  _IOErrorExit is a 
;       generic error exit that sets done and error.
;
                global  _IOSuccess
_IOSuccess:
                lds     bx,[cs:_ReqPktPtr]
                xor     ax,ax
                mov     [bx+count],ax

                global  _IOExit
_IOExit:
                mov     ah,1

StoreStatus:
                lds     bx,[cs:_ReqPktPtr]
                mov     [bx+status],ax
                pop     bx
                pop     es
                pop     ds
                pop     bp
                pop     di
                pop     dx
                pop     cx
                pop     ax
                pop     si
                retf


                global  _IODone
_IODone:
                mov     ah,3
                jmp     short StoreStatus

                global  _IOCommandError
_IOCommandError:
                mov     al,3

                global  _IOErrCnt
_IOErrCnt: 
                lds     bx,[cs:_ReqPktPtr]
                sub     [bx+count],cx
                global  _IOErrorExit
_IOErrorExit:
                mov     ah,81h
                jmp     short StoreStatus

;
; Name:
;       GetUnitNum
;
; Function:
;       Return the internally set unit number.
;
; Description:
;       Simply return the contents of uUnitNumber.  This version relies on 
;       no segment registers and makes a safe call regardless of driver 
;       state.
;
                global  GetUnitNum
GetUnitNum:
                mov     dx,[cs:uUnitNumber]
                ret

                ;
                ; These are still old style DOS-C drivers.  I'll replace 
                ; them in the next release
                ;


                ;
                ; block device interrupt
                ;
                ; NOTE: This code is not standard device driver handlers
                ; It is written for sperate code and data space.
                ;

blk_driver_params:
                   dw  blk_stk_top
                   dw  _reloc_call_blk_driver
                   dw  seg _reloc_call_blk_driver

clk_driver_params:
                   dw  clk_stk_top
                   dw  _reloc_call_clk_driver
                   dw  seg _reloc_call_clk_driver

                ; clock device interrupt
clk_entry:
                pushf
                push    bx
                
                mov     bx, clk_driver_params
                
                jmp short clk_and_blk_common


                ; block device interrupt
blk_entry:
                pushf
                push    bx
                
                mov     bx, blk_driver_params
                
clk_and_blk_common:                
                
                push    ax
                push    cx
                push    dx

                
                ; small model
                mov     ax,sp	                    	; use internal stack
                mov     dx,ss
                pushf                                   ; put flags in cx
                pop     cx
                cli                                     ; no interrupts
                mov     ss,[cs:_TEXT_DGROUP]
                mov     sp,[cs:bx]
                
                push    cx
                popf                                    ; restore interrupt flag
                
                

                push    ax                          ; save old SS/SP
                push    dx
                
                                                    ; push these registers on
                push    ds                          ; BLK_STACK
                push    bp                          ; to save stack space
                push    si
                push    di
                push    es
                Protect386Registers

                mov     ds,[cs:_TEXT_DGROUP]        ; 
                
                
                push    word [cs:_ReqPktPtr+2]
                push    word [cs:_ReqPktPtr]
                call    far [cs:bx+2]
                pop     cx
                pop     cx
                
                les     bx,[cs:_ReqPktPtr]		; now return completion code
                mov     word [es:bx+status],ax  ; mark operation complete
                
                
                Restore386Registers
                pop     es
                pop     di
                pop     si
                pop     bp
                pop     ds
                

                pop    dx                       ; get back old SS/SP
                pop    ax
                
                cli                             ; no interrupts
                mov     ss,dx           		; use dos stack
                mov     sp,ax


                pop     dx
                pop     cx
                pop     ax
                pop     bx
                popf
                retf

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -