📄 rxdosdev.asm
字号:
DevCharReadLine_20:
push di
mov byte ptr [ reqBlock.rwrFunction ][ bp ], DEVICEREAD
push word ptr [ _device. _segment ][ bp ]
push word ptr [ _device. _pointer ][ bp ]
call CharDevRequest ; get character
mov ax, word ptr [ _tempBuffer ][ bp ] ; get character
or al, al
jz DevCharReadLine_22
mov ah, 0
DevCharReadLine_22:
lea di, offset _lineEdit [ bp ]
call _lineEditor ; store character/ line editor
mov cx, word ptr ss:[ editMaxAvail ][ di ] ; get max chars
cmp cx, word ptr ss:[ editMaxBuffer ][ di ] ; at max end of line ?
pop di
jge DevCharReadLine_36 ; if exit -->
call SetExit_IfControlC ; control C or Control Z ?
storarg _endoffile, dx ; end of file status
jz DevCharReadLine_36 ; yes, exit -->
cmp ax, ControlM ; return character ?
jz DevCharReadLine_26 ; yes -->
cmp ax, ControlJ ; return character ?
jnz DevCharReadLine_12 ; no -->
DevCharReadLine_26:
mov ax, ControlJ ; do line feed
lea di, offset _lineEdit [ bp ]
call _lineEditor ; use editor to display
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; exit
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DevCharReadLine_36:
getdarg es, di, _bufferPtr
mov cx, word ptr [ _lineEdit. editMaxAvail ][ bp ] ; get chars entered
cmp word ptr [ _endoffile ][ bp ], TRUE ; zr if end of file
clc ; no carry
pop ax
pop dx
pop ax
pop di
pop bx
pop es
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Driver CHAR READ ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; cx characters to read ;
; es:di buffer to read ;
; stack driver to read from ;
; ;
; Output: ;
; cx characters actually read ;
;...............................................................;
DevCharRead:
Entry 2
darg _device
def _count, cx
ddef _bufferPtr, es, di
defbytes reqBlock, sizeMaxReqHeader
push bx
push ax
mov al, -1 ; not a block device
mov ah, IOCTLREAD
lea di, offset reqBlock [ bp ]
call initReqBlock
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
getarg cx, _count
mov word ptr [ reqBlock.rwrBytesReq ][ bp ], cx
push word ptr [ _device. _segment ][ bp ]
push word ptr [ _device. _pointer ][ bp ]
call CharDevRequest ; call device (get character)
mov cx, word ptr [ reqBlock.rwrBytesReq ][ bp ] ; actual bytes read
getdarg es, di, _bufferPtr ; restore es: di
pop ax
pop bx
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Driver WRITE OR WRITE/VERIFY ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; al drive to write to ;
; bx # sectors to write ;
; cx:dx starting sector address where to write ;
; es:di buffer to write (buffer address cannot wrap-around) ;
; ;
; Output: ;
; cy if abort/ not ready ;
;...............................................................;
DevWrite:
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
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; ok to write
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DevWrite_02:
call getAddrDPB ; (es:bx) Device Parameter Block
jc DevWrite_36 ; if invalid drive -->
push word ptr es:[ _dpbMediaDescriptor ][ bx ]
mov ah, DEVICEWRITE
cmp byte ptr ss:[ _RxDOS_Verify ], 00 ; non-zero means verify
jz DevWrite_06 ; if not verify -->
mov ah, DEVICEWRITEVERIFY ; if verify writes
DevWrite_06:
lea di, offset reqBlock [ bp ]
call initReqBlock ; al contains [logcl unit]
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
jz DevWrite_08
mov word ptr [ reqBlock. rwrHugeStartSec. _high ][ bp ], cx
mov word ptr [ reqBlock. rwrHugeStartSec. _low ][ bp ], dx
mov dx, -1
DevWrite_08:
mov word ptr [ reqBlock.rwrStartSec ][ bp ], dx
getarg ax, _drive ; restore drive
or ax, ax ; zero ?
;; jnz DevWrite_36 ; WRITE PROTECT DURING DEBUG -->
cmp ax, 03
jnz DevWrite_34
int 3
DevWrite_34:
call BlockedDevRequest ; call blocked device
nop ; DEBUG nop
DevWrite_36:
pop ax
pop di
pop bx
pop es
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Driver CHAR WRITE ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; cx characters to write ;
; es:di buffer to write ;
; stack driver address to write to ;
; ;
; Output: ;
; cy if abort/ not ready ;
;...............................................................;
DevCharWrite:
DevCharWriteLine: ; intentional alias
Entry 2
darg _device
def _count, cx
ddef _bufferPtr, es, di
defbytes volumeID, sizevolumeLabel
defbytes reqBlock, sizeMaxReqHeader
push es
push bx
push di
push ax
mov al, -1 ; not a block device
mov ah, DEVICEWRITE
lea di, offset reqBlock [ bp ]
call initReqBlock
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
getarg cx, _count
mov word ptr [ reqBlock.rwrBytesReq ][ bp ], cx
push word ptr [ _device. _segment ][ bp ]
push word ptr [ _device. _pointer ][ bp ]
call CharDevRequest ; call device
getarg cx, _count ; assume written
pop ax
pop di
pop bx
pop es
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Get System Date and Time ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; es:di points to date structure ;
;...............................................................;
getSysDate:
Entry
defbytes reqBlock, sizeMaxReqHeader
saveRegisters es, di, dx, cx
push es
push di
mov al, -1 ; not a block device
mov ah, DEVICEREAD
lea di, offset reqBlock [ bp ]
call initReqBlock
mov word ptr [ reqBlock.rwrBytesReq ][ bp ], sizeCLOCKDATA
pop word ptr [ reqBlock.rwrBuffer. _pointer ][ bp ] ; di
pop word ptr [ reqBlock.rwrBuffer. _segment ][ bp ] ; es
push word ptr [ _RxDOS_pCLOCKdriver. _segment ]
push word ptr [ _RxDOS_pCLOCKdriver. _pointer ]
call CharDevRequest
restoreRegisters cx, dx, di, es
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Set System Date and Time ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; es:di points to date structure ;
;...............................................................;
setSysDate:
Entry
defbytes reqBlock, sizeMaxReqHeader
saveRegisters es, di, dx, cx
push es
push di
mov al, -1 ; not a block device
mov ah, DEVICEWRITE
lea di, offset reqBlock [ bp ]
call initReqBlock
mov word ptr [ reqBlock.rwrBytesReq ][ bp ], sizeCLOCKDATA
pop word ptr [ reqBlock.rwrBuffer. _pointer ][ bp ] ; di
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -