summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/COMMAND/TCMD2A.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/COMMAND/TCMD2A.ASM')
-rw-r--r--v4.0/src/CMD/COMMAND/TCMD2A.ASM552
1 files changed, 552 insertions, 0 deletions
diff --git a/v4.0/src/CMD/COMMAND/TCMD2A.ASM b/v4.0/src/CMD/COMMAND/TCMD2A.ASM
new file mode 100644
index 0000000..9dcb066
--- /dev/null
+++ b/v4.0/src/CMD/COMMAND/TCMD2A.ASM
@@ -0,0 +1,552 @@
1 page 80,132
2; SCCSID = @(#)tcmd2a.asm 4.1 85/06/25
3; SCCSID = @(#)tcmd2a.asm 4.1 85/06/25
4TITLE PART5 COMMAND Transient routines.
5
6 INCLUDE comsw.asm
7
8.xlist
9.xcref
10 INCLUDE DOSSYM.INC
11 INCLUDE comequ.asm
12 INCLUDE comseg.asm
13 include ioctl.inc
14.list
15.cref
16
17
18CODERES SEGMENT PUBLIC BYTE ;AC000;
19CODERES ENDS
20
21DATARES SEGMENT PUBLIC BYTE ;AC000;
22DATARES ENDS
23
24TRANDATA SEGMENT PUBLIC BYTE ;AC000;
25 EXTRN arg_buf_ptr:word
26 EXTRN BadCurDrv:byte ;AC000;
27 EXTRN clsstring:byte
28 EXTRN dback_ptr:word
29 EXTRN display_ioctl:word ;AN000;
30 EXTRN display_width:word ;AN000;
31 EXTRN Extend_buf_ptr:word ;AN049;
32 EXTRN linperpag:word ;AN000;
33 EXTRN msg_disp_class:byte ;AN049;
34 EXTRN nulpath_ptr:word
35 EXTRN prompt_table:word
36 EXTRN string_buf_ptr:word ;AC000;
37 EXTRN vermes_ptr:word
38TRANDATA ENDS
39
40TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
41 EXTRN Arg_Buf:byte
42 EXTRN bwdbuf:byte
43 EXTRN curdrv:byte
44 EXTRN dirchar:byte
45 EXTRN major_ver_num:word
46 EXTRN minor_ver_num:word
47 EXTRN srcxname:byte ;AN049;
48 EXTRN string_ptr_2:word
49TRANSPACE ENDS
50
51TRANCODE SEGMENT PUBLIC BYTE
52
53ASSUME CS:TRANGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING
54
55;---------------
56
57TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
58 EXTRN arg:byte ; the arg structure!
59transpace ends
60;---------------
61
62 EXTRN cerror:near ;AN049;
63 EXTRN crlf2:near
64 EXTRN drvbad:near
65 EXTRN std_printf:near
66
67 PUBLIC build_dir_for_chdir
68 PUBLIC build_dir_for_prompt
69 PUBLIC build_dir_string
70 PUBLIC cls
71 PUBLIC path
72 PUBLIC print_char
73 PUBLIC print_drive
74 PUBLIC print_version
75 PUBLIC print_b
76 PUBLIC print_back
77 PUBLIC print_eq
78 PUBLIC print_esc
79 PUBLIC print_g
80 PUBLIC print_l
81 PUBLIC print_prompt
82 PUBLIC version
83
84 break Version
85assume ds:trangroup,es:trangroup
86
87VERSION:
88 call crlf2
89 call print_version
90 jmp crlf2
91
92print_version:
93 mov ah,Get_version
94 int int_command
95 push ax
96 xor ah,ah
97 mov major_ver_num,ax
98 pop ax
99 xchg ah,al
100 xor ah,ah
101 mov minor_ver_num,ax
102 mov dx,offset trangroup:vermes_ptr
103 jmp std_printf
104
105print_prompt:
106 push ds
107 push cs
108 pop ds ; MAKE SURE DS IS IN TRANGROUP
109 push es
110 invoke find_prompt ; LOOK FOR PROMPT STRING
111 jc PP0 ; CAN'T FIND ONE
112 cmp byte ptr es:[di],0
113 jnz PP1
114PP0:
115 call print_drive ; USE DEFAULT PROMPT
116 mov al,sym
117 call print_char
118 jmp short PP5
119
120PP1:
121 mov al,es:[di] ; GET A CHAR
122 inc di
123 or al,al
124 jz PP5 ; NUL TERMINATED
125 cmp al,dollar ; META CHARACTER?
126 jz PP2 ; NOPE
127PPP1:
128 call print_char
129 jmp PP1
130
131PP2:
132 mov al,es:[di]
133 inc di
134 mov bx,offset trangroup:prompt_table-3
135 or al,al
136 jz PP5
137
138PP3:
139 add bx,3
140 invoke upconv
141 cmp al,[bx]
142 jz PP4
143 cmp byte ptr [bx],0
144 jnz PP3
145 jmp PP1
146
147PP4:
148 push es
149 push di
150 push cs
151 pop es
152 call [bx+1]
153 pop di
154 pop es
155 jmp PP1
156
157PP5:
158 pop es ; RESTORE SEGMENTS
159 pop ds
160 return
161
162
163print_back:
164 mov dx,offset trangroup:dback_ptr
165 jmp std_printf
166
167print_EQ:
168 mov al,'='
169 jmp short print_char
170
171print_esc:
172 mov al,1BH
173 jmp short print_char
174
175print_G:
176 mov al,rabracket
177 jmp short print_char
178
179print_L:
180 mov al,labracket
181 jmp short print_char
182
183print_B:
184 mov al,vbar
185
186print_char:
187 push es
188 push ds
189 pop es
190 push di
191 push dx
192 mov dl,al ;AC000; Get char into al
193 mov ah,Std_CON_output ;AC000; print the char to stdout
194 int int_command ;AC000;
195 pop dx
196 pop di
197 pop es
198 ret
199
200print_drive:
201 mov ah,Get_Default_drive
202 int int_command
203 add al,capital_A
204 call print_char
205 ret
206
207ASSUME DS:TRANGROUP,ES:TRANGROUP
208
209build_dir_for_prompt:
210 xor dl,dl
211 mov si,offset trangroup:bwdbuf
212 mov di,SI
213 mov al,CurDrv
214 add al,'A'
215 mov ah,':'
216 stosw
217 mov al,[dirchar]
218 stosb
219 xchg si,di
220 mov string_ptr_2,di
221 mov ah,Current_dir
222 int int_command
223 mov dx,offset trangroup:string_buf_ptr
224 jnc DoPrint
225 mov dx,offset trangroup:BadCurDrv
226DoPrint:
227 call std_printf
228
229 ret
230
231build_dir_for_chdir:
232 call build_dir_string
233 mov dx,offset trangroup:bwdbuf
234 mov string_ptr_2,dx
235 mov dx,offset trangroup:string_buf_ptr
236 call std_printf
237 ret
238
239build_dir_string:
240 mov dl,ds:[FCB]
241 mov al,DL
242 add al,'@'
243 cmp al,'@'
244 jnz gotdrive
245 add al,[CURDRV]
246 inc al
247
248gotdrive:
249 push ax
250 mov si,offset trangroup:bwdbuf+3
251 mov ah,Current_dir
252 int int_command
253 jnc dpbisok
254 push cs
255 pop ds
256 jmp drvbad
257
258dpbisok:
259 mov di,offset trangroup:bwdbuf
260 mov dx,di
261 pop ax
262 mov ah,':'
263 stosw
264 mov al,[dirchar]
265 stosb
266
267 ret
268
269 break Path
270assume ds:trangroup,es:trangroup
271
272PATH:
273 xor al,al ;AN049; Set up holding buffer
274 mov di,offset Trangroup:srcxname ;AN049; for PATH while parsing
275 stosb ;AN049; Initialize PATH to null
276 dec di ;AN049; point to the start of buffer
277 invoke PGetarg ; Pre scan for arguments
278 jz disppath ; Print the current path
279 cmp al,semicolon ;AC049; NUL path argument?
280 jnz pathslp ;AC049;
281 inc si ;AN049; point past semicolon
282 jmp short scan_white ;AC049; Yes - make sure nothing else on line
283
284pathslp: ; Get the user specified path
285 lodsb ; Get a character
286 cmp al,end_of_line_in ;AC049; Is it end of line?
287 jz path_eol ;AC049; yes - end of command
288
289 invoke testkanj ;See if DBCS
290 jz notkanj2 ;No - continue
291 stosb ;AC049; Yes - store the first byte
292 lodsb ;skip second byte of DBCS
293
294path_hold: ;AN049;
295 stosb ;AC049; Store a byte in the PATH buffer
296 jmp short pathslp ;continue parsing
297
298notkanj2:
299 invoke upconv ;upper case the character
300 cmp al,semicolon ;AC049; ';' not a delimiter on PATH
301 jz path_hold ;AC049; go store it
302 invoke delim ;delimiter?
303 jnz path_hold ;AC049; no - go store character
304
305scan_white: ;AN049; make sure were at EOL
306 lodsb ;AN049; get a character
307 cmp al,end_of_line_in ;AN049; end of line?
308 jz path_eol ;AN049; yes - go set path
309 cmp al,blank ;AN049; whitespace?
310 jz scan_white ;AN049; yes - continue scanning
311 cmp al,tab_chr ;AN049; whitespace?
312 jz scan_white ;AN049; yes - continue scanning
313
314 mov dx,offset TranGroup:Extend_Buf_ptr ;AN049; no - set up error message
315 mov Extend_Buf_ptr,MoreArgs_ptr ;AN049; get "Too many parameters" message number
316 mov msg_disp_class,parse_msg_class ;AN049; set up parse error msg class
317 jmp cerror ;AN049;
318
319path_eol: ;AN049; Parsing was clean
320 xor al,al ;AN049; null terminate the PATH
321 stosb ;AN049; buffer
322 invoke find_path ;AN049; Find PATH in environment
323 invoke delete_path ;AC049; Delete any offending name
324 invoke scan_double_null ;AC049; Scan to end of environment
325 invoke move_name ;AC049; move in PATH=
326 mov si,offset Trangroup:srcxname ;AN049; Set up source as PATH buffer
327
328store_path: ;AN049; Store the PATH in the environment
329 lodsb ;AN049; Get a character
330 cmp al,end_of_line_out ;AN049; null character?
331 jz got_paths ;AN049; yes - exit
332 invoke store_char ;AN049; no - store character
333 jmp short store_path ;AN049; continue
334
335got_paths: ;AN049; we're finished
336 xor ax,ax ;null terminate the PATH in
337 stosw ; the environment
338 return
339
340disppath:
341 invoke find_path ;AN049;
342 call print_path
343 call crlf2
344 return
345
346print_path:
347 cmp byte ptr es:[di],0
348 jnz path1
349
350path0:
351 mov dx,offset trangroup:nulpath_ptr
352 push cs
353 pop es
354 push cs
355 pop ds
356 jmp std_printf
357
358path1:
359 push es
360 pop ds
361 sub di,5
362 mov si,di
363ASSUME DS:RESGROUP
364 invoke scasb2 ; LOOK FOR NUL
365 cmp cx,0FFH
366 jz path0
367 push cs
368 pop es
369 mov di,offset trangroup:arg_buf
370 mov dx,100h
371 sub dx,cx
372 xchg dx,cx
373 rep movsb
374 mov dx,offset trangroup:arg_buf_ptr
375 push cs
376 pop ds
377 jmp std_printf
378
379ASSUME DS:TRANGROUP
380
381 break Cls
382
383; ****************************************************************
384; *
385; * ROUTINE: CLS
386; *
387; * FUNCTION: Clear the screen using INT 10h. If ANSI.SYS is
388; * installed, send a control string to clear the
389; * screen.
390; *
391; * INPUT: command line at offset 81H
392; *
393; * OUTPUT: none
394; *
395; ****************************************************************
396
397assume ds:trangroup,es:trangroup
398
399ANSI_installed equ 0ffh
400
401CLS:
402 mov ah,Mult_ANSI ;AN000; see if ANSI.SYS installed
403 mov al,0 ;AN000;
404 int 2fh ;AN000;
405 cmp al,ANSI_installed ;AN000;
406 jz ansicls ;AN000; installed - go do ANSI CLS
407
408check_lines:
409 mov ax,(IOCTL SHL 8) + generic_ioctl_handle ;AN000; get lines per page on display
410 mov bx,stdout ;AN000; lines for stdout
411 mov ch,ioc_sc ;AN000; type is display
412 mov cl,get_generic ;AN000; get information
413 mov dx,offset trangroup:display_ioctl ;AN000;
414 int int_command ;AN000;
415 jc no_variable ;AN000; function had error, use default
416 mov ax,linperpag ;AN000; get number of rows returned
417 mov dh,al ;AN000; set number of rows
418 mov ax,display_width ;AN000; get number of columns returned
419 mov dl,al ;AN000; set number of columns
420 jmp short regcls ;AN000; go do cls
421
422no_variable:
423 mov bx,stdout ;AC000; set handle as stdout
424 mov ax,IOCTL SHL 8 ;AC000; do ioctl - get device
425 int int_command ;AC000; info
426 test dl,devid_ISDEV ;AC000; is handle a device
427 jz ANSICLS ;AC000; If a file put out ANSI
428 test dl,devid_SPECIAL ;AC000;
429 jnz cls_normal ;AC000; If not special CON, do ANSI
430
431ansicls:
432 call ansi_cls ;AN000; clear the screen
433 jmp short cls_ret ;AN000; exit
434
435;
436; Get video mode
437;
438
439cls_normal: ;AC000;
440
441 mov ah,get_video_state ;AC000; set up to get video state
442 int video_io_int ;AC000; do int 10h - BIOS video IO
443 cmp al,video_alpha ;AC000; see if in text mode
444 jbe DoAlpha
445 cmp al,video_bw ;AC000; see if black & white card
446 jz DoAlpha
447;
448; We are in graphics mode. Bogus IBM ROM does not scroll correctly. We will
449; be just as bogus and set the mode that we just got. This will blank the
450; screen too.
451;
452 mov ah,set_video_mode ;AC000; set video mode call
453 int video_io_int ;AC000; do int 10h - BIOS video IO
454 jmp short cls_ret ;AC000; exit
455
456DoAlpha:
457;
458; Get video mode and number of columns to scroll
459;
460 mov ah,get_video_state ;AC000; set up to get current video state
461 int video_io_int ;AC000; do int 10h - BIOS video IO
462 mov dl,ah
463 mov dh,linesperpage ;AC000; have 25 rows on the screen
464
465regcls:
466 call reg_cls ;AC000; go clear the screen
467
468cls_ret:
469 ret ;AC000; exit
470
471; ****************************************************************
472; *
473; * ROUTINE: REG_CLS
474; *
475; * FUNCTION: Clear the screen using INT 10H.
476; *
477; * INPUT: DL = NUMBER OF COLUMNS
478; * DH = NUMBER OF ROWS
479; *
480; * OUTPUT: none
481; *
482; ****************************************************************
483
484reg_cls proc near ;AC000;
485
486;
487; Set overscan to black.
488;
489
490 dec dh ;AC000; decrement rows and columns
491 dec dl ;AC000; to zero base
492 push dx ;AN000; save rows,columns
493 mov ah,set_color_palette ;AC000; set up to set the color to blank
494 xor bx,bx
495 int video_io_int ;AC000; do int 10h - BIOS video IO
496 pop dx ;AN000; retore rows,colums
497
498 xor ax,ax ;AC000; zero out ax
499 mov CX,ax ;AC000; an cx
500;
501; Scroll active page
502;
503 mov ah,scroll_video_page ;AC000; set up to scroll page up
504 mov bh,video_attribute ;AC000; attribute for blank line
505 xor bl,bl ;AC000; set BL to 0
506 int video_io_int ;AC000; do int 10h - BIOS video IO
507;
508; Seek to cursor to 0,0
509;
510 mov ah,set_cursor_position ;AC000; set up to set cursor position
511 xor dx,dx ;AC000; row and column 0
512 mov bh,0 ;AC000;
513 int video_io_int ;AC000; do into 10h - BIOS video IO
514
515 ret ;AC000;
516
517reg_cls endp ;AC000;
518
519
520
521; ****************************************************************
522; *
523; * ROUTINE: ANSI_CLS
524; *
525; * FUNCTION: Clear the screen using by writing a control code
526; * to STDOUT.
527; *
528; * INPUT: none
529; *
530; * OUTPUT: none
531; *
532; ****************************************************************
533
534ansi_cls proc near ;AC000;
535
536 mov si,offset trangroup:clsstring
537 lodsb
538 mov cl,al
539 xor ch,ch
540 mov ah,Raw_CON_IO
541clrloop:
542 lodsb
543 mov DL,al
544 int int_command
545 loop clrloop
546 return
547
548ansi_cls endp ;AC000;
549
550trancode ends
551 end
552 \ No newline at end of file