📄 rtmload.asm
字号:
pop ds
cCall __ctermsub ; de-install math and divide by zero
NoIntHooked: ; interrupts.
MOV AX,(C_EXIT SHL 8)+1;dos exit with error return code
INT 21H ;exit
assumes DS,NOTHING
;***
; B$ShellEntry - runtime EXEC routine for SHELL (RTM only)
;
;Purpose:
; [Added within revision 5.]
; Since the runtime module code is discarded during a SHELL
; operation, this routine deallocates the RTM code, performs
; the EXEC specified, and then reloads the RTM code with fixups.
;Entry:
; Parameters set for DOS EXEC call.
;Exit:
; AX = post-INT 21 value.
; CF = post-INT 21 value.
;Uses:
; All. RTM saved the registers it needs.
;Exceptions:
; InvalidError if bad EXE format.
; DiskIOError if error during RTM disk operations.
;******************************************************************************
;***
; B$ULReload - reload a user library. (UL only).
;
;Purpose:
; Added as part of revision [10].
; Reloads user library code and data, effectively
; reinitializing static data for subsequent execution.
;Entry:
; None.
;Exit:
; None.
;Uses:
; AX, BX, CX, DX.
;Exceptions:
; Initialization errors:
; "disk I/O" error
; "invalid format" error
;****
cProc B$ULReload,<PUBLIC,FAR>
cBegin
cEnd
;***
; ULSaveName - Allocate a high memory block for UL name (UL Only)
;
;Purpose:
; Added as part of revision [12].
; Allocate a high memory block to save user library
; file name in. Update b$ULfsd to point to the
; allocated block.
;Entry:
; Filename is in SpecBuffer
; Length is in InputStrLen
;
;Exit:
; [b$ULfsd] = 0
; [b$ULfsd+2] = allocated segment
; [b$ULNameLen] = byte size of user library name string
;Uses:
; BX, CX, DX, SI, DI, BP
;
;Preserves
; AX
;
;Exceptions:
; DOS Memory allocatation error.
; Out of memory error.
;****
;***
; ULAllocHighSeg - Allocate high memory block <= 64K from (UL only)
;
;Purpose:
; Added as part of revision [12].
; Allocate a high memory block from DOS. The block
; will be a max of 64K in length.
;Entry:
; DX = byte size of block to allocate
;Exit:
; BP = segment of allocated block
;Uses:
; CX, DX, DI.
;Exceptions:
; DOS Memory allocatation error.
; Out of memory error.
;****
;***
; PrintMessage - print a numbered message. (UL only)
;
;Purpose:
; Added with revision [19].
; Takes the numbered message, calls a QB helper routine to
; put the message in bufStdMsg and then prints the message to
; through DOS.
;Entry:
; AX - number of message to print.
;Exit:
; None.
;Uses:
; AX,CX,SI.
;Exceptions:
; None.
;******************************************************************************
cProc PrintMessage,<NEAR>,<DS>
cBegin
PUSH SS
POP DS
assumes DS,DGROUP
; AX has message number.
PUSH ES ;preserve ES across ListStdMsgRtmNear
cCall ListStdMsgRtmNear ;AX = char count, bufStdMsg = msg text
POP ES
MOV SI,OFFSET DGROUP:bufStdMsg ;[DS:SI] = ptr to message text
XCHG AX,CX ;[CX] = message length
JMP SHORT PrintFileLoop ;jump and print message
cEnd <nogen>
;***
; PrintFileName - print file name in SpecBuffer or FNameBuff. (UL only)
;
;Purpose:
; This routine prints the current UserLib Filename. If F_PRPATH
; in fUserPrompt is true, then we will a print path with the name
; (both comming from SpecBuffer). Otherwise, we will print the
; name only (from FNameBuff).
;
; Since FNameBuffLen is statically initialized to 0, this routine
; will work even if no name has yet been parsed.
;
;Entry:
; if (fUserPrompt & F_PRPATH)
; FNameBuff - filename to print.
; FNameBuffLen - length of file name.
; else
; SpecBuffer - path and filename to print.
; InputStrLen - Length of SpecBuffer.
;Exit:
; None.
;Uses:
; AX,CX,SI.
;Exceptions:
; None.
;******************************************************************************
cProc PrintFileName,NEAR,DS ; Added
cBegin
PUSH CS
POP DS
assumes DS,LOADRTM
TEST fUserPrompt,F_PRPATH ;Should we print path?
JE NoPrintPath ;No, get filename from FNameBuff
MOV SI,OFFSET SpecBuffer ;get ptr to file name and path
XOR CH,CH ;Clear CH for length
MOV CL,InputStrLen ;Get length of filename and path
JMP SHORT PrintFileMain ;Go print the string
NoPrintPath:
MOV SI,OFFSET FNameBuff ;get ptr to filename
MOV CX,FNameBuffLen ;get length of filename
PrintFileMain:
JCXZ EmptyFileName ;Eliminate degenerate case
PrintFileLoop:
LODSB ;get char in AL
MOV DL,AL ;[DL]=char to output
MOV AH,2 ;DOS char output function
INT 21H ;print char
LOOP PrintFileLoop ;repeat until all chars are printed
EmptyFileName:
cEnd
;***
; B$IInitPrint - print a numbered message before runtime inited. (QBI only)
;
;Purpose:
; Added with revision [20].
; Takes the numbered message, calls a QB helper routine to
; put the message in bufStdMsg and then prints the message to
; through DOS.
;Entry:
; AX - number of message to print.
;Exit:
; None.
;Uses:
; AX,CX,SI.
;Exceptions:
; None.
;******************************************************************************
cProc B$IInitPrint,<PUBLIC,FAR>
cBegin
; AX has message number.
cCall PrintMessage ;print the numbered message
cEnd
LoadRtmInfoInvalid:
JMP InvalidError ;jump to report invalid EXE error
;***
; LoadRtmData - load the runtime data segment (RTM only)
;
;Purpose:
; [Extracted from LoadRtmFile in revision 5.]
; From the start of the load image, load the data segment
; into the program DGROUP. The region loaded starts at
; segment CONST up to, but not including, segment COMMON.
;Entry:
; BX - handle of opened RTM file.
;Exit:
; DGROUP from CONST up to COMMON overlaid.
;Uses:
; AX, CX, DX, SI, DI, BP.
;Exceptions:
; None.
;******************************************************************************
;***
; LoadULData - load the user library data into DGROUP (UL only)
;
;Purpose:
; Added as part of revision [10].
; Load data from the user library data segment into DGROUP.
; The region loaded starts from the end of the DGROUP
; static data to the end of the user library static data.
; DGROUP will be grown by the size of the user library
; static data, and the stack will be moved into the highest
; memory of the grown DGROUP. Any pointers into the stack
; will be invalidated.
;Entry:
; BX - handle of opened RTM file.
; ES = DS - LoadRtm segment
;Exit:
; AX = new end of DGROUP static data
; Stack moved, and user library data read into hole vacated
; by the stack.
; __atopsp - points to new beginning of stack
; b$pend - points to new end of stack
; b$pendchk - points to new stack check boundary
;Uses:
; AX, CX, DX, SI, DI, BP.
;Exceptions:
; Out of memory. Invalid UL format.
;******************************************************************************
;***
;ReloadULData - load/reload UL data into hole created in DGROUP (UL Only)
;
;Purpose:
; Added with revision [10].
; Loads initial copy of data, or reloads copy of data for each RUN.
; The user library data is recopied into DGROUP. This will
; cause any preinited static data to be correct for a subsequent
; run.
;
; If blank COMMON is in preinited data, this procedure would
; reinitialize it, trashing user's values across CHAIN. To avoid
; this, a check is done for the existence of blank COMMON. If found,
; the data is moved in two chunks: "Part1" is the data before the
; COMMON block, "Part2" is the data after the COMMON block. This
; will preserve the blank COMMON in the middle for CHAIN.
;
; Note: Not loading COMMON here is ok for RUN also, because it
; would only be zeros, and the RUN initialization will
; zero the common for us.
;
;Entry:
; CX - start of DGROUP area to copy UL data into
; DI - byte size of UL data
; DS - DGROUP
;Exit:
; data copied into DGROUP (unfixed up)
;Uses:
; AX, CX, DX, SI, DI, BP, DS, ES.
;Exceptions:
; None.
;****
;***
; GetRtmCodeSize - compute the runtime module code size (RTM only)
;
;Purpose:
; (Mostly rewritten with revision [60].)
; [Extracted from LoadRtmFile in revision 5.]
; Compute the size of the load image from the EXE header
; information. Then use the CODE segment value from the
; frame buffer to compute the code size of the runtime module.
;Entry:
; EHBuffer has EXE header.
; RLBuffer has entry point frame.
;Exit:
; DX:AX - code size in bytes.
;Uses:
; AX, CX, DX.
;Exceptions:
; None.
;******************************************************************************
;***
; LoadRtmCode - load the rtm code, or user lib syms (RTM Only)
;
;Purpose:
; [Extracted from LoadRtmFile in revision 5.]
; Read the code section of the runtime module
; into memory.
;Entry:
; BX - handle of opened RTM file.
; DX:AX - size in code segment in bytes.
; BP - segment to load code.
;Exit:
; Block at segment BP has RTM code with no fixups.
;Uses:
; AX, CX, DX, SI, DI.
;Exceptions:
; DiskIOError if error during RTM file reading.
;******************************************************************************
;***
; LoadULCode - load the user lib code into high memory (UL Only)
;
;Purpose:
; Added as part of revision [10].
; Compute the size of the user library code. Allocate
; memory from DOS as high as possible.
; Read the code sections of the user lib
; into their appropriate locations in memory.
;Entry:
; BX - handle of opened RTM file.
;Exit:
; Block at segment RtmCodeSeg has UL code with no fixups.
; RtmCodeSize has paragraph size of UL code.
;Uses:
; AX, CX, DX, SI, DI, BP.
;Exceptions:
; Memory error if memory could not be allocated.
; DiskIOError if error during RTM file reading.
;******************************************************************************
;***
;ReloadULCode - Load/Reload UL code into allocated space (UL only)
;
;Purpose:
; Added as part of revision [10].
; Loads/Reloads user library code into allocated block.
;Entry:
; BP - segment to load code into.
; DX - paragraph size of code to load.
;Exit:
; The unfixed up code is loaded into the specified location.
;Uses:
; AX, CX, DX, SI, DI, ES
;Exceptions:
; None.
;****
;***
; LoadULSymbols - load the user lib symbol table into high memory (UL Only)
;
;Purpose:
; Added as part of revision [10].
; Compute the size of the user library symbol table.
; Allocate memory from DOS as high as possible.
; Read the symbol table of the user lib into memory.
;Entry:
; BX - handle of opened RTM file.
;Exit:
; Block at segment ULSymSeg has UL symbol table with no fixups.
; ULSymSize has byte size of symbol table.
;Uses:
; AX, CX, DX, SI, DI, BP.
;Exceptions:
; Memory error if memory could not be allocated.
; DiskIOError if error during RTM file reading.
;******************************************************************************
;***
; ULUpcaseSymbols - convert all symbol table names to upper case (UL only)
;
;Purpose:
; Added as part of revision [10].
; Converts all symbol table names to uppercase to simplify
; and speedup symbol table lookup routines.
;Entry:
; BP - segment of symbol table
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -