1 ;;****************************************************************************
2 ;; Assembler MACROS for use with SELECT.
4 ;; Latest Change Date: July 28, 1987
6 ;; These macros define powerful assembler verbs neccessary for SELECT.
8 ;; Note: Many of the macros make use of an ASCII-N string for passing
9 ;; parameters. The string is defined below.
11 ;; DB "string_variable",?
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.
17 ;;****************************************************************************
18 ;;****************************************************************************
19 ;; Macro Change History.
21 ;; June 18, 1987 - Split MACROS.INC into 5 smaller files. They are:
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
33 ;; - Removed the PUSHH and POPP macros from the other macro
36 ;; June 22, 1987 - Added the SCAN_PARAMETERS macro.
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.
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
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.
54 ;;****************************************************************************
56 INCLUDE MAC_EQU.INC ;AN000;
57 ;;****************************************************************************
59 ;; PUSHH: pushes the listed registers on the stack
61 ;; SYNTAX: PUSHH <register list>
63 ;; INPUT: register list = AX, BX, CX, DX, SI, DI, BP, SS, SP, CS, DS, ES
69 ;; PUSHH ALLOWS THE PROGRAMER TO SPECIFY A LIST OF REGISTER TO
70 ;; BE PUSHED ON A SINGLE LINE.
72 ;;****************************************************************************
73 PUSHH MACRO REG_LIST ;;AN000;
74 IRP REG,<REG_LIST> ;;AN000;
75 PUSH REG ;;AN000; save registers
78 ;;****************************************************************************
80 ;; POPP: pops the listed registers on the stack
82 ;; SYNTAX: POPP <register list>
84 ;; INPUT: register list = AX, BX, CX, DX, SI, DI, BP, SS, SP, CS, DS, ES
90 ;; POPP ALLOWS THE PROGRAMER TO SPECIFY A LIST OF REGISTER TO
91 ;; BE POPPED ON A SINGLE LINE.
93 ;;****************************************************************************
94 POPP MACRO REG_LIST ;;AN000;
95 IRP REG,<REG_LIST> ;;AN000;
96 POP REG ;;AN000; return registers to initial state
99 ;;****************************************************************************
101 ;; DOSCALL: DOS interrupt 21 function call
111 ;; DOSCALL INVOKES THE DOS INTERRUPT 21 FUNCTION CALL.
112 ;; THE AH REGISTER MUST ALREADY BE LOADED WITH THE
115 ;;****************************************************************************
116 DOSCALL MACRO ;;AN000;
117 INT 21H ;;AN000; call to DOS
119 ;;****************************************************************************
121 ;; INIT_VAR: Load a variable with an immediate value.
123 ;; SYNTAX: INIT_VAR variable, expression
125 ;; INPUT: variable = Address of a variable.
126 ;; expression = The immediate value to load into the variable.
131 ;; OPERATION: The memory variable identified by var is assigned the
132 ;; immediate value specified in immed.
134 ;;****************************************************************************
135 INIT_VAR MACRO VARIABLE,EXPRESSION ;;AN000;
136 MOV VARIABLE,EXPRESSION ;;AN000; move expression into variable
138 ;;****************************************************************************
140 ;; COPY_WORD: Copy a word variable to another word variable.
142 ;; SYNTAX: COPY_WORD var_dest, var_src
144 ;; INPUT: var_dest - The destination word variable.
145 ;; var_src - The source word variable.
149 ;; OPERATION: The contents of var_src remain intact.
150 ;; The contents of AX is destroyed.
152 ;;************************************************************************
153 COPY_WORD MACRO VAR_DEST, VAR_SRC ;;AN000;
154 MOV AX, VAR_SRC ;;AN000;
155 MOV VAR_DEST,AX ;;AN000;
157 ;;****************************************************************************
159 ;; COPY_BYTE: Copy a byte variable to another byte variable.
161 ;; SYNTAX: COPY_WORD var_dest, var_src
163 ;; INPUT: var_dest - The destination byte variable.
164 ;; var_src - The source byte variable.
168 ;; OPERATION: The contents of var_src remain intact.
169 ;; The contents of AL is destroyed.
171 ;;************************************************************************
172 COPY_BYTE MACRO VAR_DEST, VAR_SRC ;;AN000;
173 MOV AL, VAR_SRC ;;AN000;
174 MOV VAR_DEST,AL ;;AN000;
176 ;;****************************************************************************
178 ;; COMP_WORDS: Compare two 16 bit memory variable.
180 ;; SYNTAX: COMP_WORDS var_dest, var_src
182 ;; INPUT: var_dest - The destination memory variable (16 bits)
183 ;; var_src - The source memory variable (16 bits)
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.
190 ;;************************************************************************
191 COMP_WORDS MACRO VAR_DEST, VAR_SRC ;;AN000;
193 MOV AX, VAR_DEST ;;AN000;
194 CMP AX, VAR_SRC ;;AN000;
196 ;;****************************************************************************
198 ;; COMP_BYTES: Compare two 8 bit memory variables.
200 ;; SYNTAX: COMP_BYTES var_dest, var_src
202 ;; INPUT: var_dest - The destination memory variable ( 8 bits)
203 ;; var_src - The source memory variable ( 8 bits)
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.
210 ;;************************************************************************
211 COMP_BYTES MACRO VAR_DEST, VAR_SRC ;;AN000;
213 MOV AL, VAR_DEST ;;AN000;
214 CMP AL, VAR_SRC ;;AN000;
216 ;;****************************************************************************
218 ;; INC_VAR: Increment the specified memory variable by 1.
220 ;; SYNTAX: INC_VAR var_dest
222 ;; INPUT: var_dest - The destination memory variable.
226 ;; OPERATION: The memory variable is incremented by one.
228 ;;************************************************************************
229 INC_VAR MACRO VAR_DEST ;;AN000;
230 INC VAR_DEST ;;AN000;
232 ;;****************************************************************************
234 ;; DEC_VAR: Decrement the specified memory variable by 1.
236 ;; SYNTAX: DEC_VAR var_dest
238 ;; INPUT: var_dest - The destination memory variable.
242 ;; OPERATION: The memory variable is decremented by one.
244 ;;************************************************************************
245 DEC_VAR MACRO VAR_DEST ;;AN000;
246 DEC VAR_DEST ;;AN000;
248 ;;****************************************************************************
250 ;; INIT: initializes the DS to the beginning of the data
260 ;; THE MACRO SIMPLY SETS UP THE DATA SEGMENT.
262 ;;****************************************************************************
265 XOR AX,AX ;;AN000; make AX = 0
268 MOV DS,AX ;;AN000; initialize DS reg to beginning of data
270 ;;**************************************************************************
272 ;; MERGE_STRING: merges 2 string blocks together to form a third one
274 ;; SYNTAX: MERGE_STRING name_dest, immed_max, name_src1, name_src2
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)
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.
293 ;;**************************************************************************************
294 MERGE_STRING MACRO NAME_DEST, IMMED_MAX, NAME_SRC1, NAME_SRC2 ;;AN000;
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;
305 ;;**************************************************************************
307 ;; APPEND_STRING: Appends an ASCII-N string to the specified string.
309 ;; SYNTAX: APPEND_STRING name_dest, immed_max, name_src
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)
319 ;; The ASCII-N string text defined in name_scr is appended to the
322 ;;**************************************************************************************
323 APPEND_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;
329 ;;**************************************************************************
331 ;; COPY_STRING: Copy ASCII-N string text.
333 ;; SYNTAX: MOVE_STRING name_dest, immed_max, name_src
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)
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.
346 ;;**************************************************************************
347 COPY_STRING MACRO NAME_DEST, IMMED_MAX, NAME_SRC ;;AN000;
349 LEA DI, NAME_DEST ;;AN000;
350 LEA SI, NAME_SRC ;;AN000;
351 MOV AX, IMMED_MAX ;;AN000;
352 CALL COPY_ROUTINE ;;AN000;
354 ;;**************************************************************************
356 ;; PUSH_HEADING: Push screen label address to the SELECT stack
358 ;; SYNTAX: PUSH_HEADING immed_lab
361 ;; immed_lab - screen label
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
371 ;;****************************************************************************
372 PUSH_HEADING MACRO IMMED_LAB ;;AN000;
373 MOV AX, OFFSET IMMED_LAB ;;AN000;
374 CALL PUSH_ROUTINE ;;AN000;
376 ;;**************************************************************************
378 ;; POP_HEADING: Pop screen label address from the SELECT stack and jump
379 ;; to the label address.
381 ;; SYNTAX: POP_HEADING
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.
394 ;;****************************************************************************
395 POP_HEADING MACRO ;;AN000;
396 CALL POP_ROUTINE ;;AN000;
399 ;;****************************************************************************
401 ;; DIR: get current directory
403 ;; SYNTAX: DIR dir_buffer
405 ;; INPUT: dir_buffer = POINTER TO A 64-BYTE USER MEMORY AREA
407 ;; OUTPUT: CY = 0, AX = N/A, successful
408 ;; CY = 1, AX = error code
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.
419 ;;****************************************************************************
420 DIR 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
426 CALL RESTORE_INT_24 ;;AN000;
428 ;;****************************************************************************
430 ;; MAKE_DIR: Make a Directory
432 ;; SYNTAX: MAKE_DIR directory
434 ;; INPUT: directory = An ASCII-N STRING GIVING THE REQUIRED
436 ;; OUTPUT: CY = 0, AX = undefined, call was successful
437 ;; CY = 1, AX = error code
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.
446 ;;****************************************************************************
447 MAKE_DIR MACRO dir_len ;;AN000;
448 CALL HOOK_INT_24 ;;AN000;
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;
457 ;;**************************************************************************
459 ;; MAKE_DIR_PATHS: Create the specified directory including all the specified
460 ;; sub-directories if they do not exist.
462 ;; SYNTAX: MAKE_DIR_PATHS name_dir
465 ;; name_dir - Directory pathname in ASCII-N string format.
469 ;; CY = 1 Error - AX will contain an error code.
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.
477 ;;****************************************************************************
478 MAKE_DIR_PATHS MACRO NAME_DIR ;;AN000;
480 MOV BX, OFFSET NAME_DIR ;;AN000; Address of the ASCII-N string
481 CALL MAKE_DIR_PATHS_ROUTINE ;;AN000;
483 ;;****************************************************************************
485 ;; REMOVE_DIR: Remove Directory
487 ;; SYNTAX: REMOVE_DIR directory
489 ;; INPUT: directory = An ASCII-N STRING giving the REQUIRED PATH
491 ;; OUTPUT: CY = 0, AX = undefined, successful
492 ;; CY = 1, AX = error code
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.
500 ;; It is assumed that the string is located in the data segment
502 ;;****************************************************************************
503 REMOVE_DIR MACRO dir_len ;;AN000;
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;
513 ;;**************************************************************************
515 ;; CHANGE_DIR: Change the current directory to the specified directory.
517 ;; SYNTAX: CHANGE_DIR name_dir
520 ;; name_dir - directory pathname in ASCII-N string format.
524 ;; CY = 1 Error AX will contain an error code
526 ;; OPERATION: The directory pathname identified by the ASCII-N string
527 ;; becomes the default directory.
529 ;;****************************************************************************
530 CHANGE_DIR MACRO NAME_DIR ;;AN000;
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
538 CALL RESTORE_INT_24 ;;AN000;
540 INCLUDE MACROS2.INC ;;AN000;