]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/MODE/MAIN.ASM

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / CMD / MODE / MAIN.ASM
1 ;\em
2 PAGE ,132 ;\ f
3 TITLE MODE COMMAND - MAIN PROCEDURE AND COMMAND PARSING
4 .XLIST
5 INCLUDE STRUC.INC
6 .LIST
7 ;.SALL
8
9
10 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P R O L O G ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
11 ;º º
12
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
18 ; being issued.
19
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
22 ; system.
23 ;º º
24 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P R O L O G ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
25
26 INCLUDE SYSMSG.INC
27
28 MSG_UTILNAME <MODE>
29
30
31 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ E Q U A T E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
32 ;º º
33
34 false EQU 00H
35 STDIN EQU 0 ;AN002;handle for standard input device
36 STDPRN EQU 4 ;AN002;handle for standard printer device
37 TERMINATE EQU 4CH ;INT 21 "TERMINATE RETURNING CODE" FUNCTION
38 terminate_and_stay_resident EQU 31H ;INT 21 "terminate and remain resident"
39 truu EQU 0FFH
40
41 ;º º
42 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ E Q U A T E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
43
44
45 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ S T R U C T U R E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
46 ;º º
47
48
49 ;º º
50 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ S T R U C T U R E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
51
52
53 PAGE
54 PRINTF_CODE SEGMENT PUBLIC
55 ASSUME CS:PRINTF_CODE,DS:PRINTF_CODE,SS:PRINTF_CODE
56
57
58 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P U B L I C S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
59 ;º º
60
61 PUBLIC main
62 PUBLIC SYSDISPMSG
63 PUBLIC SYSGETMSG
64
65
66 ;º º
67 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P U B L I C S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
68
69
70 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ E X T R N S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
71 ;º º
72
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
77 EXTRN noerror:BYTE
78 EXTRN parse_parameters:NEAR
79 EXTRN PRINTF: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'
82
83 ;º º
84 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ E X T R N S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
85
86
87 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ D A T A ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
88 ;º º
89
90
91 DB "The MODE command "
92 DB "--------------------------------------------------------------"
93
94 ;º º
95 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ D A T A ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
96
97 ;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P R O C E D U R E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
98 ;º º
99
100 close_handles PROC NEAR ;AN002;close all standard device handles
101 ;AN002;
102 MOV AH,3EH ;AN002;
103 ;AN002;
104 .FOR BX = STDIN TO STDPRN ;AN002;
105 INT 21H ;AN002;
106 .NEXT BX ;AN002;
107 ;AN002;
108 RET ;AN002;
109 ;AN002;
110 close_handles ENDP ;AN002;
111
112 ;º º
113 ;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ P R O C E D U R E S ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
114
115
116 ;\f
117 ;-------------------------------------------------------------------------------
118
119 MSG_SERVICES <MSGDATA> ;define message service data area
120
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>
124
125
126 main PROC NEAR
127
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
135 .ENDIF
136
137 MOV AH,TERMINATE ;assume won't stay resident
138 .IF <noerror EQ false> THEN
139 MOV AL,1 ;had a problem somewhere
140 .ELSE
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"
147 ;TO first usable
148 ADD DX,rescode_length ;BYTE OF PROGRAM segment PREFIX
149 MOV AH,terminate_and_stay_resident
150 .ENDIF
151 MOV AL,0 ;all went well
152 .ENDIF
153 .ELSE ;ABORT
154
155 CALL SYSDISPMSG ;display some "I'm crashing" message
156
157 .ENDIF
158
159
160 INT 21H ;TERMINATE RETURNING ERRORLEVEL INDICATING success
161 RET
162
163 include msgdcl.inc
164
165 main ENDP
166
167 PRINTF_CODE ENDS
168 END