summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/COMMAND/TUCODE.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/COMMAND/TUCODE.ASM')
-rw-r--r--v4.0/src/CMD/COMMAND/TUCODE.ASM520
1 files changed, 520 insertions, 0 deletions
diff --git a/v4.0/src/CMD/COMMAND/TUCODE.ASM b/v4.0/src/CMD/COMMAND/TUCODE.ASM
new file mode 100644
index 0000000..6531c44
--- /dev/null
+++ b/v4.0/src/CMD/COMMAND/TUCODE.ASM
@@ -0,0 +1,520 @@
1 page 80,132
2; SCCSID = @(#)tucode.asm 4.2 85/05/31
3; SCCSID = @(#)tucode.asm 4.2 85/05/31
4Title COMMAND Language midifiable Code Transient
5
6
7.xlist
8.xcref
9 INCLUDE dossym.inc
10 INCLUDE comsw.asm
11 INCLUDE comseg.asm
12 INCLUDE comequ.asm
13.list
14.cref
15
16
17DATARES SEGMENT PUBLIC BYTE ;AC000;
18 EXTRN ECHOFLAG:BYTE
19DATARES ENDS
20
21TRANDATA SEGMENT PUBLIC BYTE ;AC000;
22 EXTRN BAD_ON_OFF_ptr:word
23 EXTRN ctrlcmes_ptr:word
24 EXTRN DEL_Y_N_PTR:WORD
25 EXTRN ECHOMES_ptr:word
26 EXTRN extend_buf_ptr:word ;AC000;
27 EXTRN offmes_ptr:word
28 EXTRN onmes_ptr:word
29 EXTRN PARSE_BREAK:BYTE ;AN000;
30 EXTRN promptdat_moday:word ;AC000;
31 EXTRN promptdat_ptr:word ;AC000;
32 EXTRN promptdat_yr:word ;AC000;
33 EXTRN string_buf_ptr:word
34 EXTRN SUREMES_ptr:word
35 EXTRN VERIMES_ptr:BYTE
36 EXTRN WeekTab:word
37TRANDATA ENDS
38
39TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
40 EXTRN arg_buf:byte
41 EXTRN BWDBUF:BYTE
42 EXTRN DEST:BYTE
43 EXTRN destdir:byte
44 EXTRN dirchar:byte
45 EXTRN PARSE1_CODE:BYTE ;AN000;
46 EXTRN RESSEG:WORD
47 EXTRN string_ptr_2:word
48
49TRANSPACE ENDS
50
51TRANCODE SEGMENT PUBLIC BYTE
52
53 EXTRN CERROR:NEAR
54 EXTRN CRLF2:NEAR
55 EXTRN extend_setup:near ;AN022;
56
57 PUBLIC CNTRLC
58 PUBLIC ECHO
59 PUBLIC GetDate
60 PUBLIC NOTEST2
61 PUBLIC PRINT_DATE
62 PUBLIC SLASHP_ERASE ;AN000;
63 PUBLIC VERIFY
64
65ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:TRANGROUP,SS:NOTHING
66
67; ****************************************************************
68; *
69; * ROUTINE: NOTEST2 - execution of DEL/ERASE command
70; *
71; * FUNCTION: Delete files based on user parsed input. Prompt
72; * user for Y/N if necessary. If an error occurs,
73; * set up an error message and go to CERROR.
74; *
75; * INPUT: FCB at 5ch set up with filename(s) entered
76; * Current directory set to entered directory
77; *
78; * OUTPUT: none
79; *
80; ****************************************************************
81;
82; ARE YOU SURE prompt when deleting *.*
83
84NOTEST2:
85 MOV CX,11
86 MOV SI,FCB+1
87
88AMBSPEC:
89 LODSB
90 CMP AL,'?'
91 JNZ ALLFIL
92 LOOP AMBSPEC
93
94ALLFIL:
95 CMP CX,0
96 JNZ NOPRMPT
97
98ASKAGN:
99 MOV DX,OFFSET TRANGROUP:SUREMES_ptr ; "Are you sure (Y/N)?"
100 invoke std_printf
101 MOV SI,80H
102 MOV DX,SI
103 MOV WORD PTR [SI],120 ; zero length
104 MOV AX,(STD_CON_INPUT_FLUSH SHL 8) OR STD_CON_STRING_INPUT
105 INT 21H
106 LODSW
107 OR AH,AH
108 JZ ASKAGN
109 INVOKE SCANOFF
110 call char_in_xlat ;G Convert to upper case
111 retc ;AN000; return if function not supported
112 CMP AL,CAPITAL_N ;G
113 retz
114 CMP AL,CAPITAL_Y ;G
115 PUSHF
116 CALL CRLF2
117 POPF
118 JNZ ASKAGN
119
120NOPRMPT:
121 MOV AH,FCB_DELETE
122 MOV DX,FCB
123 INT 21H
124 INC AL
125 jz eraerr
126 invoke RESTUDIR
127 ret ; If no error, return
128
129eraerr:
130 invoke set_ext_error_msg ;AN022; set up the extended error
131 push dx ;AN022; save message
132 invoke RESTUDIR
133 pop dx ;AN022; restore message
134
135 cmp word ptr extend_buf_ptr,error_no_more_files ;AN022; convert no more files to
136 jnz cerrorj2 ;AN022; file not found
137 mov Extend_Buf_ptr,error_file_not_found ;AN000; get message number in control block
138
139cerrorj2:
140 jmp cerror
141
142
143; ****************************************************************
144; *
145; * ROUTINE: SLASHP_ERASE - execution of DEL/ERASE /P
146; *
147; * FUNCTION: Delete files based on user parsed input. Prompt
148; * user for Y/N where necessary. If an error occurs
149; * set up and error message and transfer control
150; * to CERROR.
151; *
152; * INPUT: FCB at 5ch set up with filename(s) entered
153; * Current directory set to entered directory
154; *
155; * OUTPUT: none
156; *
157; ****************************************************************
158
159ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:TRANGROUP,SS:NOTHING
160
161SLASHP_ERASE: ;AN000; entry point
162 invoke build_dir_string ;AN000; set up current directory string for output
163 mov ah,Set_DMA ;AN000; issue set dta int 21h
164 mov dx,offset trangroup:destdir ;AN000; use Destdir for target
165 int 21H ;AN000;
166 mov ah,Dir_Search_First ;AN000; do dir search first int 21h
167 mov dx,FCB ;AN000; use FCB at 5Ch for target
168 int 21H ;AN000;
169 inc al ;AN000; did an error occur
170 jz eraerr ;AN022; go to error exit
171
172delete_prompt_loop: ;AN000;
173 mov si,offset trangroup:destdir+1 ;AN000; set up FCB as source
174 mov di,offset trangroup:dest ;AN000; set up dest as target
175 mov al,dirchar ;AN000; store a "\" in the first char
176 stosb ;AN000; of DEST
177 invoke fcb_to_ascz ;AN000; convert filename from FCB to ASCIIZ string
178
179slashp_askagn: ;AN000;
180 call crlf2 ;AN000; print out carriage return, line feed
181 mov dx,offset trangroup:bwdbuf ;AN000; print out current directory string
182 mov bx,dx ;AN000; get string pointer in bx
183 cmp byte ptr [bx+3],end_of_line_out ;AN000; see if only D:\,0
184 jnz not_del_root ;AN000; no continue
185 mov byte ptr [bx+2],end_of_line_out ;AN000; yes, get rid of \
186
187Not_del_root: ;AN000;
188 mov string_ptr_2,dx ;AN000;
189 mov dx,offset trangroup:string_buf_ptr ;AN000;
190 invoke std_printf ;AN000;
191 mov dx,offset trangroup:dest ;AN000; print out file name string
192 mov string_ptr_2,dx ;AN000;
193 mov dx,offset trangroup:string_buf_ptr ;AN000;
194 invoke std_printf ;AN000;
195 mov dx,offset trangroup:Del_Y_N_Ptr ;AN000; issue ", Delete (Y/N)?" message
196 invoke std_printf ;AN000;
197 mov si,80H ;AN000; set up buffer for input
198 mov dx,si ;AN000;
199 mov word ptr [si],combuflen ;AN000;
200 mov ax,(std_con_input_flush shl 8) or std_con_string_input ;AN000;
201 int int_command ;AN000; get input from the user
202 lodsw ;AN000;
203 or ah,ah ;AN000; was a character entered?
204 jz slashp_askagn ;AN000; no - ask again
205 invoke scanoff ;AN000; scan off leading delimiters
206 call char_in_xlat ;AN000; yes - upper case it
207 retc ;AN000; return if function not supported
208 cmp al,capital_n ;AN000; was it no?
209 jz next_del_file ;AN000; yes - don't delete file
210 cmp al,capital_y ;AN000; was it yes?
211 jz delete_this_file ;AN000; yes - delete the file
212 jmp short slashp_askagn ;AN000; it was neither - ask again
213
214delete_this_file: ;AN000;
215 mov ah,fcb_delete ;AN000; delete the file
216 mov dx,offset trangroup:destdir ;AN000; use Destdir for target
217 int int_command ;AN000;
218 inc al ;AN000; did an error occur?
219 jnz next_del_file ;AN000; no - get next file
220 jmp eraerr ;AN022; go to error exit - need long jmp
221
222next_del_file: ;AN000;
223 mov ah,dir_search_next ;AN000; search for another file
224 mov dx,FCB ;AN000;
225 int int_command ;AN000;
226 inc al ;AN000; was a file found?
227 jz slash_p_exit ;AN000; no - exit
228 jmp delete_prompt_loop ;AN000; yes - continue (need long jump)
229
230slash_p_exit:
231 invoke get_ext_error_number ;AN022; get the extended error number
232 cmp ax,error_no_more_files ;AN022; was error file not found?
233 jz good_erase_exit ;AN022; yes - clean exit
234 jmp extend_setup ;AN022; go issue error message
235
236good_erase_exit:
237 invoke restudir ;AN000; we're finished - restore user's dir
238 call crlf2 ;AN000; print out carriage return, line feed
239 ret ;AN000; exit
240
241
242;************************************************
243; ECHO, BREAK, and VERIFY commands. Check for "ON" and "OFF"
244
245 break Echo
246
247assume ds:trangroup,es:trangroup
248
249ECHO:
250 CALL ON_OFF
251 JC DOEMES
252 MOV DS,[RESSEG]
253ASSUME DS:RESGROUP
254 JNZ ECH_OFF
255 OR [ECHOFLAG],1
256 RET
257ECH_OFF:
258 AND [ECHOFLAG],NOT 1
259 RET
260
261
262CERRORJ:
263 JMP CERROR
264
265;
266; There was no discrenable ON or OFF after the ECHO. If there is nothing but
267; delimiters on the command line, we issue the ECHO is ON/OFF message.
268;
269
270ASSUME DS:TRANGROUP
271
272DOEMES:
273 cmp cl,0 ;AC000; was anything on the line?
274 jz PEcho ; just display current state.
275 MOV DX,82H ; Skip one char after "ECHO"
276 invoke CRPRINT
277 JMP CRLF2
278
279PECHO:
280 MOV DS,[RESSEG]
281ASSUME DS:RESGROUP
282 MOV BL,[ECHOFLAG]
283 PUSH CS
284 POP DS
285ASSUME DS:TRANGROUP
286 AND BL,1
287 MOV DX,OFFSET TRANGROUP:ECHOMES_ptr
288 JMP SHORT PYN
289
290 break Break
291assume ds:trangroup,es:trangroup
292
293CNTRLC:
294 CALL ON_OFF
295 MOV AX,(SET_CTRL_C_TRAPPING SHL 8) OR 1
296 JC PCNTRLC
297 JNZ CNTRLC_OFF
298 MOV DL,1
299 INT 21H ; Set ^C
300 RET
301
302CNTRLC_OFF:
303 XOR DL,DL
304 INT 21H ; Turn off ^C check
305 RET
306
307PCNTRLC:
308 CMP CL,0 ;AC000; rest of line blank?
309 JNZ CERRORJ ; no, oops!
310
311pccont:
312 XOR AL,AL
313 INT 21H
314 MOV BL,DL
315 MOV DX,OFFSET TRANGROUP:CTRLCMES_ptr
316
317PYN:
318 mov si,offset trangroup:onmes_ptr ;AC000; get ON pointer
319 OR BL,BL
320 JNZ PRINTVAL
321 mov si,offset trangroup:offmes_ptr ;AC000; get OFF pointer
322
323PRINTVAL:
324 push dx ;AN000; save offset of message block
325 mov bx,dx ;AN000; save offset value
326 lodsw ;AN000; get message number of on or off
327 mov dh,util_msg_class ;AN000; this is a utility message
328 invoke Tsysgetmsg ;AN000; get the address of the message
329 add bx,ptr_off_pos ;AN000; point to offset of ON/OFF
330 mov word ptr [bx],si ;AN000; put the offset in the message block
331 pop dx ;AN000; get message back
332 invoke std_printf ;AC000; go print message
333 mov word ptr [bx],0 ;AN000; zero out message pointer
334
335 ret ;AN000; exit
336
337 break Verify
338assume ds:trangroup,es:trangroup
339
340VERIFY:
341 CALL ON_OFF
342 MOV AX,(SET_VERIFY_ON_WRITE SHL 8) OR 1
343 JC PVERIFY
344 JNZ VER_OFF
345 INT 21H ; Set verify
346 RET
347
348VER_OFF:
349 DEC AL
350 INT 21H ; Turn off verify after write
351 RET
352
353PVERIFY:
354 CMP CL,0 ;AC000; is rest of line blank?
355 JNZ CERRORJ ; nope...
356 MOV AH,GET_VERIFY_ON_WRITE
357 INT 21H
358 MOV BL,AL
359 MOV DX,OFFSET TRANGROUP:VERIMES_ptr
360 JMP PYN
361
362; ****************************************************************
363; *
364; * ROUTINE: ON_OFF
365; *
366; * FUNCTION: Parse the command line for an optional ON or
367; * OFF string for the BREAK, VERIFY, and ECHO
368; * routines.
369; *
370; * INPUT: command line at offset 81H
371; * PARSE_BREAK control block
372; *
373; * OUTPUT: If carry is clear
374; * If ON is found
375; * Zero flag set
376; * If OFF is found
377; * Zero flag clear
378; * If carry set
379; * If nothing on command line
380; * CL set to zero
381; * If error
382; * CL contains error value from parse
383; *
384; ****************************************************************
385
386assume ds:trangroup,es:trangroup
387
388ON_OFF:
389 MOV SI,81h
390
391scan_on_off: ;AN032; scan off leading blanks & equal
392 lodsb ;AN032; get a char
393 cmp al,blank ;AN032; if whitespace
394 jz scan_on_off ;AN032; keep scanning
395 cmp al,tab_chr ;AN032; if tab
396 jz scan_on_off ;AN032; keep scanning
397 cmp al,equal_chr ;AN032; if equal char
398 jz parse_on_off ;AN032; start parsing
399 dec si ;AN032; if none of above - back up
400
401parse_on_off: ;AN032; and start parsing
402 mov di,offset trangroup:parse_break ;AN000; Get adderss of PARSE_BREAK
403 xor cx,cx ;AN000; clear cx,dx
404 xor dx,dx ;AN000;
405 invoke cmd_parse ;AC000; call parser
406 cmp ax,end_of_line ;AC000; are we at end of line?
407 jz BADONF ;AC000; yes, return error
408 cmp ax,result_no_error ;AN000; did an error occur
409 jz on_off_there ;AN000; no - continue
410 mov cx,ax ;AN000; yes - set cl to error code
411 jmp short BADONF ;AN000; return error
412
413on_off_there:
414 cmp parse1_code,-1 ;AN014; was a valid positional present?
415 jnz good_on_off ;AN014; yes - continue
416 mov cx,badparm_ptr ;AN014; something other than ON/OFF
417 jmp short BADONF ;AN014; return error
418
419good_on_off: ;AN014;
420 xor ax,ax ;AC000; set up return code for
421 or al,parse1_code ;AC000; ON or OFF in AX
422 pushf ;AN000; save flags
423 mov di,offset trangroup:parse_break ;AN000; Get adderss of PARSE_BREAK
424 xor dx,dx ;AN000;
425 invoke cmd_parse ;AN000; call parser
426 cmp ax,end_of_line ;AN000; are we at end of line?
427 jnz BADONF_flags ;AN000; NO, return error
428 popf ;AN000; restore flags
429 clc ;AC000; no error
430 jmp short on_off_end ;AN000; return to caller
431
432BADONF_flags:
433 mov cx,ax
434 popf
435
436;
437; No discernable ON or OFF has been found. Put an error message pointer in DX
438; and return the error
439;
440BADONF:
441 MOV DX,OFFSET TRANGROUP:BAD_ON_OFF_ptr
442 STC
443
444ON_OFF_END:
445
446 RET
447
448
449
450;*************************************************************************
451; print date
452
453PRINT_DATE:
454 PUSH ES
455 PUSH DI
456 PUSH CS
457 POP ES
458 CALL GetDate ; get date
459 xchg dh,dl ;AN000; switch month & day
460 mov promptDat_yr,cx ;AC000; put year into message control block
461 mov promptDat_moday,dx ;AC000; put month and day into message control block
462 mov dx,offset trangroup:promptDat_ptr ;AC000; set up message for output
463 invoke std_printf
464;AD061; mov promptDat_yr,0 ;AC000; reset year, month and day
465;AD061; mov promptDat_moday,0 ;AC000; pointers in control block
466 POP DI ;AC000; restore di,es
467 POP ES ;AC000;
468 return
469;
470; Do GET DATE system call and set up 3 character day of week in ARG_BUF
471; for output. Date will be returned in CX,DX.
472;
473
474GetDate:
475 mov di,offset trangroup:arg_buf ;AC000; target for day of week
476 MOV AH,GET_DATE ;AC000; get current date
477 INT int_command ;AC000; Get date in CX:DX
478 CBW ;AC000;
479
480 push cx ;AN000; save date returned in
481 push dx ;AN000; CX:DX
482 MOV SI,AX
483 SHL SI,1
484 ADD SI,AX ; SI=AX*3
485 mov cx,si ;AN000; save si
486 mov ax,weektab ;AN000; get message number of weektab
487 mov dh,util_msg_class ;AN000; this is a utility message
488 push di ;AN000; save argument buffer
489 invoke Tsysgetmsg ;AN000; get the address of the message
490 pop di ;AN000; retrieve argument buffer
491 add si,cx ;AC000; get day of week
492 MOV CX,3
493 REP MOVSB
494 mov al,end_of_line_out ;AC000; terminate the string
495 stosb
496 pop dx ;AN000; get back date
497 pop cx ;AN000;
498
499 return
500;g
501;g This routine determines whether the character in AL is a
502;g Yes or No character. On return, if AL=0, the character is
503;g No, if AL=1, the character is Yes.
504;g
505
506assume ds:trangroup
507
508char_in_xlat proc near
509
510 mov dl,al ;AC000; get character into DX
511 xor dh,dh ;AC000;
512 mov ax,(getextcntry SHL 8) + 35 ;AC000; Yes/No char call
513 int int_command ;AC000;
514
515 ret
516
517char_in_xlat endp
518
519TRANCODE ENDS
520 END