1 ;;****************************************************************************
2 ;; Assembler MACROS for use with SELECT.
4 ;; Latest Change Date: August 04, 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 ;;****************************************************************************
19 ;;************************************************************************
21 ;; CLOSE_FILE: Close File
23 ;; SYNTAX: CLOSE_FILE handle
25 ;; INPUT: handle = The handle of the file to close.
27 ;; OUTPUT: CY = 0, AX = undefined, successful
28 ;; CY = 1, AX = error code
32 ;; THIS MACROS CLOSES THE FILE WITH THE GIVEN FILE HANDLE.
33 ;; IT MAKES USE OF INT 21 (AH=3EH).
34 ;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
37 ;;**************************************************************************
38 CLOSE_FILE MACRO HANDLE ;;AN000;
40 MOV BX, HANDLE ;;AN000;
41 CALL FAR PTR CLOSE_FILE_ROUTINE ;;AN000;
43 ;;**************************************************************
45 ;; CREATE_FILE: Create new File
47 ;; SYNTAX: CREATE_FILE name_file, immed_attr, var_handle
49 ;; INPUT: name_file - filename in ASCII-N string format.
50 ;; immed_attr - file attribute
52 ;; OUTPUT: CY = 0 Success: var_handle contain the file handle
53 ;; CY = 1 Error: AX contains as error code
58 ;; CREATE_FILE CREATES A FILE WITH THE GIVEN NAME USING INT 21H (AH=5BH)
59 ;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
62 ;;**************************************************************************
63 CREATE_FILE MACRO NAME_FILE, IMMED_ATTR, VAR_HANDLE ;;AN000;
64 LEA DI, NAME_FILE ;;AN000;
65 MOV CX, IMMED_ATTR ;;AN000;
66 CALL CREATE_FILE_ROUTINE ;;AN000;
67 MOV VAR_HANDLE, AX ;;AN000;
69 ;;****************************************************************************
71 ;; ERASE_FILE: Erase File
73 ;; SYNTAX: ERASE_FILE filename
75 ;; INPUT: filename = POINTER TO ASCII-N STRING - FILE NAME
77 ;; OUTPUT: CY = 0, AX = undefined, successful
78 ;; CY = 1, AX = error code
82 ;; ERASE_FILE ERASES THE FILE USING INT 21H (AH=41H).
83 ;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
86 ;;****************************************************************************
87 ERASE_FILE MACRO FILE_NAME ;;AN000;
89 LEA DI, FILE_NAME ;;AN000;
90 CALL ERASE_FILE_ROUTINE ;;AN000;
92 ;;****************************************************************************
94 ;; CHMOD_FILE: Change file attributes to read/write
96 ;; SYNTAX: CHMOD_FILE filename
98 ;; INPUT: filename = POINTER TO ASCII-N STRING - FILE NAME
103 ;; The CHMOD dos call is executed (43H) to change the file's attributes
106 ;;****************************************************************************
107 CHMOD_FILE MACRO FILE_NAME ;;AN000;
109 LEA DI, FILE_NAME ;;AN000;
110 CALL CHMOD_FILE_ROUTINE ;;AN000;
112 ;;************************************************************************
113 ;; FIND_FILE: Find File
115 ;; SYNTAX: FIND_FILE name, attribute
117 ;; INPUT: name = POINTER TO ASCII-N STRING - FILE NAME
118 ;; attribute - the file attribute used in the search
120 ;; OUTPUT: CY = 0, AX = undefined, successful
121 ;; CY = 1, AX = error code
125 ;; FINDFILE FINDS THE FIRST FILENAME SPECIFIED USING INT 21 (AH=4EH).
126 ;; AND LOADS INFORMATION INTO THE CURRENT DTA.
127 ;; NOTE : THE DEFAULT DTA IS AT 80H IN THE PSP.
128 ;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
129 ;; IS RETURNED IN AX.
131 ;;************************************************************************
132 FIND_FILE MACRO LOC_FILE,ATTRIBUTE ;;AN000;
134 LEA DI, LOC_FILE ;;AN000;
135 MOV CX, ATTRIBUTE ;;AN000;
136 CALL FIND_FILE_ROUTINE ;;AN000;
138 ;;************************************************************************
139 ;; FIND_NEXT: Find the next match in the directory.
146 ;; OUTPUT: CY = 0, AX = undefined, successful
147 ;; CY = 1, AX = error code
149 ;; OPERATION: This macro must be called after FIND_FIRST. It searched
150 ;; the same directory as the FIND_FIRST command for the next match.
151 ;; If none is found then the carry flag is set.
152 ;; This macro uses the data in the DTA for the directory seach so
153 ;; it is important not to change the address of the current DTA.
156 ;;************************************************************************
157 FIND_NEXT MACRO LOC_FILE,ATTRIBUTE ;;AN000;
158 CALL HOOK_INT_24 ;;AN000;
159 MOV INT_24_ERROR, FALSE ;;AN000; Zero the number of critical errors
162 CALL RESTORE_INT_24 ;;AN000;
164 ;;**************************************************************************
166 ;; OPEN_FILE - Open File
168 ;; SYNTAX: OPEN_FILE file_name, mode, handle
170 ;; INPUT: file_name = POINTER TO ASCII-N STRING - FILE NAME
171 ;; mode = 0,1,2 (read,write,read/write)
172 ;; handle = POINTER TO A LOCATION TO STORE FILE HANDLE
174 ;; OUTPUT: CY = 0, AX = FILE HANDLE, successful
175 ;; CY = 1, AX = error code
179 ;; THIS MACRO OPENS A FILE FOR READ/WRITE OPERATIONS.
180 ;; IT MAKES USE OF INT 21 (AH=3DH).
181 ;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
182 ;; IS RETURNED IN AX.
184 ;;**************************************************************************
185 OPEN_FILE MACRO FILE_NAME,MODE,HANDLE ;;AN000;
187 LEA DI, FILE_NAME ;;AN000;
188 MOV AL, MODE ;;AN000;
189 CALL OPEN_FILE_ROUTINE ;;AN000;
190 MOV HANDLE, AX ;;AN000;
192 ;;**************************************************************************
194 ;; RENAME_FILE - Rename File
196 ;; SYNTAX: RENAME_FILE old_name, new_name
198 ;; INPUT: old_name = POINTER TO ASCII-N STRING -OLD FILE NAME
199 ;; new_name = POINTER TO ASCII-N STRING -NEW FILE NAME
201 ;; OUTPUT: CY = 0, AX = undefined, successful
202 ;; CY = 1, AX = error code
206 ;; THIS MACRO RENAMES A FILE GIVEN 2 NAMES.
207 ;; IT MAKES USE OF INT 21 (AH=56H).
208 ;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
209 ;; IS RETURNED IN AX.
211 ;;**************************************************************************
212 RENAME_FILE MACRO OLD_NAME,NEW_NAME ;;AN000;
214 LEA SI, OLD_NAME ;;AN000;
215 LEA DI, NEW_NAME ;;AN000;
216 CALL RENAME_FILE_ROUTINE ;;AN000;
218 ;;**************************************************************************
220 ;; READ_FILE: Transfer the specified number of bytes from a file into a
223 ;; SYNTAX: READ_FILE var_handle, buffer, immed_char, var_char
226 ;; var_handle - The handle of the file to read.
227 ;; buffer - The address of where to store the data
228 ;; immed_char - The number of characters to read
231 ;; CY = 0, Read success. var_char - number of bytes read
232 ;; CY = 1, Read error. AX contains the error code.
236 ;; THIS MACRO READS TO AN ALREADY OPENED FILE.
237 ;; IT MAKES USE OF INT 21 (AH=3FH).
238 ;; AX WILL RETURN THE NUMBER BYTES ACTUALLY WRITTEN.
240 ;;************************************************************************
241 READ_FILE MACRO VAR_HANDLE,BUFFER,IMMED_CHAR, VAR_CHAR ;;AN000;
243 MOV BX,VAR_HANDLE ;;AN000;
244 MOV DX,OFFSET BUFFER ;;AN000;
245 MOV CX,IMMED_CHAR ;;AN000;
246 CALL READ_FILE_ROUTINE ;;AN000;
248 ;;**************************************************************************
250 ;; WRITE_FILE: Transfer the specified number of bytes from a buffer into a
253 ;; SYNTAX: WRITE_FILE var_handle, buffer, immed_char, var_char
256 ;; var_handle - The handle of the file to write to.
257 ;; buffer - The address of where the data is stored.
258 ;; immed_char - The number of characters to write.
261 ;; CY = 0, Write success. var_char - number of bytes written.
262 ;; CY = 1, Write error. AX contains the error code.
266 ;; THIS MACRO WRITES TO AN ALREADY OPENED FILE.
267 ;; IT MAKES USE OF INT 21 (AH=3DH).
268 ;; AX WILL RETURN THE NUMBER BYTES ACTUALLY WRITTEN.
270 ;;************************************************************************
271 WRITE_FILE MACRO VAR_HANDLE, BUFFER, IMMED_CHAR, VAR_CHAR ;;AN000;
273 MOV BX,VAR_HANDLE ;;AN000;
274 MOV DX,OFFSET BUFFER ;;AN000;
275 MOV CX,IMMED_CHAR ;;AN000;
276 CALL WRITE_FILE_ROUTINE ;;AN000;
278 ;;**************************************************************************
280 ;; PREPARE_FILE: Prepare a file and a buffer for the construction of that
281 ;; file line by line.
283 ;; SYNTAX: PREPARE_FILE filename
286 ;; filename = The name of the file to create. (ASCII-N format)
288 ;; OUTPUT: CY = 0: No error was encountered.
289 ;; CY = 1: There was an error encountered.
291 ;; OPERATION: A attempt is made to create the file. If it fails because
292 ;; the file already exists, then the file is opened for writing.
293 ;; The user will then write to the file be calling WRITE_LINE macro. The
294 ;; data will be temperarily stored in a buffer to limit the actual number
295 ;; of writes to the file.
297 ;;**************************************************************************
298 PREPARE_FILE MACRO FILENAME ;;AN000;
300 MOV BX, OFFSET FILENAME ;;AN000; Pass the address of the filename string
301 CALL PREPARE_FILE_ROUTINE ;;AN000; Call a routine to do that actual work
303 ;;**************************************************************************
305 ;; WRITE_LINE: Write a line to the file being constructed.
307 ;; SYNTAX: WRITE_LINE line
310 ;; line = The line to write to the file. (ASCII-N format)
312 ;; OUTPUT: CY = 0: No error was encountered.
313 ;; CY = 1: An error was encountered.
315 ;; OPERATION: The line that is passed, has a CR and a LF appended to the
316 ;; end of the line. The data is then stored in a buffer. When the
317 ;; buffer is full, the data is written to the disk.
319 ;;**************************************************************************
320 WRITE_LINE MACRO LINE ;;AN000;
322 MOV BX, OFFSET LINE ;;AN000; Pass the address of the line to write
323 CALL WRITE_LINE_ROUTINE ;;AN000; Call a routine to do the actual work
325 ;;**************************************************************************
327 ;; SAVE_FILE: Empty the data in the buffer being used to create the file
328 ;; and then close the file.
330 ;; SYNTAX: SAVE_FILE file_name, error_code
333 ;; file_name = The name of the file being built. If there has been
334 ;; an error encountered, then the file will be erased.
336 ;; OUTPUT: CY = 0: No error was encountered.
337 ;; CY = 1: An error was encountered.
338 ;; ERROR_CODE will contain the code of the error which
341 ;; OPERATION: The routine will check to see if there is any data left in
342 ;; the buffer. If there is, the data is written to the file being
343 ;; created. The file is then closed. If errors were encountered at
344 ;; anytime during the create process, then the carry flag will be set
345 ;; and the error code will be returned in ERROR_CODE.
347 ;;**************************************************************************
348 SAVE_FILE MACRO FILE_NAME, ERROR_CODE ;;AN000;
350 MOV BX, OFFSET FILE_NAME ;;AN000; Get the address of the file name string
351 CALL SAVE_FILE_ROUTINE ;;AN000; Call a subroutine to do the actual work
352 MOV ERROR_CODE, AX ;;AN000; Store the returned error code
354 ;;**************************************************************************
356 ;; CHECK_DOS_VERSION: Check DOS Version level is 4.00
358 ;; SYNTAX: CHECK_DOS_VERSION
363 ;; OUTPUT: CY = 0: Current DOS Version is 4.00
364 ;; CY = 1: Current DOS Version is other than level 4.00
366 ;; OPERATION: DOS function call 30h is performed to get the current DOS
367 ;; version number. If the DOS version is not 4.00, the carry flag is set.
369 ;;**************************************************************************
370 CHECK_DOS_VERSION MACRO ;;AN000;
371 MOV AH, 30H ;;AN000; DOS function number to perform
373 .IF < AL EQ MAJOR_VERSION > AND ;;AC047;SEH check is now made in VERSIONA.INC
374 .IF < AH EQ MINOR_VERSION > ;;AC047;SEH Check the DOS minor version
375 CLC ;;AN000; This is the correct version
377 STC ;;AN000; This is the incorrect version
380 ;;**************************************************************************
382 ;; SET_DISPLAY_MODE: Set the display mode to 80 column.
384 ;; SYNTAX: SET_DISPLAY_MODE
392 ;; OPERATION: The Video Interrupt (INT 10H, AH = 0) is performed to set
393 ;; the display to 80 column mode.
395 ;;************************************************************************
396 SET_DISPLAY_MODE MACRO ;;AN000;
398 CALL SET_DISPLAY_MODE_ROUTINE ;;AN000;
401 ;;************************************************************************
403 ;; CHECK_EXPANDED_MEMORY: Check if the system supports expanded memory.
405 ;; SYNTAX: CHECK_EXPANDED_MEMORY var_xma
411 ;; var_xma = 0: Expanded memory is NOT supported.
412 ;; = 1: Expanded memory is supported.
413 ;; var_mod80 = 0: Not model 80
416 ;; OPERATION: A call to the system services (INT 15H, AH = C0H) is performed
417 ;; to get the system configuration parameters. (model byte).
419 ;; The Personal System/2 Model 80 (model byte = 0F8h) always support
422 ;; The Personal System/2 Models 50 and 60 (model byte = 0FCh) support
423 ;; expanded memory if the ??? 2 is present. The ??? 2 card has
424 ;; the identity number of F7FEh. F7H is read through the port address
425 ;; 101h and FEH is read through port 100H
427 ;; All other models do not support expanded memory.
429 ;;************************************************************************
430 CHECK_EXPANDED_MEMORY MACRO VAR_XMA, VAR_MOD80 ;;AC000;JW
432 CALL CHK_EX_MEM_ROUTINE ;;AN000;
433 MOV VAR_XMA, SI ;;AN000;
434 MOV VAR_MOD80,BX ;;AN000;JW
437 INCLUDE MACROS3.INC ;;AN000;