📄 rxdosexe.asm
字号:
mov al, ' '
mov cx, (sizefnName + sizefnExtension)
mov di, offset pspFCB_1
rep stosb ; init fcb 1
mov cx, (sizefnName + sizefnExtension)
mov di, offset pspFCB_2
rep stosb ; init fcb 2
mov word ptr es:[ pspFileHandlePtr. _segment ], es
mov word ptr es:[ pspFileHandlePtr. _pointer ], pspHandleTable
mov word ptr es:[ pspFileHandleCount ], sizepspHandleTable
mov ax, word ptr [ _RxDOS_DOSVersion ] ; get DOS Version
mov word ptr es:[ pspVersion ], ax ; Major, Minor version (VERS)
jmp short createPSP_12
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; copy an existing PSP
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
createPSP_08:
call copyCurrentPSP ; copy current PSP
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; other specific initialization
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
createPSP_12:
mov ax, word ptr ss:[ _RxDOS_CurrentPSP ]
mov word ptr es:[ pspParentId ], ax ; parent PSP address
mov ax, es ; compute next alloc
add ax, word ptr [ _AllocSize ][ bp ]
mov word ptr es:[ pspNextParagraph ], ax
mov word ptr es:[ pspInt20 ], 20CDh ; Int 20 instruction
mov word ptr es:[ pspDosCall ], 21CDh ; Int 21 instruction
mov word ptr es:[ pspDosCall + 2 ], 0CBh ; retf
mov byte ptr es:[ pspDispatcher ], 9Ah ; call instruction
mov word ptr es:[ 1+(pspDispatcher. _segment) ], cs
mov word ptr es:[ 1+(pspDispatcher. _pointer) ], offset _CallDOS
mov word ptr es:[ pspShareChain. _pointer ], -1 ; share vector
mov word ptr es:[ pspShareChain. _segment ], -1
push ds
xor ax, ax
mov ds, ax
mov bx, offset ( intCONTROLC * 4 ) ; Int23 control-C vector
mov ax, word ptr [ _pointer ][ bx ] ; existing value copied to PSP
mov dx, word ptr [ _segment ][ bx ]
mov word ptr es:[ pspControlCVect. _pointer ], ax
mov word ptr es:[ pspControlCVect. _segment ], dx
mov bx, offset ( intCRITICALERROR * 4 ) ; Int24 criterror vector
mov ax, word ptr [ _pointer ][ bx ] ; existing value copied to PSP
mov dx, word ptr [ _segment ][ bx ]
mov word ptr es:[ pspCritErrorVect. _pointer ], ax
mov word ptr es:[ pspCritErrorVect. _segment ], dx
RetCallersStackFrame ds, bx
mov dx, word ptr [ _CS ][ bx ] ; set terminate vector as return address
mov ax, word ptr [ _IP ][ bx ]
mov word ptr es:[ pspTerminateVect. _pointer ], ax
mov word ptr es:[ pspTerminateVect. _segment ], dx
pop ds
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; copy command line
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov di, offset pspCommandTail ; build dummy command line
mov word ptr ss:[ di ], 0D00h ; pre-init command line
mov ax, word ptr [ _ExecBlock. _segment ][ bp ]
or ax, word ptr [ _ExecBlock. _pointer ][ bp ]
jz createPSP_56 ; if no load execute block -->
getdarg ds, di, _ExecBlock
cmp word ptr [ lexecCommandTail. _segment ][ di ], -1
jz createPSP_36 ; if no command tail to copy -->
mov ax, word ptr [ lexecCommandTail. _segment ][ di ]
or ax, word ptr [ lexecCommandTail. _pointer ][ di ]
jz createPSP_36 ; if no command tail to copy -->
SaveRegisters es, si
lds si, dword ptr [ lexecCommandTail ][ di ]
mov di, offset pspCommandTail
mov cx, 0001 ; add one for length byte (thanks BillW)
add cl, byte ptr [ si ] ; get character count
rep movsb ; copy
mov byte ptr es:[ di ], 0Dh ; store trailing cr
RestoreRegisters si, es ; address of PSP
createPSP_36:
getdarg ds, di, _ExecBlock
cmp word ptr [ lexecFCB_1. _segment ][ di ], -1
jz createPSP_42 ; if no FCB 1 to copy -->
mov ax, word ptr [ lexecFCB_1. _segment ][ di ]
or ax, word ptr [ lexecFCB_1. _pointer ][ di ]
jz createPSP_42 ; if no FCB 1 to copy -->
lds si, dword ptr [ lexecFCB_1 ][ di ]
mov di, offset pspFCB_1
mov cx, (pspFCB_2 - pspFCB_1)/ 2
rep movsw
createPSP_42:
getdarg ds, di, _ExecBlock
cmp word ptr [ lexecFCB_2. _segment ][ di ], -1
jz createPSP_56 ; if no FCB 2 to copy -->
mov ax, word ptr [ lexecFCB_2. _segment ][ di ]
or ax, word ptr [ lexecFCB_2. _pointer ][ di ]
jz createPSP_56 ; if no FCB 2 to copy -->
lds si, dword ptr [ lexecFCB_2 ][ di ]
mov di, offset pspFCB_2
mov cx, (pspFCB_2 - pspFCB_1)/ 2
rep movsw
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; exit
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
createPSP_56:
pop es
pop ds
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Increment Ref Count ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; al SFT handle ;
; dx increment value ;
;...............................................................;
incrRefCount:
push es
push di
push dx
xor ah, ah
call FindSFTbyHandle ; get corresponding SFT (es: di )
pop dx
test word ptr es:[ sftDevInfo ][ di ], sftNoInherit
jnz incrRefCount_08 ; if no inherit -->
add word ptr es:[ sftRefCount ][ di ], dx ; bump in use count
incrRefCount_08:
pop di
pop es
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Allocate Loader Memory, copy Env block, init PSP ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; es:bx load execute block ;
; ax paragraphs of program expected ;
; dx max requested paragraphs ;
; ;
; Output: ;
; ax PSP segment address ;
; es Data segment address ;
; cx size in paras of area allocated ;
; cy if cannot create ;
;...............................................................;
_LoaderAllocMemory:
Entry
ddef _ExecBlock, es, bx
def _requiredParas, ax
def _maxRequestedParas, dx
def _allocatedSize, 0000
def _envSeg, 0000
def _AllocEnv, 0000
def _programPSP, 0000
def _loadHigh, FALSE
def _StartSegment
def _envSize
def _originalMemPolicy
add word ptr [ _requiredParas ][ bp ], (sizePSP / PARAGRAPH)
ifc _loaderAllocMemory_50
or dx, dx ; special 0000 request ?
jnz _loaderAllocMemory_04 ; no -->
mov word ptr [ _maxRequestedParas ][ bp ], 0FFFFh
mov word ptr [ _loadHigh ][ bp ], TRUE ; if load HIGH
_loaderAllocMemory_04:
mov ax, word ptr [ _requiredParas ][ bp ]
cmp ax, word ptr [ _maxRequestedParas ][ bp ]
jc _loaderAllocMemory_08
jz _loaderAllocMemory_08
mov word ptr [ _maxRequestedParas ][ bp ], ax
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; determine the size of the environment block, if any.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_loaderAllocMemory_08:
mov ax, word ptr [ _RxDOS_AllocStrategy ]
storarg _originalMemPolicy, ax ; save current alloc policy
mov ax, word ptr es:[ lexecEnvironment ][ bx ]
or ax, ax ; env block address passed ?
jnz _loaderAllocMemory_14 ; if segment passed -->
mov ax, word ptr ss:[ _RxDOS_CurrentPSP ]
or ax, ax ; current PSP available ?
jz _loaderAllocMemory_12 ; no, go figure something -->
mov es, ax
mov ax, word ptr es:[ pspEnvironment ] ; get environment block address
or ax, ax ; available ?
jnz _loaderAllocMemory_14 ; yes, use it -->
_loaderAllocMemory_12:
mov word ptr [ _RxDOS_AllocStrategy ], _MEM_LASTFIT_HIGH
mov cx, sizeParasPerPage ; if no exec block, default to this for now
jmp short _loaderAllocMemory_24 ; go allocate default size
_loaderAllocMemory_14:
mov es, ax ; memory block address
storarg _envSeg, ax ; save env segment to copy
call _getSizeOfEnvString ; get size of env string
_loaderAllocMemory_24:
storarg _envSize, cx ; save size in paras
call allocateMemBlock ; return seg pointer to avail memory
getarg ax, _originalMemPolicy ; restore current alloc policy
mov word ptr [ _RxDOS_AllocStrategy ], ax
jc _loaderAllocMemory_50 ; if insufficient space to load -->
storarg _AllocEnv, es ; store alloc environment
xor ax, ax
xor di, di ; start of area
getarg cx, _envSize ; get size in paras
shl cx, 1 ; convert paras to words
shl cx, 1 ; convert paras to words
shl cx, 1 ; convert paras to words
rep stosw ; clear/ zero.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; copy environment
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmp word ptr [ _envSeg ][ bp ], 0000 ; no default segment ?
jz _loaderAllocMemory_42 ; skip copy -->
push ds
xor di, di
xor si, si
getarg ds, _envSeg
getarg cx, _envSize ; env size in paras
shl cx, 1 ; convert to words !
shl cx, 1
shl cx, 1
rep movsw ; copy env block
pop ds
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; allocate block
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_loaderAllocMemory_42:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -