]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/SELECT/MACROS5.INC

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / SELECT / MACROS5.INC
1 ;;****************************************************************************
2 ;; Assembler MACROS for use with SELECT.
3 ;; File: MACROS5.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 page ;;AN000;
19 ;;************************************************************************;;
20 ;;
21 ;; GET_COUNTRY_DEFAULTS: Get country, keyboard and codepage for the
22 ;; specified entry from the CTY_TABLE.
23 ;;
24 ;; SYNTAX: GET_COUNTRY_DEFAULTS VAR_TABLE, VAR_INDEX
25 ;;
26 ;; INPUT:
27 ;; VAR_TABLE = 1: Use CTY_TAB_A
28 ;; = 2: Use CTY_TAB_B
29 ;; VAR_INDEX = index into country list table
30 ;;
31 ;; OUTPUT:
32 ;; N_COUNTRY = Country code
33 ;; N_KYBD_VAL = 0: Keyboard code is not valid
34 ;; = 1: Keyboard code is valid
35 ;; S_KEYBOARD = Keyboard code (ASCII-N format)
36 ;; N_CP_PRI = Primary code page
37 ;; N_CP_SEC = Secondary code page
38 ;; N_DESIGNATES = Number of disignates
39 ;; N_CPSW = Cpsw status
40 ;; N_CTY_RES = Reserved
41 ;;
42 ;;
43 ;; OPERATION: The country code, keyboard, primary codepage and the
44 ;; seondary codepage from the CTY_TABLE for the specified index is
45 ;; returned as spedified above.
46 ;;
47 ;; Note: Index of the first item is the table is 1.
48 ;;
49 ;;****************************************************************************
50 GET_COUNTRY_DEFAULTS MACRO VAR_TABLE, VAR_INDEX ;;AN000;
51
52 MOV BX, VAR_TABLE ;;AN000; Get which table to search
53 MOV AX, VAR_INDEX ;;AN000; Get where to start in the table
54 CALL GET_CNTY_DEF_ROUTINE ;;AN000;
55 ENDM ;;AN000;
56
57 ;;************************************************************************;;
58 ;;
59 ;; GET_DOS_COUNTRY: Get current country information.
60 ;;
61 ;; SYNTAX: GET_DOS_COUNTRY buffer, var_country
62 ;;
63 ;; INPUT:
64 ;; BUFFER = 38 byte data buffer area for country information.
65 ;;
66 ;; OUTPUT:
67 ;; VAR_COUNTRY = Default country code
68 ;;
69 ;; OPERATION: DOS function call 65h (id=1) is performed to get the extended
70 ;; country information into the specified data buffer for the default
71 ;; and the active CON device. The country code value from the data buffer
72 ;; is returned in the memory variable specified.
73 ;;
74 ;;****************************************************************************
75 GET_DOS_COUNTRY MACRO BUFFER, VAR_COUNTRY ;;AN000;
76
77
78 PUSH ES ;;AN000;
79 PUSH DS ;;AN000;
80 POP ES ;;AN000;
81
82 MOV DI, OFFSET BUFFER ;;AN000; Get the address of the buffer
83 MOV AX, 6501H ;;AN000; Fn call 65h with ID value = 1
84 MOV BX, -1 ;;AN000; Code page of interest (current)
85 MOV DX, -1 ;;AN000; Get information for default country
86 MOV CX, 38 ;;AN000; Amount of data to return
87 DOSCALL ;;AN000;
88
89 MOV BX, [DI]+3 ;;AN000; Get the country ID
90 MOV VAR_COUNTRY, BX ;;AN000;
91
92 POP ES ;;AN000;
93
94 ENDM ;;AN000;
95 ;;****************************************************************************
96 ;;
97 ;; GET_COUNTRY_INDEX: Scan CTY_TABLE for the specified country code and
98 ;; return index of country code into the table.
99 ;;
100 ;; SYNTAX: GET_COUNTRY_INDEX var_country, var_tab, var_index
101 ;;
102 ;; INPUT:
103 ;; var_country = The country code
104 ;;
105 ;; OUTPUT:
106 ;; var_tab = 1: Country code is in table CTY_TAB_A
107 ;; = 2: Country code is in table CTY_TAB_B
108 ;; var_index = The index into the country list.
109 ;;
110 ;; OPERATION: The CTY_TABLE is scanned for the specified country code and
111 ;; the index into the table is returned.
112 ;;
113 ;; Note: The index of the first item in the table is 1.
114 ;;
115 ;;************************************************************************;;
116 GET_COUNTRY_INDEX MACRO VAR_COUNTRY, VAR_TAB, VAR_INDEX ;;AN000;
117
118 MOV CX, VAR_COUNTRY ;;AN000; Get the country index
119 CALL GET_CNTY_INDEX_ROUTINE ;;AN000; Search the table for this value
120 MOV VAR_TAB, DX ;;AN000; Which table it was found in
121 MOV VAR_INDEX, BX ;;AN000; Which location in that table
122 ENDM ;;AN000;
123 ;;****************************************************************************
124 ;;
125 ;; GET_KEYBOARD_INDEX: Scan KYBD_TABLE for the specified keyboard code and
126 ;; return index of keyboard code in the table and the
127 ;; alternate keyboard indicator.
128 ;;
129 ;; SYNTAX: GET_KEYBOARD_INDEX name_kybd, var_table, var_index, var_alt
130 ;;
131 ;; INPUT:
132 ;; name_kybd = The keyboard code in ASCII-N format.
133 ;;
134 ;; OUTPUT:
135 ;; var_table = 1: Keyboard is IN table KYBD_TAB_A
136 ;; = 2: Keyboard is in table KYBD_TAB_B
137 ;; var_index = The index into keyboard table.
138 ;; var_alt = 0: No alternate keyboard
139 ;; = 1: Alternate keyboard present
140 ;;
141 ;; OPERATION: The KYBD_TABLE is scanned for the specifies keyboard code and
142 ;; the index into the table is returned.
143 ;;
144 ;; Note: The index of the first item in the table is 1.
145 ;;
146 ;;************************************************************************
147 GET_KEYBOARD_INDEX MACRO NAME_KYBD, VAR_TABLE, VAR_INDEX, VAR_ALT ;;AN000;
148
149 MOV DI, OFFSET NAME_KYBD ;;AN000; The name of the keyboard to search for
150 CALL GET_KYBD_INDEX_ROUTINE ;;AN000; Search for this keyboard code
151 MOV VAR_TABLE, DX ;;AN000; Which table the code was found in
152 MOV VAR_INDEX, BX ;;AN000; Which index in the table
153 MOV VAR_ALT, AL ;;AN000; Returned alternate keyboard byte
154 ENDM ;;AN000;
155 ;;************************************************************************;;
156 ;;
157 ;; GET_KEYBOARD: Get the keyboard code and the alternate keyboard
158 ;; indicator from the KYBD_TABLE for the item specified by the index
159 ;; into the keyboard table.
160 ;;
161 ;; SYNTAX: GET_KEYBOARD var_table, var_index, name_kybd, var_alt
162 ;;
163 ;; INPUT:
164 ;; var_table = 1: Keyboard code is in table KYBD_TAB_A
165 ;; = 2: Keyboard code is is table KYBD_TAB_B
166 ;; var_index = index into the keyboard table.
167 ;;
168 ;; OUTPUT:
169 ;; name_kybd = keyboard code in ASCII-N format.
170 ;; var_alt = 0: No alternate keyboard
171 ;; = 1: Alternate keyboard present
172 ;;
173 ;; OPERATION: The keyboard code from the KYBD_TABLE for the specified
174 ;; index item is returned. Also, the alternate keyboard present
175 ;; variable is updated.
176 ;;
177 ;; Note: Index of the first item in the table is 1.
178 ;;
179 ;;****************************************************************************
180 GET_KEYBOARD MACRO VAR_TABLE, VAR_INDEX, NAME_KYBD, VAR_ALT ;;AN000;
181
182 MOV AX, VAR_INDEX ;;AN000; Where to start the search
183 MOV CX, VAR_TABLE ;;AN000; Which table to search
184 MOV DI, OFFSET NAME_KYBD ;;AN000; The name of the keyboard code returned
185 CALL GET_KYBD_ROUTINE ;;AN000;
186 MOV VAR_ALT, AL ;;AN000; Returned alternate code
187 ENDM ;;AN000;
188 ;;************************************************************************;;
189 ;;
190 ;; GET_ALT_KYBD_TABLE: Scan the ALT_KYB_TABLE for the specified keyboard,
191 ;; and return the pointer to the specified keyboards alternate keyboard
192 ;; code list.
193 ;;
194 ;; SYNTAX: GET_ALT_KYBD_TABLE name_kybd, var_table, var_kyb
195 ;;
196 ;; INPUT:
197 ;; name_kybd = Keyboard code in ASCII-N format.
198 ;;
199 ;; OUTPUT:
200 ;; var_table = Pointer to alternat keyboards list.
201 ;; var_kyb = 1: French
202 ;; = 2: Italian
203 ;; = 3: UK English
204 ;;
205 ;; OPERATION: The ALT_KYB_TABLE is scanned for the specified keyboard
206 ;; code. Pointer to a table of alternate keyboards available for the
207 ;; specified keyboard code is returned as well as the keyboard identifier.
208 ;;
209 ;;****************************************************************************
210 GET_ALT_KYBD_TABLE MACRO NAME_KYBD, VAR_TABLE, VAR_KYB ;;AN000;
211 ;;
212 MOV SI, OFFSET ALT_KYB_TAB_1 ;;AN000; Offset of the data in the table
213 MOV AL, ALT_KYB_TABLE ;;AN000; Number of entries in the table
214 MOV BX, 1 ;;AN000; Index currently being scaned
215 ;;
216 MOV DX, NAME_KYBD+2 ;;AN000;
217 .WHILE <<WORD PTR [SI]> NE DX > AND ;;AN000;
218 .WHILE < BL LE AL > ;;AN000;
219 INC BL ;;AN000;
220 ADD SI, TYPE ALT_KYB_DEF ;;AN000;
221 .ENDWHILE ;;AN000;
222 ;;
223 .IF < BL GT AL > ;;AN000; Entry NOT found
224 MOV VAR_KYB, 0 ;;AN000;
225 MOV VAR_TABLE, 0 ;;AN000; Pointer is 0 since entry not found
226 .ELSE ;;AN000;
227 COPY_WORD VAR_TABLE, [SI]+2 ;;AN000; Copy the table entries
228 COPY_BYTE VAR_KYB, [SI]+4 ;;AN000;
229 .ENDIF ;;AN000;
230 ;;
231 ENDM ;;AN000;
232 ;;************************************************************************;;
233 ;;
234 ;; GET_ALT_KEYBOARD: Get the alternate keyboard code from the specified
235 ;; alternate keyboard table for the item specified by the index.
236 ;;
237 ;; SYNTAX: GET_ALT_KEYBOARD var_table, var_kyb, var_index, name_kybd
238 ;;
239 ;; INPUT:
240 ;; var_table = Pointer to alternate keyboard table
241 ;; var_kyb = 1: French
242 ;; = 2: Italian
243 ;; = 3: UK English
244 ;; var_index = Index into the keyboard table.
245 ;;
246 ;; OUTPUT:
247 ;; name_kybd = The keyboard code in ASCII-N format.
248 ;;
249 ;; OPERATION: The keyboard code from the specified table for the
250 ;; specified index item is returned.
251 ;;
252 ;; NOTE: The index of the first item is the table is 1.
253 ;;
254 ;;****************************************************************************
255 GET_ALT_KEYBOARD MACRO VAR_TABLE, VAR_KYB, VAR_INDEX, NAME_KYBD ;;AN000;
256
257 MOV AX, VAR_INDEX ;;AN000; Get the table index
258 DEC AX ;;AN000; Make the index start at 0
259 MOV SI, VAR_TABLE ;;AN000; Pointer to the table
260 INC SI ;;AN000; Adjust pointer for table length byte
261 .IF < VAR_KYB EQ ALT_FRENCH> ;;AN000;
262 MOV CX, TYPE FR_STRUC ;;AN000;
263 .ELSEIF < VAR_KYB EQ ALT_ITALIAN > ;;AN000;
264 MOV CX, TYPE IT_STRUC ;;AN000;
265 .ELSE ;;AN000;
266 MOV CX, TYPE UK_STRUC ;;AN000;
267 .ENDIF ;;AN000;
268 MUL CX ;;AN000;
269 ADD SI, AX ;;AN000; Get the address of the required entry
270 ;;
271 PUSH ES ;;AN000;
272 PUSH DS ;;AN000;
273 POP ES ;;AN000;
274 MOV DI, OFFSET NAME_KYBD ;;AN000;
275 MOV CX, LEN_ALT_KYBD_ID ;;AN000; Number of bytes in the keyboard code
276 MOV [DI], CX ;;AN000;
277 ADD DI, 2 ;;AN000;
278 CLD ;;AN000;
279 REP MOVSB ;;AN000;
280 POP ES ;;AN000;
281 ENDM ;;AN000;
282 ;;****************************************************************************
283 ;;
284 ;; EXEC_PROGRAM: Loads another program into memory and begins execution.
285 ;;
286 ;; SYNTAX: EXEC_PROGRAM child, name_com, parm_block, re_dir
287 ;;
288 ;; INPUT: child = Name of the program to execute (ASCII-N format)
289 ;; name_com = The command line to be passed to parm_block
290 ;; parm_block = Parameter block for child program.
291 ;; re_dir = 1: Redirect Stdout and Stderr to null
292 ;; = 0: Don't redirect output.
293 ;;
294 ;; OUTPUT: CY = 0: Successful
295 ;; CY = 1: Error - AX has the error code.
296 ;;
297 ;; OPERATION: The command line to be passed to the parameter block is
298 ;; copied to the command buffer specified for the parameter block and
299 ;; a carrage return is appended to the end of the buffer. (The
300 ;; command line length can be zero.
301 ;;
302 ;; The segment offsets in the parameter block are defined and DOS
303 ;; function call 29H is performed to set up the default FCB's.
304 ;;
305 ;; DOS function call 4Bh is performed to load and execute the
306 ;; specified child program. The contents of SS and SP are destroyed
307 ;; during the call, so they must be save and restored later. When the
308 ;; parent program (SELECT) gets control, all available memory is
309 ;; allocated to it. It is assumed that memory has been freed (Function
310 ;; call 4Ah - FREE_MEM) before invoking this function.
311 ;;
312 ;;************************************************************************;;
313 EXEC_PROGRAM MACRO CHILD, NAME_COM, PARM_BLOCK, RE_DIR ;;AN000;
314
315 MOV AX, OFFSET CHILD ;;AN000;
316 PUSH AX ;;AN000;
317 MOV AX, OFFSET NAME_COM ;;AN000;
318 PUSH AX ;;AN000;
319 MOV AX, OFFSET PARM_BLOCK ;;AN000;
320 PUSH AX ;;AN000;
321 MOV AX, RE_DIR ;;AN000;
322 PUSH AX ;;AN000;
323 CALL EXEC_PROGRAM_ROUTINE ;;AN000;
324 ENDM ;;AN000;
325 ;;*****************************************************************************
326 ;;
327 ;; FREE_MEM: Free memory by modifying the memory block
328 ;;
329 ;; SYNTAX: FREE_MEM address
330 ;;
331 ;; INPUT:
332 ;; address - The address of the first free paragraph in memory.
333 ;;
334 ;; OUTPUT: CY = 0, AX=undefined, successful
335 ;; CY = 1, AX= error code
336 ;;
337 ;; OPERATION:
338 ;;
339 ;; FREEMEM MODIFIES ALLOCATED MEMORY BLOCKS TO
340 ;; CONTAIN THE NEW SPECIFIED BLOCK SIZE.
341 ;; IT MAKES USE OF DOS INT 21 (AH=4AH).
342 ;; IF AN ERROR OCCURS, THE CARRY FLAG IS SET, AND THE ERROR CODE
343 ;; IS RETURNED IN AX.
344 ;;
345 ;;****************************************************************************
346 FREE_MEM MACRO address ;;AN000;
347 PUSH ES ;;AN000;
348 MOV AH,62H ;;AN000;
349 DOSCALL ;;AN000; Get the current PSP segment
350 MOV ES,BX ;;AN000; Load current PSP segment
351 MOV BX, ADDRESS ;;AN000; size of program in paragraphs in bx reg
352
353 MOV AH,4AH ;;AN000; free memory function
354 DOSCALL ;;AN000;
355 POP ES ;;AN000;
356 ENDM ;;AN000;
357 ;;****************************************************************************
358 ;;
359 ;; CLEAR_SCREEN: clear the screen to white on blue
360 ;;
361 ;; SYNTAX: CLEAR_SCREEN
362 ;;
363 ;; INPUT:
364 ;; None.
365 ;;
366 ;; OUTPUT:
367 ;; None.
368 ;;
369 ;; OPERATION: Clears the screen using the BIOS function to scroll the
370 ;; screen completely.
371 ;;
372 ;;****************************************************************************
373 CLEAR_SCREEN MACRO ;;AN000;
374 MOV CX,0 ;;AN000;
375 MOV DX,184Fh ;;AN000; scroll screen from (0,0) tO (24,79)
376 MOV AX,0600h ;;AN000; AH = 6, Scroll Function
377 ;; AL = 0, Clear scroll area
378 MOV BH,01FH ;;AN000; video I/O interrupt
379 INT 10H ;;AN000;
380 MOV DX,0 ;;AN000; RKJ-set cursor posn to top right hand corner
381 MOV BH,0 ;;AN000; RKJ
382 MOV AH,2 ;;AN000; RKJ
383 INT 10H ;;AN000; RKJ
384 ENDM ;;AN000;
385 ;;****************************************************************************
386 ;;
387 ;; CLEAR_SCREEN2: clear the screen to white on black
388 ;;
389 ;; SYNTAX: CLEAR_SCREEN2
390 ;;
391 ;; INPUT:
392 ;; None.
393 ;;
394 ;; OUTPUT:
395 ;; None.
396 ;;
397 ;; OPERATION: Clears the screen using the BIOS function to scroll the
398 ;; screen completely.
399 ;;
400 ;;****************************************************************************
401 CLEAR_SCREEN2 MACRO ;;AN000;
402 MOV CX,0 ;;AN000;
403 MOV DX,184Fh ;;AN000; scroll screen from (0,0) tO (24,79)
404 MOV AX,0600h ;;AN000; AH = 6, Scroll Function
405 ;; AL = 0, Clear scroll area
406 MOV BH,7 ;;AN000; video I/O interrupt
407 INT 10H ;;AN000;
408 MOV DX,0 ;;AN000; RKJ-set cursor posn to top right hand corner
409 MOV BH,0 ;;AN000; RKJ
410 MOV AH,2 ;;AN000; RKJ
411 INT 10H ;;AN000; RKJ
412 ENDM ;;AN000;
413 ;;****************************************************************************
414 ;;
415 ;; POS_CURSOR: position the cursor to top left corner of screen
416 ;;
417 ;; SYNTAX: POS_CURSOR
418 ;;
419 ;; INPUT:
420 ;; None.
421 ;;
422 ;; OUTPUT:
423 ;; None.
424 ;;
425 ;; OPERATION: Homes the cursor using the BIOS function call.
426 ;;
427 ;;****************************************************************************
428 POS_CURSOR MACRO ;;AN085; SEH
429 PUSH AX ;;AN085; SEH
430 PUSH BX ;;AN085; SEH
431 PUSH CX ;;AN085; SEH
432 PUSH DX ;;AN085; SEH
433 PUSH SI ;;AN085; SEH
434 PUSH DI ;;AN085; SEH
435 PUSH ES ;;AN085; SEH
436 MOV DX,0 ;;AN085; SEH-set cursor posn to top left hand corner
437 XOR BH,BH ;;AN085; SEH
438 MOV AH,2 ;;AN085; SEH
439 INT 10H ;;AN085; SEH
440 POP ES ;;AN085; SEH
441 POP DI ;;AN085; SEH
442 POP SI ;;AN085; SEH
443 POP DX ;;AN085; SEH
444 POP CX ;;AN085; SEH
445 POP BX ;;AN085; SEH
446 POP AX ;;AN085; SEH
447 ENDM ;;AN085; SEH
448 ;;****************************************************************************
449 ;;
450 ;; BEEP: Produce a tone on the PC speaker
451 ;;
452 ;; SYNTAX: BEEP frequency, duration
453 ;;
454 ;; INPUT: frequency = 37 to 32767
455 ;; duration = 1 to 65535
456 ;;
457 ;; OUTPUT: A SOUND
458 ;;
459 ;; OPERATION:
460 ;;
461 ;; BEEP CREATES A TONE USING THE PC SPEAKER
462 ;;
463 ;;****************************************************************************
464 BEEP MACRO FREQ,DUR ;;AN000;
465
466
467 MOV DI, FREQ ;;AN000; set the frequency
468 MOV BX, DUR ;;AN000; set the duration
469 CALL BEEP_ROUTINE ;;AN000;
470
471 ENDM ;;AN000;
472 ;;**************************************************************************
473 ;;
474 ;; GOTO : used instead of branching assembler intructions
475 ;;
476 ;; SYNTAX: GOTO label
477 ;;
478 ;; INPUT: label = an assembler label for a branching instruction
479 ;;
480 ;; OUTPUT: none
481 ;;
482 ;; OPERATION:
483 ;;
484 ;;
485 ;;**************************************************************************
486 GOTO MACRO LABEL ;;AN000;
487 JMP LABEL ;;AN000; jump to label
488 ENDM ;;AN000;
489 ;;************************************************************************;;
490 ;;
491 ;; BYTE_TO_CHAR: Convert a 8-bit binary number to ASCII format.
492 ;;
493 ;; SYNTAX: BYTE_TO_CHAR var_num, name_str
494 ;;
495 ;; INPUT:
496 ;; var_num = binary number to convert. (8 bits)
497 ;;
498 ;; OUTPUT:
499 ;; name_str = ASCII-N string for the specifed value.
500 ;;
501 ;; OPERATION: The specified 8 bit numeric variable contents are converted
502 ;; to ASCII and stored in ASCII-N format. Leading zeros will not be
503 ;; stored.
504 ;;
505 ;;************************************************************************;;
506 BYTE_TO_CHAR MACRO VAR_NUM, NAME_STR ;;AN000;
507
508
509 MOV AL, VAR_NUM ;;AN000;
510 MOV AH, 0 ;;AN000;
511 MOV DI, OFFSET NAME_STR ;;AN000;
512 CALL BIN_TO_CHAR_ROUTINE ;;AN000;
513 ENDM ;;AN000;
514 ;;************************************************************************;;
515 ;;
516 ;; WORD_TO_CHAR: Convert a binary number to ASCII format.
517 ;;
518 ;; SYNTAX: WORD_TO_CHAR var_num, name_str
519 ;;
520 ;; INPUT:
521 ;; var_num = binary number to convert. (16 bits)
522 ;;
523 ;; OUTPUT:
524 ;; name_str = ASCII-N string for the specifed value.
525 ;;
526 ;; OPERATION: The specified 16 bit numeric variable contents are converted
527 ;; to ASCII and stored in ASCII-N format. Leading zeros will not be
528 ;; stored.
529 ;;
530 ;;************************************************************************;;
531 WORD_TO_CHAR MACRO VAR_NUM, NAME_STR ;;AN000;
532
533 MOV AX, VAR_NUM ;;AN000;
534 MOV DI, OFFSET NAME_STR ;;AN000;
535 CALL BIN_TO_CHAR_ROUTINE ;;AN000;
536 ENDM ;;AN000;
537
538 INCLUDE MACROS6.INC ;;AN000;