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

📄 rxdosdev.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 5 页
字号:
        call maxBlockDevices                            ; get number of blocked devices

        currSegment es
        mov bx, offset _RxDOS_NULLDev                   ; get start of chain
        getarg ax, _drive

findBlockedDev_08:
        cmp bx, -1                                      ; end of list ?
        stc                                             ; set error
        jz findBlockedDev_16                            ; if end of list -->

        test word ptr es:[ devAttributes ][ bx ], ( DEV_CHAR )
        jnz findBlockedDev_14                           ; if a character device -->

        sub cl, es:[ devUnits ][ bx ]                   ; # units suported
        cmp al, cl                                      ; compare against drive code
        jl findBlockedDev_14                            ; if not device of interest -->

        or ax, ax                                       ; clear carry
        jmp short findBlockedDev_16                     ; return -->

findBlockedDev_14:
        les bx, dword ptr es:[ devLink ][ bx ]
        jmp findBlockedDev_08                           ; go to next ->

findBlockedDev_16:
        mov cx, es
        mov dx, bx
        getarg ax, _drive
        pop bx
        pop es
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Report Max Block Devices Available                           ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   cx     number of blocked devices                            ;
        ;...............................................................;

maxBlockDevices:

        push es
        currSegment es
        mov bx, offset _RxDOS_NULLDev                   ; get start of chain
        xor cx, cx                                      ; # blocked devices

maxBlockDev_08:
        cmp bx, -1                                      ; end of list ?
        jz maxBlockDev_16                               ; if end of list -->

        test word ptr es:[ devAttributes ][ bx ], ( DEV_CHAR )
        jnz maxBlockDev_14                              ; if a character device -->

        add cl, byte ptr es:[ devName ][ bx ]

maxBlockDev_14:
        les bx, dword ptr es:[ devLink ][ bx ]
        jmp maxBlockDev_08                              ; go to next ->

maxBlockDev_16:
        pop es
        ret

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Driver Media Request                                         ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   al     drive to check                                       ;
        ;   ah     media type expected                                  ;
        ;   ss:bx  ptr for volume id return value                       ;
        ;           (value set only if line changed)                    ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   cy     if abort/ not ready                                  ;
        ;                                                               ;
        ;   ax     original drive info                                  ;
        ;   ch     new media type                                       ;
        ;   cl     if changed flags                                     ;
        ;...............................................................;

DevMediaRequest:

        Entry
        def  _drive, ax
        def  _ptrVolumeID, bx                           ; ss:
        defbytes reqBlock, sizeMaxReqHeader

        push es
        push bx
        push di
        push ax

        mov ah, MEDIAREQUEST
        lea di, offset reqBlock [ bp ]
        call initReqBlock

        mov byte ptr [ reqBlock. mrMediaID  ][ bp ], ah
        mov byte ptr [ reqBlock. mrLength   ][ bp ], sizeMEDIAReqHeader
        mov byte ptr [ reqBlock. mrFunction ][ bp ], MEDIAREQUEST
        getarg ax, _drive                               ; restore drive
        call BlockedDevRequest                          ; call blocked device

        mov bx, word ptr [ _ptrVolumeID ][ bp ]
        mov ax, word ptr [ reqBlock. mrVolumeID. _Low  ][ bp ]
        mov cx, word ptr [ reqBlock. mrVolumeID. _High ][ bp ]
        mov word ptr ss:[ _Low  ][ bx ], ax
        mov word ptr ss:[ _High ][ bx ], cx

        mov ch, byte ptr [ reqBlock. mrMediaID ][ bp ]
        mov cl, byte ptr [ reqBlock. mrReturn  ][ bp ]

        pop ax
        pop di
        pop bx
        pop es
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Incorrect Disk Media                                         ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   ax     drive                                                ;
        ;   cx:dx  serial number required                               ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   cy     if abort/ not ready                                  ;
        ;   ax     original drive info                                  ;
        ;                                                               ;
        ;   All Registers Saved                                         ;
        ;...............................................................;

incorrectDiskMedia:

        Entry
        defbytes _devVolumeId, sizeVolumeID
        defbytes reqBlock, sizeMaxReqHeader

        mov ah, MEDIAREQUEST
        lea di, offset reqBlock [ bp ]
        call initReqBlock

        mov ax, offset devErrInvalidDiskChange
        lea bx, offset reqBlock [ bp ]
        call _callCriticalError
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Driver READ                                                  ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   al     drive                                                ;
        ;   bx     # sectors to read                                    ;
        ;   cx:dx  starting sector address to read                      ;
        ;   es:di  buffer to read (buffer address cannot wrap-around)   ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   cy     if abort/ not ready                                  ;
        ;...............................................................;

