summaryrefslogtreecommitdiff
path: root/v4.0/src/SELECT/MACROS.INC
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/SELECT/MACROS.INC')
-rw-r--r--v4.0/src/SELECT/MACROS.INC540
1 files changed, 540 insertions, 0 deletions
diff --git a/v4.0/src/SELECT/MACROS.INC b/v4.0/src/SELECT/MACROS.INC
new file mode 100644
index 0000000..a942878
--- /dev/null
+++ b/v4.0/src/SELECT/MACROS.INC
@@ -0,0 +1,540 @@
1;;****************************************************************************
2;; Assembler MACROS for use with SELECT.
3;; File: MACROS.INC
4;; Latest Change Date: July 28, 1987
5;;
6;; These macros define powerful assembler verbs neccessary for SELECT.
7;;
8;; Note: Many of the macros make use of an ASCII-N string for passing
9;; parameters. The string is defined below.
10;; DW count
11;; DB "string_variable",?
12;;
13;; COUNT is the length of the string and is a word.
14;; It is necessary to follow the string with at least one byte for the
15;; purpose of changing the ASCII-N string to an ASCII-Z string.
16;;
17;;****************************************************************************
18;;****************************************************************************
19;; Macro Change History.
20;;
21;; June 18, 1987 - Split MACROS.INC into 5 smaller files. They are:
22;; MACROS.INC
23;; MACROS2.INC
24;; MACROS3.INC
25;; MACROS4.INC
26;; MACROS5.INC
27;; At the end of the files, there is an INCLUDE statement
28;; to include the next file. Therefore, the modules which
29;; use these macros do not have to add more include statements.
30;; The only one that must have an INCLUDE statement is
31;; MACROS.INC.
32;;
33;; - Removed the PUSHH and POPP macros from the other macro
34;; definitions.
35;;
36;; June 22, 1987 - Added the SCAN_PARAMETERS macro.
37;;
38;; June 24, 1987 - Added the PREPARE_FILE, WRITE_LINE and SAVE_FILE macros.
39;; - Revised the SCAN_PARAMETERS macro to read two of the
40;; parameters from a file instead of the command line.
41;;
42;; June 26, 1987 - Changed the EXEC_PROGRAM macros to perform a call to
43;; EXEC_PROGRAM_ROUTINE which performs the same tasks are the
44;; previously defined macro. EXEC_PROGRAM_ROUTINE was added
45;; to ROUTINES.INC.
46;;
47;; June 29, 1987 - Changed the GET_COUNTRY_INDEX to a subroutine call to
48;; GET_CNTY_INDEX_ROUTINE. The routine has been changed
49;; to get the new information from the structure, NUM_DESIGNATES,
50;; CPSW_STAT, and RESERVED_1.
51;; - Changed GET_COUNTRY_DEFAULTS, GET_KEYBOARD_INDEX and
52;; GET_KEYBOARD macros to perform subroutines calls.
53;;
54;;****************************************************************************
55PAGE ;AN000;
56INCLUDE MAC_EQU.INC ;AN000;
57;;****************************************************************************
58;;
59;; PUSHH: pushes the listed registers on the stack
60;;
61;; SYNTAX: PUSHH <register list>
62;;
63;; INPUT: register list = AX, BX, CX, DX, SI, DI, BP, SS, SP, CS, DS, ES
64;;
65;; OUTPUT: none
66;;
67;; OPERATION:
68;;
69;; PUSHH ALLOWS THE PROGRAMER TO SPECIFY A LIST OF REGISTER TO
70;; BE PUSHED ON A SINGLE LINE.
71;;
72;;****************************************************************************
73PUSHH MACRO REG_LIST ;;AN000;
74 IRP REG,<REG_LIST> ;;AN000;
75 PUSH REG ;;AN000; save registers
76 ENDM ;;AN000;
77 ENDM ;;AN000;
78;;****************************************************************************
79;;
80;; POPP: pops the listed registers on the stack
81;;
82;; SYNTAX: POPP <register list>
83;;
84;; INPUT: register list = AX, BX, CX, DX, SI, DI, BP, SS, SP, CS, DS, ES
85;;
86;; OUTPUT: none
87;;
88;; OPERATION:
89;;
90;; POPP ALLOWS THE PROGRAMER TO SPECIFY A LIST OF REGISTER TO
91;; BE POPPED ON A SINGLE LINE.
92;;
93;;****************************************************************************
94POPP MACRO REG_LIST ;;AN000;
95 IRP REG,<REG_LIST> ;;AN000;
96 POP REG ;;AN000; return registers to initial state
97 ENDM ;;AN000;
98 ENDM ;;AN000;
99;;****************************************************************************
100;;
101;; DOSCALL: DOS interrupt 21 function call
102;;
103;; SYNTAX: DOSCALL
104;;
105;; INPUT: none
106;;
107;; OUTPUT: none
108;;
109;; OPERATION:
110;;
111;; DOSCALL INVOKES THE DOS INTERRUPT 21 FUNCTION CALL.
112;; THE AH REGISTER MUST ALREADY BE LOADED WITH THE
113;; REQUIRED VALUE.
114;;
115;;****************************************************************************
116DOSCALL MACRO ;;AN000;
117 INT 21H ;;AN000; call to DOS
118 ENDM ;;AN000;
119;;****************************************************************************
120;;
121;; INIT_VAR: Load a variable with an immediate value.
122;;
123;; SYNTAX: INIT_VAR variable, expression
124;;
125;; INPUT: variable = Address of a variable.
126;; expression = The immediate value to load into the variable.
127;;
128;; OUTPUT:
129;; None.
130;;
131;; OPERATION: The memory variable identified by var is assigned the
132;; immediate value specified in immed.
133;;
134;;****************************************************************************
135INIT_VAR MACRO VARIABLE,EXPRESSION ;;AN000;
136 MOV VARIABLE,EXPRESSION ;;AN000; move expression into variable
137 ENDM ;;AN000;
138;;****************************************************************************
139;;
140;; COPY_WORD: Copy a word variable to another word variable.
141;;
142;; SYNTAX: COPY_WORD var_dest, var_src
143;;
144;; INPUT: var_dest - The destination word variable.
145;; var_src - The source word variable.
146;;
147;; OUTPUT: none
148;;
149;; OPERATION: The contents of var_src remain intact.
150;; The contents of AX is destroyed.
151;;
152;;************************************************************************
153COPY_WORD MACRO VAR_DEST, VAR_SRC ;;AN000;
154 MOV AX, VAR_SRC ;;AN000;
155 MOV VAR_DEST,AX ;;AN000;
156 ENDM ;;AN000;
157;;****************************************************************************
158;;
159;; COPY_BYTE: Copy a byte variable to another byte variable.
160;;
161;; SYNTAX: COPY_WORD var_dest, var_src
162;;
163;; INPUT: var_dest - The destination byte variable.
164;; var_src - The source byte variable.
165;;
166;; OUTPUT: none
167;;
168;; OPERATION: The contents of var_src remain intact.
169;; The contents of AL is destroyed.
170;;
171;;************************************************************************
172COPY_BYTE MACRO VAR_DEST, VAR_SRC ;;AN000;
173 MOV AL, VAR_SRC ;;AN000;
174 MOV VAR_DEST,AL ;;AN000;
175 ENDM ;;AN000;
176;;****************************************************************************
177;;
178;; COMP_WORDS: Compare two 16 bit memory variable.
179;;
180;; SYNTAX: COMP_WORDS var_dest, var_src
181;;
182;; INPUT: var_dest - The destination memory variable (16 bits)
183;; var_src - The source memory variable (16 bits)
184;;
185;; OUTPUT: none
186;;
187;; OPERATION: The two 16 bit memory variables are compared and the status
188;; flags are updated. Refer to the ASSEMBLER reference for more details.
189;;
190;;************************************************************************
191COMP_WORDS MACRO VAR_DEST, VAR_SRC ;;AN000;
192 ;
193 MOV AX, VAR_DEST ;;AN000;
194 CMP AX, VAR_SRC ;;AN000;
195 ENDM ;;AN000;
196;;****************************************************************************
197;;
198;; COMP_BYTES: Compare two 8 bit memory variables.
199;;
200;; SYNTAX: COMP_BYTES var_dest, var_src
201;;
202;; INPUT: var_dest - The destination memory variable ( 8 bits)
203;; var_src - The source memory variable ( 8 bits)
204;;
205;; OUTPUT: none
206;;
207;; OPERATION: The two 8 bit memory variables are compared and the status
208;; flags are updated. Refer to the ASSEMBLER reference for more details.
209;;
210;;************************************************************************
211COMP_BYTES MACRO VAR_DEST, VAR_SRC ;;AN000;
212 ;
213 MOV AL, VAR_DEST ;;AN000;
214 CMP AL, VAR_SRC ;;AN000;
215 ENDM ;;AN000;
216;;****************************************************************************
217;;
218;; INC_VAR: Increment the specified memory variable by 1.
219;;
220;; SYNTAX: INC_VAR var_dest
221;;
222;; INPUT: var_dest - The destination memory variable.
223;;
224;; OUTPUT: none
225;;
226;; OPERATION: The memory variable is incremented by one.
227;;
228;;************************************************************************
229INC_VAR MACRO VAR_DEST ;;AN000;
230 INC VAR_DEST ;;AN000;
231 ENDM ;;AN000;
232;;****************************************************************************
233;;
234;; DEC_VAR: Decrement the specified memory variable by 1.
235;;
236;; SYNTAX: DEC_VAR var_dest
237;;
238;; INPUT: var_dest - The destination memory variable.
239;;
240;; OUTPUT: none
241;;
242;; OPERATION: The memory variable is decremented by one.
243;;
244;;************************************************************************
245DEC_VAR MACRO VAR_DEST ;;AN000;
246 DEC VAR_DEST ;;AN000;
247 ENDM ;;AN000;
248;;****************************************************************************
249;;
250;; INIT: initializes the DS to the beginning of the data
251;;
252;; SYNTAX: INIT
253;;
254;; INPUT: none
255;;
256;; OUTPUT: none
257;;
258;; OPERATION:
259;;
260;; THE MACRO SIMPLY SETS UP THE DATA SEGMENT.
261;;
262;;****************************************************************************
263INIT MACRO ;;AN000;
264 PUSH DS ;;AN000;
265 XOR AX,AX ;;AN000; make AX = 0
266 PUSH AX ;;AN000;
267 MOV AX,DATA ;;AN000;
268 MOV DS,AX ;;AN000; initialize DS reg to beginning of data
269 ENDM ;;AN000;
270;;**************************************************************************
271;;
272;; MERGE_STRING: merges 2 string blocks together to form a third one
273;;
274;; SYNTAX: MERGE_STRING name_dest, immed_max, name_src1, name_src2
275;;
276;; INPUT: name_dest - Destination string variable (ASCII-N format)
277;; immed_max - Maximum length of destination string
278;; name_src1 - Source string variable 1 (ASCII-N format)
279;; name_src2 - Source string variable 2 (ASCII-N format)
280;;
281;; OUTPUT:
282;; None.
283;;
284;; OPERATION:
285;; The string pointed to by name_scr1 is copied to the destination string
286;; first followed by the string pointed to by name_scr2. If the
287;; destination string is not long enough to hold the new string, then
288;; the strings are copied until all the space is used up.
289;; It is assumed that the input strings and the output string
290;; are in the current data segment.
291;;
292;;
293;;**************************************************************************************
294MERGE_STRING MACRO NAME_DEST, IMMED_MAX, NAME_SRC1, NAME_SRC2 ;;AN000;
295
296 LEA DI, NAME_DEST ;;AN000;
297 LEA SI, NAME_SRC1 ;;AN000;
298 MOV AX, IMMED_MAX ;;AN000;
299 CALL COPY_ROUTINE ;;AN000;
300 MOV CX, IMMED_MAX ;;AN000;
301 LEA DI, NAME_DEST ;;AN000;
302 LEA SI, NAME_SRC2 ;;AN000;
303 CALL APPEND_STRING_ROUTINE ;;AN000;
304 ENDM ;;AN000;
305;;**************************************************************************
306;;
307;; APPEND_STRING: Appends an ASCII-N string to the specified string.
308;;
309;; SYNTAX: APPEND_STRING name_dest, immed_max, name_src
310;;
311;; INPUT: name_dest - Destination string variable (ASCII-N format)
312;; immed_max - Maximum length of destination string
313;; name_src - Source string variable (ASCII-N format)
314;;
315;; OUTPUT:
316;; None.
317;;
318;; OPERATION:
319;; The ASCII-N string text defined in name_scr is appended to the
320;; end of name_dest.
321;;
322;;**************************************************************************************
323APPEND_STRING MACRO NAME_DEST, IMMED_MAX, NAME_SRC ;;AN000;
324 MOV CX, IMMED_MAX ;;AN000;
325 LEA DI, NAME_DEST ;;AN000;
326 LEA SI, NAME_SRC ;;AN000;
327 CALL APPEND_STRING_ROUTINE ;;AN000;
328 ENDM ;;AN000;
329;;**************************************************************************
330;;
331;; COPY_STRING: Copy ASCII-N string text.
332;;
333;; SYNTAX: MOVE_STRING name_dest, immed_max, name_src
334;;
335;; INPUT:
336;; name_dest - The destination string variable.
337;; immed_max - The maximum length of destination string.
338;; name_src - source string veriable (ASCII-N format)
339;;
340;; OUTPUT:
341;; None.
342;;
343;; OPERATION: ASCII-N string text defined in name_src is copied to name_dest.
344;; The number of characters copied to name_dest will not exceed immed_max.
345;;
346;;**************************************************************************
347COPY_STRING MACRO NAME_DEST, IMMED_MAX, NAME_SRC ;;AN000;
348 ;
349 LEA DI, NAME_DEST ;;AN000;
350 LEA SI, NAME_SRC ;;AN000;
351 MOV AX, IMMED_MAX ;;AN000;
352 CALL COPY_ROUTINE ;;AN000;
353 ENDM ;;AN000;
354;;**************************************************************************
355;;
356;; PUSH_HEADING: Push screen label address to the SELECT stack
357;;
358;; SYNTAX: PUSH_HEADING immed_lab
359;;
360;; INPUT:
361;; immed_lab - screen label
362;;
363;; OUTPUT:
364;; None.
365;;
366;; OPERATION: The screen label address is pushed onto the SELECT stack
367;; provided the numher of entries on the stack will not exceed the
368;; maximum. Error will NOT be generated if the function was not
369;; successful.
370;;
371;;****************************************************************************
372PUSH_HEADING MACRO IMMED_LAB ;;AN000;
373 MOV AX, OFFSET IMMED_LAB ;;AN000;
374 CALL PUSH_ROUTINE ;;AN000;
375 ENDM ;;AN000;
376;;**************************************************************************
377;;
378;; POP_HEADING: Pop screen label address from the SELECT stack and jump
379;; to the label address.
380;;
381;; SYNTAX: POP_HEADING
382;;
383;; INPUT:
384;; None.
385;;
386;; OUTPUT:
387;; None.
388;;
389;; OPERATION: The screen label address from the SELECT stack is poped
390;; if the number of entries on the stack is not zero. If the number
391;; of entries is zero, the EXIT_DOS screen label address will be used.
392;; A jump to the screen label address is also performed.
393;;
394;;****************************************************************************
395POP_HEADING MACRO ;;AN000;
396 CALL POP_ROUTINE ;;AN000;
397 JMP SI ;;AN000;
398 ENDM ;;AN000;
399;;****************************************************************************
400;;
401;; DIR: get current directory
402;;
403;; SYNTAX: DIR dir_buffer
404;;
405;; INPUT: dir_buffer = POINTER TO A 64-BYTE USER MEMORY AREA
406;;
407;; OUTPUT: CY = 0, AX = N/A, successful
408;; CY = 1, AX = error code
409;;
410;; OPERATION:
411;;
412;; DIR PLACES THE FULL PATH NAME OF THE CURRENT DIRECTORY FOR THE
413;; SPECIFIED DRIVE IN THE BUFFER.
414;; THE RETURNING STRING IS AN ASCIIZ STRING AND IT DOES NOT
415;; HAVE THE DRIVE LETTER OR A BACKSLASH.
416;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
417;; IS RETURNED IN AX.
418;;
419;;****************************************************************************
420DIR MACRO DIR_BUFFER ;;AN000;
421 CALL HOOK_INT_24 ;;AN000;
422 MOV SI,OFFSET DIR_BUFFER ;;AN000; pointer to 64 byte user area
423 MOV DL,0 ;;AN000; give directory of the default drive
424 MOV AH,47H ;;AN000; get current directory
425 DOSCALL ;;AN000;
426 CALL RESTORE_INT_24 ;;AN000;
427 ENDM ;;AN000;
428;;****************************************************************************
429;;
430;; MAKE_DIR: Make a Directory
431;;
432;; SYNTAX: MAKE_DIR directory
433;;
434;; INPUT: directory = An ASCII-N STRING GIVING THE REQUIRED
435;; PATH
436;; OUTPUT: CY = 0, AX = undefined, call was successful
437;; CY = 1, AX = error code
438;;
439;; OPERATION:
440;;
441;; THE DIRECTORY IS MADE USING THE DOS INT 21H (AH=39H) CALL.
442;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
443;; IS RETURNED IN AX.
444;;
445;;
446;;****************************************************************************
447MAKE_DIR MACRO dir_len ;;AN000;
448 CALL HOOK_INT_24 ;;AN000;
449
450 MOV DI,OFFSET dir_len ;;AN000;
451 CALL POS_ZERO ;;AN000; position the '0' at the end of the path
452 MOV DX,OFFSET dir_len[2] ;;AN000; advance pointer to beginning of path
453 MOV AH,39H ;;AN000; make directory interrupt
454 DOSCALL ;;AN000; call to DOS interrupt 21
455 CALL RESTORE_INT_24 ;;AN000;
456 ENDM ;;AN000;
457;;**************************************************************************
458;;
459;; MAKE_DIR_PATHS: Create the specified directory including all the specified
460;; sub-directories if they do not exist.
461;;
462;; SYNTAX: MAKE_DIR_PATHS name_dir
463;;
464;; INPUT:
465;; name_dir - Directory pathname in ASCII-N string format.
466;;
467;; OUTPUT:
468;; CY = 0 Success
469;; CY = 1 Error - AX will contain an error code.
470;;
471;; OPERATION: The directory pathname is created.
472;; If the drive letter and colon are not followed by a '\', then the
473;; macro will start creating the directories from the default directory.
474;; If they are followed by a '\', then the macro will start at the root.
475;;
476;;
477;;****************************************************************************
478MAKE_DIR_PATHS MACRO NAME_DIR ;;AN000;
479
480 MOV BX, OFFSET NAME_DIR ;;AN000; Address of the ASCII-N string
481 CALL MAKE_DIR_PATHS_ROUTINE ;;AN000;
482 ENDM ;;AN000;
483;;****************************************************************************
484;;
485;; REMOVE_DIR: Remove Directory
486;;
487;; SYNTAX: REMOVE_DIR directory
488;;
489;; INPUT: directory = An ASCII-N STRING giving the REQUIRED PATH
490;;
491;; OUTPUT: CY = 0, AX = undefined, successful
492;; CY = 1, AX = error code
493;;
494;; OPERATION:
495;;
496;; THE DIRECTORY IS REMOVED USING THE DOS INT 21H (AH=3AH) CALL.
497;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
498;; IS RETURNED IN AX.
499;;
500;; It is assumed that the string is located in the data segment
501;;
502;;****************************************************************************
503REMOVE_DIR MACRO dir_len ;;AN000;
504
505 CALL HOOK_INT_24 ;;AN000;
506 MOV DI,OFFSET dir_len ;;AN000;
507 CALL POS_ZERO ;;AN000; position the '0' at the end of the path
508 MOV DX,OFFSET dir_len[2] ;;AN000; advance pointer to beginning of path
509 MOV AH,3AH ;;AN000; remove the specified directory
510 DOSCALL ;;AN000; call to DOS interrupt 21
511 CALL RESTORE_INT_24 ;;AN000;
512 ENDM ;;AN000;
513;;**************************************************************************
514;;
515;; CHANGE_DIR: Change the current directory to the specified directory.
516;;
517;; SYNTAX: CHANGE_DIR name_dir
518;;
519;; INPUT:
520;; name_dir - directory pathname in ASCII-N string format.
521;;
522;; OUTPUT:
523;; CY = 0 Success
524;; CY = 1 Error AX will contain an error code
525;;
526;; OPERATION: The directory pathname identified by the ASCII-N string
527;; becomes the default directory.
528;;
529;;****************************************************************************
530CHANGE_DIR MACRO NAME_DIR ;;AN000;
531
532 CALL HOOK_INT_24 ;;AN000;
533 MOV DI,OFFSET NAME_DIR ;;AN000; Get the offset of the string
534 CALL POS_ZERO ;;AN000; Make into an ASCII-Z string
535 MOV DX,OFFSET NAME_DIR+2 ;;AN000; Get the start of the string
536 MOV AH,3BH ;;AN000; DOS function call number
537 DOSCALL ;;AN000;
538 CALL RESTORE_INT_24 ;;AN000;
539 ENDM ;;AN000;
540INCLUDE MACROS2.INC ;;AN000;