📄 rxdos.asm
字号:
cli
setES ss ; caller's stack
mov bx, bp ; caller's stack to es: bx
mov ds, word ptr cs:[ _RxDOS_CurrentSeg ] ; current segment.
mov ss, word ptr cs:[ _RxDOS_CurrentSeg ] ; current segment.
mov sp, word ptr ss:[ _RxDOS_CurrentStackTop ] ; point to current stack.
push bx ; caller's stack reference
push es
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; current stack parameters
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Entry ; set [ bp ]
def _FctAddress
push word ptr [ _RxDOS_CurrentStackTop ]
sub word ptr [ _RxDOS_CurrentStackTop ], 384 ; reserve stack
push word ptr [ _RxDOS_CurrentInstance ] ; base address of current stack
mov word ptr [ _RxDOS_CurrentInstance ], bp ; base address of current stack
push word ptr [ _RxDOS_INDOSFlag ]
inc word ptr [ _RxDOS_INDOSFlag ] ; INDOS
push word ptr [ _RxDOS_StackLongJump ] ; long jump
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; save PSP values
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov dx, word ptr [ _RxDOS_CurrentPSP ]
or dx, dx ; was PSP zero ?
jz _Interrupt_21_12 ; if no valid PSP -->
mov ds, dx ; see if PSP was ever set
mov word ptr ds:[ pspUserStack. _segment ], es
mov word ptr ds:[ pspUserStack. _pointer ], bx
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; determine function address
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Interrupt_21_12:
sti
cld
currSegment ds ; point to current segment
mov word ptr [ _RxDOS_FunctionCall ], ax ; AX on call
cmp ah, _RxDOS_maxFunctionCode ; max function code ?
jnc _Interrupt_21_48 ; if out of range -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
; [ds] from user call is passed in [es]
; [dx] from user call is passed in [di]
; [ds] is changed to current segment
; [ss] == [ds] is assumed
;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
xor bh, bh
mov bl, ah ; offset into functions table
add bx, bx
mov bx, word ptr [ _RxDOS_functions ][ bx ] ;
mov word ptr [ _FctAddress ][ bp ], bx ; save dispatch address
RetCallersStackFrame ds, bx
mov es, word ptr [ _DataSegment][ bx ] ; ds on call
mov di, word ptr [ _DX ][ bx ] ; set di from DX
mov bx, word ptr [ _BX ][ bx ] ; restore bx
mov dx, di ; and also passed in DI
clc
currSegment ds ; point to current segment
mov word ptr [ _RxDOS_StackLongJump ], sp ; save stack long jump
IFDEF RxDOS_TRACEBUILD
call LogTraceInt21Calls ; trace build
ENDIF
call word ptr [ _FctAddress ][ bp ] ; go do function
jnc _Interrupt_21_48
_Interrupt_21_22:
RetCallersStackFrame es, bx
or word ptr es:[ _Flags ][ bx ], 1 ; set carry bit
mov si, ax ; error pointer in AX
cmp ax, -1 ; error an FCB error ?
mov ah, byte ptr es:[ _AX. _AH ][ bx ] ; retain ah in case fcb error
jz _Interrupt_21_32 ; yes -->
mov word ptr ss:[ _RxDOS_pExtErrorCode ], si ; save ptr to error code
mov ax, word ptr cs:[ ExtErrorCodeValue ][ si ] ; get actual error value
_Interrupt_21_32:
mov word ptr es:[ _AX ][ bx ], ax ; get actual error code.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return registers
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_Interrupt_21_48:
cli
pop word ptr ss:[ _RxDOS_StackLongJump ] ; long jump
pop word ptr ss:[ _RxDOS_INDOSFlag ] ; restore INDOS
pop word ptr ss:[ _RxDOS_CurrentInstance ] ; _Instance
pop word ptr ss:[ _RxDOS_CurrentStackTop ]
pop bx ; fct address
pop bx ; caller's stack pointer
sub bx, sizeStackFrame ; adjusted stack pointer
pop ss ; caller's stack reference
mov sp, bx
pop ax ; restore registers
pop bx
pop cx
pop dx
pop si
pop di
pop bp
pop ds
pop es
iret
_Interrupt_21 endp
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Call DOS Interface ;
;...............................................................;
_CallDOS proc far
mov ah, cl ; old compatability
Int21
ret ; far return
_CallDOS endp
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Interrupt 20 ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Terminate Program ;
;...............................................................;
_Interrupt_20 proc far
Int21 TerminateProcess, 00
iret ; no return expected
_Interrupt_20 endp
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Where Data Segment Relocated ;
;...............................................................;
_RxDOS_CurrentSeg dw 0000 ; Current Segment.
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; System Wide Functions ;
;...............................................................;
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; NULL Device Driver ;
;...............................................................;
null_interrupt proc far
mov word ptr es:[ rwrStatus ][ bx ], ( OP_DONE )
null_strategy: ret
null_interrupt endp
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Interrupt 23 - Control Break Exit Address ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; This is a default Int 23 handler. ;
; ;
; Returns CY to cancel current application. ;
; ;
;...............................................................;
_Interrupt_23 proc far
stc
ret 2 ; returns to appl (iret w/o status)
_Interrupt_23 endp
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Interrupt 24 - Critical Error Handler ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; This is a default Int 24 handler. ;
; ;
; Usage: ;
; bp:si driver's header ;
; di error code ;
; al drive code ;
; ah allowed responses ;
; 08h CRITERROR_IGNOREALLOWED ;
; 10h CRITERROR_RETRYALLOWED ;
; 20h CRITERROR_FAILALLOWED ;
; ;
; Return: ;
; al contains one of these values ;
; 00h CRITERROR_IGNORE ;
; 01h CRITERROR_RETRY ;
; 02h CRITERROR_TERMINATE ;
; 03h CRITERROR_FAIL ;
;...............................................................;
_Interrupt_24 proc far
push ds
push es
push cs
pop ds
push ax
xchg ax, di
mov ah, 0
xchg di, ax ; upper bits zero
add di, di
mov di, word ptr [ CriticalErrorMessages ][ di ]
call _CritErrorDisplayNewLine
pop ax
push ax
cmp al, -1 ; valid unit ?
jz _Interrupt_24_08 ; no drive -->
mov di, offset perr_OnDrive
call _CritErrorDisplayMessage
pop ax
push ax
add al, 'A'
int 29h
mov al, ':'
int 29h
_Interrupt_24_08:
pop ax ; abort, retry, fail, ...
push ax ;
mov di, offset CritError_AbortRetryIgnoreFail
test ah, CRITERROR_FAILALLOWED
jnz _Interrupt_24_12
mov di, offset CritError_AbortRetryIgnore
_Interrupt_24_12:
call _CritErrorDisplayNewLine
xor ax, ax
int 16h
push ax
int 29h
pop cx ; character
pop ax ; allowed to ah
push ax
or cl, 20h ; lower case
cmp cl, "f" ; Fail ?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -