3 TITLE MODE COMMAND
- MAIN PROCEDURE
AND COMMAND PARSING
10 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P R O L O G ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
13 ; AC001 - P3976: Need to have all pieces of messages in MODE.SKL so have to
14 ; implement the SYSGETMSG method of getting addressability to
15 ; the pieces. This means that the code does a SYSGETMSG call
16 ; which returns a pointer (DS:SI) to the message piece. The
17 ; address is then put in the sublist block for the message
20 ; AN002 - P4011: Need to close all open handles before terminating and staying
21 ; resident so don't eat into the total available handles for the
24 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P R O L O G ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
31 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ E Q U A T E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
35 STDIN EQU
0 ;AN002;handle for standard input device
36 STDPRN EQU
4 ;AN002;handle for standard printer device
37 TERMINATE EQU 4
CH ;INT 21 "TERMINATE RETURNING CODE" FUNCTION
38 terminate_and_stay_resident EQU 31H
;INT 21 "terminate and remain resident"
42 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ E Q U A T E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
45 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ S T R U C T U R E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
50 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ S T R U C T U R E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
54 PRINTF_CODE
SEGMENT PUBLIC
55 ASSUME
CS:PRINTF_CODE
,DS:PRINTF_CODE
,SS:PRINTF_CODE
58 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P U B L I C S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
67 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P U B L I C S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
70 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ E X T R N S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
73 EXTRN analyze_and_invoke
:NEAR
74 EXTRN get_machine_type
:NEAR ;get model and sub-model bytes
75 EXTRN initialize_sublists
:NEAR ;see display.asm
76 EXTRN move_destination
:ABS
;location of res code after it has been moved
78 EXTRN parse_parameters
:NEAR
80 EXTRN rescode_length
:ABS
;length in paragraphs of the resident code
81 EXTRN stay_resident
:BYTE ;boolean indicating just loaded resident code see 'rescode'
84 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ E X T R N S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
87 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ D A T A ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
91 DB "The MODE command "
92 DB "--------------------------------------------------------------"
95 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ D A T A ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
97 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P R O C E D U R E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
100 close_handles PROC
NEAR ;AN002;close all standard device handles
104 .FOR
BX = STDIN TO STDPRN
;AN002;
110 close_handles ENDP
;AN002;
113 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P R O C E D U R E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
117 ;-------------------------------------------------------------------------------
119 MSG_SERVICES
<MSGDATA
> ;define message service data area
121 MSG_SERVICES
<LOADmsg
,GETmsg
,DISPLAYmsg
,CHARmsg
,NUMmsg
,INPUTmsg
> ;AC001;
122 MSG_SERVICES
<mode
.cla
,mode
.clb
,mode
.cl1
,mode
.cl2
> ;class B is for messages > 30
123 ;;RPS MSG_SERVICES <mode.cl1,mode.cl2>
128 CALL SYSLOADMSG
;load the message text
129 .IF NC THEN
;IF messages loaded successfully THEN
130 CALL get_machine_type
131 CALL initialize_sublists
132 CALL parse_parameters
133 .IF <noerror
EQ truu
> THEN
;no problems parsing so continue
134 CALL analyze_and_invoke
;semantically analyze the parms and invoke appropriate routine
137 MOV AH,TERMINATE
;assume won't stay resident
138 .IF <noerror
EQ false
> THEN
139 MOV AL,1 ;had a problem somewhere
141 .IF <stay_resident
EQ truu
> THEN
142 CALL close_handles
;close all standard devices;AN002;
143 MOV DX,move_destination
144 MOV CL,4 ;4 right shifts = divide by 16
145 SAR DX,CL ;DX=offset of start of resident code in paragraphs
146 ;SET END OF RESIDENT CODE FOR "terminate and remain resident"
148 ADD DX,rescode_length
;BYTE OF PROGRAM segment PREFIX
149 MOV AH,terminate_and_stay_resident
151 MOV AL,0 ;all went well
155 CALL SYSDISPMSG
;display some "I'm crashing" message
160 INT 21H
;TERMINATE RETURNING ERRORLEVEL INDICATING success