DevRead:

        Entry
        def  _drive, ax
        def  _sectors, bx
        ddef _bufferPtr, es, di
        ddef _sector, cx, dx
        defbytes volumeID, sizevolumeLabel
        defbytes reqBlock, sizeMaxReqHeader

        push es
        push bx
        push di
        push ax
        call getAddrDPB                                 ; (es:bx) Device Parameter Block
        jc DevRead_16                                   ; if invalid drive -->

        push word ptr es:[ _dpbMediaDescriptor ][ bx ]

        mov ah, DEVICEREAD
        lea di, offset reqBlock [ bp ]
        call initReqBlock

        getarg ax, _sectors
        mov word ptr [ reqBlock.rwrBytesReq ][ bp ], ax

        pop ax                                          ; media descriptor
        mov byte ptr [ reqBlock.rwrMediaID ][ bp ], al

        mov dx, word ptr [ _bufferPtr. _segment ][ bp ]
        mov ax, word ptr [ _bufferPtr. _pointer ][ bp ]
        mov word ptr [ reqBlock.rwrBuffer. _segment ][ bp ], dx
        mov word ptr [ reqBlock.rwrBuffer. _pointer ][ bp ], ax

        lea di, offset volumeID [ bp ]
        mov word ptr [ reqBlock. rwrVolumeID. _pointer ][ bp ], di
        mov word ptr [ reqBlock. rwrVolumeID. _segment ][ bp ], ss

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  if address is huge, store in huge request area
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        getdarg cx, dx, _sector
        or cx, cx                                       ; if huge address
        jz DevRead_08                                   ; must save in huge, else skip -->

        mov word ptr [ reqBlock. rwrHugeStartSec. _high ][ bp ], cx
        mov word ptr [ reqBlock. rwrHugeStartSec. _low  ][ bp ], dx
        mov dx, -1

DevRead_08:
        mov word ptr [ reqBlock.rwrStartSec ][ bp ], dx ; sector (or -1 if huge)
        getarg ax, _drive                               ; restore drive
        call BlockedDevRequest                          ; call blocked device

DevRead_16:
        pop ax
        pop di
        pop bx
        pop es
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Driver CHAR READ LINE                                        ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Reads until CR or end of buffer                              ;
        ;                                                               ;
        ;  Input:                                                       ;
        ;   cx     characters to read                                   ;
        ;   es:di  buffer to read                                       ;
        ;   stack  driver to read from                                  ;
        ;                                                               ;
        ;  Output:                                                      ;
        ;   cx     characters actually returned                         ;
        ;   zr     if end of file                                       ;
        ;...............................................................;

DevCharReadLine:

        Entry 2
        darg _device

        def  _endoffile, FALSE
        def  _updatedBuffers, FALSE
        ddef _clockticks        
        ddef _bufferPtr, es, di
        defbytes _tempBuffer, 8
        defbytes _lineEdit, sizeLINEEDITOR
        defbytes reqBlock, sizeMaxReqHeader

        push es
        push bx
        push di
        push ax
        push cx                                         ; max characters

        mov al, -1                                      ; not a block device
        mov ah, NONDESTRREAD
        lea di, offset reqBlock [ bp ]
        call initReqBlock                               ; init non-destructive read

        call ClockTimer                                 ; dx: ax
        stordarg _clockticks, dx, ax

        pop cx
        push di
        lea di, offset _lineEdit [ bp ]
        mov dx, word ptr [ _bufferPtr. _segment ][ bp ]
        mov ax, word ptr [ _bufferPtr. _pointer ][ bp ]
        call _lineEditorInit                            ; init line editor control block

        lea di, offset _tempBuffer [ bp ]
        mov word ptr [ reqBlock.rwrBuffer. _segment ][ bp ], ss
        mov word ptr [ reqBlock.rwrBuffer. _pointer ][ bp ], di
        mov word ptr [ reqBlock.rwrBytesReq         ][ bp ], 1
        pop di

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  wait for character
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DevCharReadLine_12:
        mov byte ptr [ reqBlock.rwrFunction ][ bp ], NONDESTRREAD
        mov word ptr [ reqBlock.rwrStatus   ][ bp ], 0000

        push word ptr [ _device. _segment ][ bp ]
        push word ptr [ _device. _pointer ][ bp ]
        call CharDevRequest                             ; test for character

        test word ptr [ reqBlock.rwrStatus ][ bp ], OP_DONE
        jz DevCharReadLine_16                           ; time out -->
        test word ptr [ reqBlock.rwrStatus ][ bp ], OP_BUSY
        jz DevCharReadLine_20                           ; we have a character -->

DevCharReadLine_16:
        cmp word ptr [ _updatedBuffers ][ bp ], TRUE    ; already updated buffers ?
        jz DevCharReadLine_18                           ; skip around -->
        call updateAllChangedCCBBuffers                 ; optimized update changed CCBs
        mov word ptr [ _updatedBuffers ][ bp ], TRUE    ; already updated buffers ?

DevCharReadLine_18:
        int intIDLELOOP                                 ; let other applications run
        jmp DevCharReadLine_12                          ; continue looping -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  get character, see if end of buffer or cr
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

⌨️ 快捷键说明

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