summaryrefslogtreecommitdiff
path: root/v4.0/src/BIOS/SYSINIT2.ASM
diff options
context:
space:
mode:
authorGravatar Mark Zbikowski2024-04-25 21:24:10 +0100
committerGravatar Microsoft Open Source2024-04-25 22:32:27 +0000
commit2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch)
tree80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/BIOS/SYSINIT2.ASM
parentMerge pull request #430 from jpbaltazar/typoptbr (diff)
downloadms-dos-main.tar.gz
ms-dos-main.tar.xz
ms-dos-main.zip
MZ is back!HEADmain
Diffstat (limited to 'v4.0/src/BIOS/SYSINIT2.ASM')
-rw-r--r--v4.0/src/BIOS/SYSINIT2.ASM1624
1 files changed, 1624 insertions, 0 deletions
diff --git a/v4.0/src/BIOS/SYSINIT2.ASM b/v4.0/src/BIOS/SYSINIT2.ASM
new file mode 100644
index 0000000..ff8b8ae
--- /dev/null
+++ b/v4.0/src/BIOS/SYSINIT2.ASM
@@ -0,0 +1,1624 @@
1 PAGE ,132 ;
2; SCCSID = @(#)sysinit2.asm 1.13 85/10/15
3TITLE BIOS SYSTEM INITIALIZATION
4%OUT ...SYSINIT2
5
6;==============================================================================
7;REVISION HISTORY:
8;AN000 - New for DOS Version 4.00 - J.K.
9;AC000 - Changed for DOS Version 4.00 - J.K.
10;AN00x - PTM number for DOS Version 4.00 - J.K.
11;==============================================================================
12;AN001; p132 Multiple character device installation problem. 6/27/87 J.K.
13;AN002; d24 MultiTrack= command added. 6/29/87 J.K.
14;AN003; p29 Extra space character in parameters passed.
15; (Modification on ORGANIZE routine for COMMENT= fixed this
16; problem too) 6/29/87 J.K.
17;AN004; d41 REM command in CONFIG.SYS 7/7/87 J.K.
18;AN005; d184 Set DEVMARK for MEM command 8/25/87 J.K.
19;AN006; p1820 New Message SKL file 10/20/87 J.K.
20;AN007; p1821 Include the COPYRIGH.INC file 10/22/87 J.K.
21;AN008; p2210 IBMDOS returns incorrect DBCS vector table length 11/02/87 J.K.
22;AN009; p2667 ccMono_Ptr problem 11/30/87 J.K.
23;AN010; p2792 Device?driver.sys /d:2 command should not work 12/09/87 J.K.
24;AN011; p3120 REM followed by CR, LF causes problem 01/13/88 J.K.
25;AN012; p3111 Take out the order dependency of the INSTALL= 01/25/88 J.K.
26;AN013; d479 New option to disable extended INT 16h function call 02/12/88 J.K.
27;AN014; D486 SHARE installation for big media 02/23/88 J.K.
28;AN015; D526 Add /NC parameter when installing SHARE.EXE 04/28/88 J.K.
29;==============================================================================
30
31TRUE EQU 0FFFFh
32FALSE EQU 0
33LF equ 10
34CR equ 13
35TAB equ 9
36
37IBMVER EQU TRUE
38IBM EQU IBMVER
39STACKSW EQU TRUE ;Include Switchable Hardware Stacks
40IBMJAPVER EQU FALSE ;If TRUE set KANJI true also
41MSVER EQU FALSE
42ALTVECT EQU FALSE ;Switch to build ALTVECT version
43KANJI EQU FALSE
44
45 IF IBMJAPVER
46NOEXEC EQU TRUE
47 ELSE
48NOEXEC EQU FALSE
49 ENDIF
50
51DOSSIZE EQU 0A000H
52
53.xlist
54; INCLUDE dossym.INC
55 include smdossym.inc ;J.K. Reduced version of DOSSYM.INC
56 INCLUDE devsym.INC
57 include ioctl.INC
58 include DEVMARK.inc
59.list
60
61 IF NOT IBM
62 IF NOT IBMJAPVER
63 EXTRN RE_INIT:FAR
64 ENDIF
65 ENDIF
66
67code segment public 'code'
68 extrn EC35_Flag: byte
69code ends
70
71SYSINITSEG SEGMENT PUBLIC 'SYSTEM_INIT' BYTE
72
73ASSUME CS:SYSINITSEG,DS:NOTHING,ES:NOTHING,SS:NOTHING
74
75 EXTRN BADOPM:BYTE,CRLFM:BYTE,BADCOM:BYTE,BADMEM:BYTE,BADBLOCK:BYTE
76 EXTRN BADSIZ_PRE:BYTE,BADLD_PRE:BYTE
77; EXTRN BADSIZ_POST:BYTE,BADLD_POST:BYTE
78 EXTRN SYSSIZE:BYTE,BADCOUNTRY:BYTE
79
80 EXTRN dosinfo:dword,entry_point:dword,
81 EXTRN MEMORY_SIZE:WORD,fcbs:byte,keep:byte
82 EXTRN DEFAULT_DRIVE:BYTE,confbot:word,alloclim:word
83 EXTRN BUFFERS:WORD,zero:byte,sepchr:byte
84 EXTRN FILES:BYTE
85 EXTRN count:word,chrptr:word
86 EXTRN bufptr:byte,memlo:word,prmblk:byte,memhi:word
87 EXTRN ldoff:word,area:word,PACKET:BYTE,UNITCOUNT:BYTE,
88 EXTRN BREAK_ADDR:DWORD,BPB_ADDR:DWORD,drivenumber:byte
89 extrn COM_Level:byte, CMMT:byte, CMMT1:byte, CMMT2:byte
90 extrn Cmd_Indicator:byte
91 extrn DoNotShowNum:byte
92 extrn MultDeviceFlag:byte
93 extrn DevMark_Addr:word ;AN005;
94 extrn SetDevMarkFlag:byte ;AN005;
95 extrn Org_Count:word ;AN012;
96
97 EXTRN Stall:near
98 EXTRN Error_Line:near
99
100 PUBLIC Int24,Open_Dev,Organize,Mem_Err,Newline,CallDev,Badload
101 PUBLIC PrnDev,AuxDev,Config,Commnd,Condev,GetNum,BadFil,PrnErr
102 PUBLIC Round,Delim,Print,Set_Break
103 PUBLIC SetParms, ParseLine, DiddleBack
104 PUBLIC Skip_delim,SetDOSCountryInfo,Set_Country_Path,Move_Asciiz
105 PUBLIC Cntry_Drv,Cntry_Root,Cntry_Path
106 PUBLIC Delim
107 public PathString ;AN014;
108 public LShare ;AN014;
109
110;
111; The following set of routines is used to parse the DRIVPARM = command in
112; the CONFIG.SYS file to change the default drive parameters.
113;
114SetParms:
115 push ds
116 push ax
117 push bx
118 push cx
119 push dx
120 push cs
121 pop ds
122 ASSUME DS:SYSINITSEG
123 xor bx,bx
124 mov bl,byte ptr drive
125 inc bl ; get it correct for IOCTL call (1=A,2=B...)
126 mov dx,offset DeviceParameters
127 mov ah, IOCTL
128 mov al, GENERIC_IOCTL
129 mov ch, RAWIO
130 mov cl, SET_DEVICE_PARAMETERS
131 int 21H
132 test word ptr Switches, flagec35
133 jz Not_EC35
134
135 mov cl, byte ptr drive ; which drive was this for?
136 mov ax, Code ; get Code segment
137 mov ds, ax ; set code segment
138 assume ds:code
139 mov al, 1 ; assume drive 0
140 shl al, cl ; set proper bit depending on drive
141 or ds:EC35_Flag, al ; set the bit in the permanent flags
142
143Not_EC35:
144 pop dx ; fix up all the registers
145 pop cx
146 pop bx
147 pop ax
148 pop ds
149 assume ds:nothing
150 ret
151
152;
153; Replace default values for further DRIVPARM commands
154;
155DiddleBack:
156 push ds
157 push cs
158 pop ds
159 assume ds:sysinitseg
160 mov word ptr DeviceParameters.DP_Cylinders,80
161 mov byte ptr DeviceParameters.DP_DeviceType, DEV_3INCH720KB
162 mov word ptr DeviceParameters.DP_DeviceAttributes,0
163 mov word ptr switches,0 ; zero all switches
164 pop ds
165 assume ds:nothing
166 ret
167
168;
169; Entry point is ParseLine. AL contains the first character in command line.
170;
171ParseLine: ; don't get character first time
172 push ds
173 push cs
174 pop ds
175 ASSUME DS:SYSINITSEG
176NextSwtch:
177 cmp al,CR ; carriage return?
178 jz done_line
179 cmp al,LF ; linefeed?
180 jz put_back ; put it back and done
181; Anything less or equal to a space is ignored.
182 cmp al,' ' ; space?
183 jbe get_next ; skip over space
184 cmp al,'/'
185 jz getparm
186 stc ; mark error invalid-character-in-input
187 jmp short exitpl
188
189getparm:
190 call Check_Switch
191 mov word ptr Switches,BX ; save switches read so far
192 jc swterr
193get_next:
194 invoke getchr
195 jc done_line
196 jmp NextSwtch
197swterr:
198 jmp exitpl ; exit if error
199
200done_line:
201 test word ptr Switches,flagdrive ; see if drive specified
202 jnz okay
203 stc ; mark error no-drive-specified
204 jmp short exitpl
205
206okay:
207 mov ax,word ptr switches
208 and ax,0003H ; get flag bits for changeline and non-rem
209 mov word ptr DeviceParameters.DP_DeviceAttributes,ax
210 mov word ptr DeviceParameters.DP_TrackTableEntries, 0
211 clc ; everything is fine
212 call SetDeviceParameters
213exitpl:
214 pop ds
215 ret
216
217put_back:
218 inc count ; one more char to scan
219 dec chrptr ; back up over linefeed
220 jmp short done_line
221;
222; Processes a switch in the input. It ensures that the switch is valid, and
223; gets the number, if any required, following the switch. The switch and the
224; number *must* be separated by a colon. Carry is set if there is any kind of
225; error.
226;
227Check_Switch:
228 invoke getchr
229 jc err_check
230 and al,0DFH ; convert it to upper case
231 cmp al,'A'
232 jb err_check
233 cmp al,'Z'
234 ja err_check
235 push es
236 push cs
237 pop es
238 mov cl,byte ptr switchlist ; get number of valid switches
239 mov ch,0
240 mov di,1+offset switchlist ; point to string of valid switches
241 repne scasb
242 pop es
243 jnz err_check
244 mov ax,1
245 shl ax,cl ; set bit to indicate switch
246 mov bx,word ptr switches ; get switches so far
247 or bx,ax ; save this with other switches
248 mov cx,ax
249 test ax, switchnum ; test against switches that require number to follow
250 jz done_swtch
251 invoke getchr
252 jc err_Swtch
253 cmp al,':'
254 jnz err_swtch
255 invoke getchr
256 push bx ; preserve switches
257 mov byte ptr cs:sepchr,' ' ; allow space separators
258 call GetNum
259 mov byte ptr cs:sepchr,0
260 pop bx ; restore switches
261; Because GetNum does not consider carriage-return or line-feed as OK, we do
262; not check for carry set here. If there is an error, it will be detected
263; further on (hopefully).
264 call Process_Num
265
266done_swtch:
267 clc
268 ret
269
270err_swtch:
271 xor bx,cx ; remove this switch from the records
272err_check:
273 stc
274 ret
275
276;
277; This routine takes the switch just input, and the number following (if any),
278; and sets the value in the appropriate variable. If the number input is zero
279; then it does nothing - it assumes the default value that is present in the
280; variable at the beginning. Zero is OK for form factor and drive, however.
281;
282Process_Num:
283 test word ptr Switches,cx ; if this switch has been done before,
284 jnz done_ret ; ignore this one.
285 test cx,flagdrive
286 jz try_f
287 mov byte ptr drive,al
288 jmp short done_ret
289
290try_f:
291 test cx,flagff
292 jz try_t
293; Ensure that we do not get bogus form factors that are not supported
294 ;cmp al,Max_Dev_Type
295 ;ja done_ret
296 mov byte ptr DeviceParameters.DP_DeviceType,al
297 jmp short done_ret
298
299try_t:
300 or ax,ax
301 jz done_ret ; if number entered was 0, assume default value
302 test cx,flagcyln
303 jz try_s
304 mov word ptr DeviceParameters.DP_Cylinders,ax
305 jmp short done_ret
306
307try_s:
308 test cx,flagseclim
309 jz try_h
310 mov word ptr slim,ax
311 jmp short done_ret
312;
313; Must be for number of heads
314try_h:
315 mov word ptr hlim,ax
316
317done_ret:
318 clc
319 ret
320
321;
322; SetDeviceParameters sets up the recommended BPB in each BDS in the
323; system based on the form factor. It is assumed that the BPBs for the
324; various form factors are present in the BPBTable. For hard files,
325; the Recommended BPB is the same as the BPB on the drive.
326; No attempt is made to preserve registers since we are going to jump to
327; SYSINIT straight after this routine.
328;
329SetDeviceParameters:
330 push es
331 push cs
332 pop es
333ASSUME ES:SYSINITSEG
334 xor bx,bx
335 mov bl,byte ptr DeviceParameters.DP_DeviceType
336 cmp bl,DEV_5INCH
337 jnz Got_80
338 mov cx,40 ; 48tpi has 40 cylinders
339 mov word ptr DeviceParameters.DP_Cylinders,cx
340Got_80:
341 shl bx,1 ; get index into BPB table
342 mov si,offset BPBTable
343 mov si,word ptr [si+bx] ; get address of BPB
344Set_RecBPB:
345 mov di,offset DeviceParameters.DP_BPB ; es:di -> BPB
346 mov cx,size a_BPB
347 cld
348 repe movsb
349 pop es
350ASSUME ES:NOTHING
351 test word ptr switches,flagseclim
352 jz see_heads
353 mov ax,word ptr slim
354 mov word ptr DeviceParameters.DP_BPB.BPB_SectorsPerTrack,ax
355see_heads:
356 test word ptr switches,flagheads
357 jz Set_All_Done
358 mov ax,word ptr hlim
359 mov word ptr DeviceParameters.DP_BPB.BPB_Heads,ax
360;
361; We need to set the media byte and the total number of sectors to reflect the
362; number of heads. We do this by multiplying the number of heads by the number
363; of 'sectors per head'. This is not a fool-proof scheme!!
364;
365 mov cx,ax ; cx has number of heads
366 dec cl ; get it 0-based
367 mov ax,DeviceParameters.DP_BPB.BPB_TotalSectors ; this is OK for two heads
368 sar ax,1 ; ax contains # of sectors/head
369 sal ax,cl
370 jc Set_All_Done ; We have too many sectors - overflow!!
371 mov DeviceParameters.DP_BPB.BPB_TotalSectors,ax
372; Set up correct Media Descriptor Byte
373 cmp cl,1
374 mov bl,0F0H
375 mov al,2 ; AL contains sectors/cluster
376 ja Got_Correct_Mediad
377 mov bl,byte ptr DeviceParameters.DP_BPB.BPB_MediaDescriptor
378 je Got_Correct_Mediad
379; We have one head - OK for 48tpi medium
380 mov al,1 ; AL contains sectors/cluster
381 mov ch,DeviceParameters.DP_DeviceType
382 cmp ch,DEV_5INCH
383 jz Dec_Mediad
384 mov bl,0F0H
385 jmp short Got_Correct_Mediad
386Dec_Mediad:
387 dec bl ; adjust for one head
388Got_Correct_Mediad:
389 mov byte ptr DeviceParameters.DP_BPB.BPB_MediaDescriptor,bl
390 mov byte ptr DeviceParameters.DP_BPB.BPB_SectorsPerCluster,al
391 clc
392Set_All_Done:
393 RET
394
395ASSUME DS:NOTHING, ES:NOTHING
396
397NOCHAR1: STC
398 return
399
400ORGANIZE:
401 MOV CX,[COUNT]
402 JCXZ NOCHAR1
403 CALL MAPCASE
404 XOR SI,SI
405 MOV DI,SI
406 xor ax,ax
407 mov COM_Level, 0
408
409;ORG1: CALL GET ;SKIP LEADING CONTROL CHARACTERS
410; CMP AL,' '
411; JB ORG1
412Org1:
413 call Skip_Comment ;AN000;
414 jz End_Commd_Line ;AN000; found a comment string and skipped.
415 call Get2 ;AN000; Not a comment string. Then get a char.
416 cmp al, LF ;AN000;
417 je End_Commd_Line ;AN000; starts with a blank line.
418 cmp al, ' ' ;AN000;
419 jbe Org1 ;AN000; skip leading control characters
420 jmp Findit ;AN000;
421End_Commd_Line: ;AN000;
422 stosb ;AN000; store line feed char in buffer for the LineCount.
423 mov COM_Level, 0 ;AN000; reset the command level.
424 jmp Org1 ;AN000;
425Findit: ;AN000;
426 PUSH CX
427 PUSH SI
428 PUSH DI
429 MOV BP,SI
430 DEC BP
431 MOV SI,OFFSET COMTAB ;Prepare to search command table
432 MOV CH,0
433FINDCOM:
434 MOV DI,BP
435 MOV CL,[SI]
436 INC SI
437 JCXZ NOCOM
438 REPE CMPSB
439 LAHF
440 ADD SI,CX ;Bump to next position without affecting flags
441 SAHF
442 LODSB ;Get indicator letter
443 JNZ FINDCOM
444 cmp byte ptr es:[di], CR ;AN011;The next char might be CR,LF
445 je GotCom0 ;AN011; such as in "REM",CR,LF case.
446 cmp byte ptr es:[di], LF ;AN011;
447 je GotCom0 ;AN011;
448 push ax ;AN010;
449 mov al, byte ptr es:[di] ;AN010;Now the next char. should be a delim.
450 call delim ;AN010;
451 pop ax ;AN010;
452 jnz findcom ;AN010;
453GotCom0:
454 POP DI
455 POP SI
456 POP CX
457 JMP SHORT GOTCOM
458
459NOCOM:
460 POP DI
461 POP SI
462 POP CX
463 MOV AL,'Z'
464 stosb ;AN000; save indicator char.
465Skip_Line: ;AN000;
466 call Get2 ;AN000;
467 cmp al, LF ;AN000; skip this bad command line
468 jne Skip_Line ;AN000;
469 jmp End_Commd_Line ;AN000; handle next command line
470
471GOTCOM: STOSB ;SAVE INDICATOR CHAR IN BUFFER
472 mov Cmd_Indicator, al ;AN000; save it for the future use.
473
474ORG2: CALL GET2 ;SKIP the commad name UNTIL DELIMITER
475 cmp al, LF ;AN011;
476 je Org21 ;AN011;
477 cmp al, CR ;AN011;
478 je Org21 ;AN011;
479 CALL DELIM ;
480 JNZ ORG2
481 jmp short Org3 ;AN011;
482Org21: ;AN011;if CR or LF then
483 dec si ;AN011; undo SI, CX register
484 inc cx ;AN011; and continue
485
486;ORG4: CALL GET2
487; call Delim ;J.K. 5/30/86. To permit "device=filename/p..." stuff.
488; jz ORG_EXT ;J.K. 5/30/86
489;Org4_Cont:
490; STOSB
491; CMP AL,' '
492; JA ORG4
493; CMP AL,10
494; JZ ORG1
495;
496; MOV BYTE PTR ES:[DI-1],0
497
498Org3:
499 cmp Cmd_Indicator, 'Y' ;AN000; Comment= command?
500 je Get_Cmt_Token ;AN000;
501 cmp Cmd_Indicator, 'I' ;AN000; Install= command?
502 je Org_file ;AN000;
503 cmp Cmd_Indicator, 'D' ;AN000; Device= command?
504 je Org_file ;AN000;
505 cmp Cmd_Indicator, 'J' ;AN000; IFS= command?
506 je Org_file ;AN000;
507 cmp Cmd_Indicator, 'S' ;AN000; Shell= is a special one!!!
508 je Org_file ;AN000;
509 cmp Cmd_Indicator, '1' ;AN013; SWITCHES= command?
510 je Org_Switch ;AN013;
511 jmp Org4 ;AN000;
512Org_Switch:
513 call Skip_Comment ;AN013;
514 jz End_Commd_Line_Brdg ;AN013;
515 call Get2 ;AN013;
516 call Org_Delim ;AN013;
517 jz Org_Switch ;AN013;
518 stosb ;AN013;
519 jmp Org5 ;AN013;
520Org_file: ;AN000; Get the filename and put 0 at end,
521 call Skip_Comment ;AN000;
522 jz Org_Put_Zero ;AN000;
523 call Get2 ;AN000; Not a comment
524 call Delim ;AN000;
525 jz Org_file ;AN000; Skip the possible delimeters
526 stosb ;AN000; copy the first non delim char found in buffer
527Org_Copy_File: ;AN000;
528 call Skip_Comment ;AN000; comment char in the filename?
529 jz Org_Put_Zero ;AN000; then stop copying filename at that point
530 call Get2 ;AN000;
531 cmp al, '/' ;AN000; a switch char? (device=filename/xxx)
532 je End_File_slash ;AN000; this will be the special case.
533 stosb ;AN000; save the char. in buffer
534 call Delim ;AN000;
535 jz End_Copy_File ;AN000;
536 cmp al, ' ' ;AN000;
537 ja Org_Copy_File ;AN000; keep copying
538 jmp End_Copy_File ;AN000; otherwise, assume end of the filename.
539Get_Cmt_token: ;AN000; get the token. Just max. 2 char.
540 call Get2 ;AN000;
541 cmp al, ' ' ;AN000; skip white spaces or "=" char.
542 je Get_Cmt_Token ;AN000; (we are allowing the other special
543 cmp al, TAB ;AN000; charaters can used for comment id.
544 je Get_Cmt_Token ;AN000; character.)
545 cmp al, '=' ;AN000; = is special in this case.
546 je Get_Cmt_Token ;AN000;
547 cmp al, CR ;AN000;
548 je Get_Cmt_End ;AN000; cannot accept the carridge return
549 cmp al, LF ;AN000;
550 je Get_Cmt_End ;AN000;
551 mov CMMT1, al ;AN000; store it
552 mov CMMT, 1 ;AN000; 1 char. so far.
553 call Get2 ;AN000;
554 cmp al, ' ' ;AN000;
555 je Get_Cmt_End ;AN000;
556 cmp al, TAB ;AN000;
557 je Get_Cmt_End ;AN000;
558 cmp al, CR ;AN000;
559 je Get_Cmt_End ;AN000;
560 cmp al, LF ;AN000;
561 je End_Commd_Line_Brdg ;AN000;
562 mov CMMT2, al ;AN000;
563 inc CMMT ;AN000;
564Get_Cmt_End: ;AN000;
565 call Get2 ;AN000;
566 cmp al, LF ;AN000;
567 jne Get_Cmt_End ;AN000; skip it.
568End_Commd_Line_Brdg: jmp End_Commd_Line ;AN000; else jmp to End_Commd_Line
569
570Org_Put_Zero: ;AN000; Make the filename in front of
571 mov byte ptr es:[di], 0 ;AN000; the comment string to be an asciiz.
572 inc di ;AN000;
573 jmp End_Commd_Line ;AN000; (Maybe null if device=/*)
574End_file_slash: ;AN000; AL = "/" option char.
575 mov byte ptr es:[di],0 ;AN000; make a filename an asciiz
576 inc di ;AN000; and
577 stosb ;AN000; store "/" after that.
578 jmp Org5 ;AN000; continue with the rest of the line
579
580End_Copy_File: ;AN000;
581 mov byte ptr es:[di-1], 0 ;AN000; make it an asciiz and handle the next char.
582 cmp al, LF ;AN000;
583 je End_Commd_Line_brdg ;AN000;
584 jmp Org5 ;AN000;
585
586Org4: ;AN000; Org4 skips all delimiters after the command name except for '/'
587 call Skip_Comment ;AN000;
588 jz End_Commd_Line_brdg ;AN000;
589 call Get2 ;AN000;
590 call Org_Delim ;AN000; skip delimiters EXCEPT '/' (mrw 4/88)
591 jz Org4 ;AN000;
592 jmp Org51 ;AN000;
593Org5: ;AN000; rest of the line
594 call Skip_Comment ;AN000; Comment?
595 jz End_Commd_Line_brdg ;AN000;
596 call Get2 ;AN000; Not a comment.
597Org51: ;AN000;
598 stosb ;AN000; copy the character
599 cmp al, '"' ;AN000; a quote ?
600 je At_Quote ;AN000;
601 cmp al, ' ' ;AN000;
602 ja Org5 ;AN000;
603 cmp al, LF ;AN000; line feed?
604 je Org1_brdg ;AN000; handles the next command line.
605 jmp Org5 ;AN000; handles next char in this line.
606Org1_brdg: jmp Org1 ;AN000;
607At_Quote: ;AN000;
608 cmp COM_Level, 0 ;AN000;
609 je Up_Level ;AN000;
610 mov COM_Level, 0 ;AN000; reset it.
611 jmp Org5 ;AN000;
612Up_Level: ;AN000;
613 inc COM_level ;AN000; set it.
614 jmp Org5 ;AN000;
615
616
617;ORG5: CALL GET2
618; STOSB
619; CMP AL,10
620; JNZ ORG5
621; JMP ORG1
622;
623;ORG_EXT:
624; cmp al,' ' ;space?
625; je Org4_Cont ;then do not make an exception. Go back.
626; cmp al,9 ;Tab?
627; je Org4_Cont
628; mov byte ptr es:[di], 0 ;put 0 at the current DI to make it an ASCIIZ
629; inc DI ;
630; stosb ;and copy the delimeter char.
631; jmp short ORG5 ;and continue as usual.
632
633
634GET2:
635 JCXZ NOGET
636 MOV AL,ES:[SI]
637 INC SI
638 DEC CX
639 return
640
641;GET: JCXZ NOGET
642; MOV AL,ES:[SI]
643; INC SI
644; DEC CX
645; CALL Org_DELIM
646; JZ GET
647; return
648
649Skip_Comment:
650;J.K.Skip the commented string until LF, if current es:si-> a comment string.
651;J.K.In) ES:SI-> sting
652;J.K. CX -> length.
653;J.K.Out) Zero flag not set if not found a comment string.
654;J.K. Zero flag set if found a comment string and skipped it. AL will contain
655;J.K. the line feed charater at this moment when return.
656;J.K. AX register destroyed.
657;J.K. If found, SI, CX register adjusted accordingly.
658
659 jcxz NoGet ;AN000; Get out of the Organize routine.
660 cmp COM_Level, 0 ;AN000; only check it if parameter level is 0.
661 jne No_Commt ;AN000; (Not inside quotations)
662
663 cmp CMMT, 1 ;AN000;
664 jb No_Commt ;AN000;
665 mov al, es:[si] ;AN000;
666 cmp CMMT1, al ;AN000;
667 jne No_Commt ;AN000;
668 cmp CMMT, 2 ;AN000;
669 jne Skip_Cmmt ;AN000;
670 mov al, es:[si+1] ;AN000;
671 cmp CMMT2, al ;AN000;
672 jne No_Commt ;AN000;
673Skip_Cmmt: ;AN000;
674 jcxz NoGet ;AN000; get out of Organize routine.
675 mov al, es:[si] ;AN000;
676 inc si ;AN000;
677 dec cx ;AN000;
678 cmp al, LF ;AN000; line feed?
679 jne Skip_Cmmt ;AN000;
680No_Commt: ;AN000;
681 ret ;AN000;
682
683
684DELIM:
685 CMP AL,'/' ;J.K. 5/30/86. IBM will assume "/" as an delimeter.
686 retz
687 cmp al, 0 ;J.K. 5/23/86 Special case for sysinit!!!
688 retz
689Org_Delim: ;AN000; Used by Organize routine except for getting
690 CMP AL,' ' ;the filename.
691 retz
692 CMP AL,9
693 retz
694 CMP AL,'='
695 retz
696 CMP AL,','
697 retz
698 CMP AL,';'
699 return
700
701
702NOGET: POP CX
703 MOV COUNT,DI
704 mov Org_Count, DI ;AN012;
705 XOR SI,SI
706 MOV CHRPTR,SI
707 return
708
709;Get3: jcxz NOGET ;J.K.do not consider '/',',' as a delim.
710; mov al, es:[si]
711; inc si
712; dec cx
713; call DELIM
714; jnz Get3_ret
715; cmp al,'/'
716; je Get3_ret
717; cmp al,','
718; jne Get3
719;Get3_ret:
720; ret
721
722
723
724;
725; NEWLINE RETURNS WITH FIRST CHARACTER OF NEXT LINE
726;
727NEWLINE:invoke GETCHR ;SKIP NON-CONTROL CHARACTERS
728 retc
729 CMP AL,LF ;LOOK FOR LINE FEED
730 JNZ NEWLINE
731 invoke GETCHR
732 return
733
734MAPCASE:
735 PUSH CX
736 PUSH SI
737 PUSH DS
738 PUSH ES
739 POP DS
740 XOR SI,SI
741CONVLOOP:
742 LODSB
743
744 IF KANJI
745 CALL TESTKANJ
746 JZ NORMCONV
747 INC SI ;Skip next char
748 DEC CX
749 JCXZ CONVDONE ;Just ignore 1/2 kanji error
750;Fall through, know AL is not in 'a'-'z' range
751NORMCONV:
752 ENDIF
753
754 CMP AL,'a'
755 JB NOCONV
756 CMP AL,'z'
757 JA NOCONV
758 SUB AL,20H
759 MOV [SI-1],AL
760NOCONV:
761 LOOP CONVLOOP
762CONVDONE:
763 POP DS
764 POP SI
765 POP CX
766 return
767
768 IF KANJI
769TESTKANJ:
770 CMP AL,81H
771 JB NOTLEAD
772 CMP AL,9FH
773 JBE ISLEAD
774 CMP AL,0E0H
775 JB NOTLEAD
776 CMP AL,0FCH
777 JBE ISLEAD
778NOTLEAD:
779 PUSH AX
780 XOR AX,AX ;Set zero
781 POP AX
782 return
783
784ISLEAD:
785 PUSH AX
786 XOR AX,AX ;Set zero
787 INC AX ;Reset zero
788 POP AX
789 return
790 ENDIF
791
792ASSUME DS:NOTHING
793
794Yes_Break_Failed: ;device driver Init failed and aborted.
795 stc
796 pop ax
797 return
798
799SET_BREAK:
800;J.K. 8/14/86 For DOS 3.3, this routine is modified to take care of the
801;Device driver's initialization error and abort.
802;If [break_addr+2] == [memhi] && [break_addr] = 0 then assume
803;that the device driver's initialization has an error and wanted to
804;abort the device driver. In this case, this routine will set carry
805;and return to the caller.
806;J.K. 6/26/87 If MultDeviceFlag <> 0, then do not perform the check.
807;This is to allow the multiple character device driver which uses
808;the same ending address segment with the offset value 0 for each
809;of the drives.
810
811 PUSH AX
812 MOV AX,WORD PTR [BREAK_ADDR+2] ;REMOVE THE INIT CODE
813 cmp MultDeviceFlag, 0 ;AN001;
814 jne Set_Break_Continue ;AN001;Do not check it.
815 cmp ax, [MEMHI]
816 jne Set_Break_Continue ;if not same, then O.K.
817
818 cmp word ptr [BREAK_ADDR],0
819 je Yes_Break_failed ;[Break_addr+2]=[MEMHI] & [Break_addr]=0
820
821Set_Break_Continue:
822 MOV [MEMHI],AX
823 MOV AX,WORD PTR [BREAK_ADDR]
824 MOV [MEMLO],AX
825 POP AX ; NOTE FALL THROUGH
826 or [SetDevMarkFlag], SETBRKDONE ;AN005; Signal the successful Set_break
827
828;
829; Round the values in MEMLO and MEMHI to paragraph boundary.
830; Perform bounds check.
831;
832ROUND:
833 PUSH AX
834 MOV AX,[MEMLO]
835
836 invoke ParaRound ; para round up
837
838 ADD [MEMHI],AX
839 MOV [MEMLO],0
840 mov ax,memhi ; ax = new memhi
841 CMP AX,[ALLOCLIM] ; if new memhi >= alloclim, error
842 JAE MEM_ERR
843 test cs:[SetDevMarkFlag], FOR_DEVMARK ;AN005;
844 jz Skip_Set_DEVMARKSIZE ;AN005;
845 push es ;AN005;
846 push si ;AN005;
847 mov si, cs:[DevMark_Addr] ;AN005;
848 mov es, si ;AN005;
849 sub ax, si ;AN005;
850 dec ax ;AN005;
851 mov es:[DEVMARK_SIZE], ax ;AN005; Paragraph
852 and cs:[SetDevMarkFlag], NOT_FOR_DEVMARK ;AN005;
853 pop si ;AN005;
854 pop es ;AN005;
855Skip_Set_DEVMARKSIZE: ;AN005;
856 POP AX
857 clc ;clear carry
858 return
859
860MEM_ERR:
861 MOV DX,OFFSET BADMEM
862 PUSH CS
863 POP DS
864 CALL PRINT
865 JMP STALL
866
867CALLDEV:MOV DS,WORD PTR CS:[ENTRY_POINT+2]
868 ADD BX,WORD PTR CS:[ENTRY_POINT] ;Do a little relocation
869 MOV AX,DS:[BX]
870 PUSH WORD PTR CS:[ENTRY_POINT]
871 MOV WORD PTR CS:[ENTRY_POINT],AX
872 MOV BX,OFFSET PACKET
873 CALL [ENTRY_POINT]
874 POP WORD PTR CS:[ENTRY_POINT]
875 return
876
877BADNUM:
878 MOV sepchr,0
879 XOR AX,AX ; Set Zero flag, and AX = 0
880 pop bx ; J.K.
881 stc ; AND carry set
882 return
883
884ToDigit:
885 SUB AL,'0'
886 JB NotDig
887 CMP AL,9
888 JA NotDig
889 CLC
890 return
891NotDig: STC
892 return
893
894; GetNum parses a decimal number.
895; Returns it in AX, sets zero flag if AX = 0 (MAY BE considered an
896; error), if number is BAD carry is set, zero is set, AX=0.
897GETNUM: push bx ; J.K.
898 XOR BX,BX ; running count is zero
899B2: CALL ToDigit ; do we have a digit
900 JC BadNum ; no, bomb
901 XCHG AX,BX ; put total in AX
902 PUSH BX ; save digit
903 MOV BX,10 ; base of arithmetic
904 MUL BX ; shift by one decimal di...
905 POP BX ; get back digit
906 ADD AL,BL ; get total
907 ADC AH,0 ; make that 16 bits
908 JC BADNUM ; too big a number
909 XCHG AX,BX ; stash total
910
911 invoke GETCHR ;GET NEXT DIGIT
912 JC B1 ; no more characters
913 cmp al, ' ' ;J.K. 5/23/86 space?
914 jz B15 ;J.K. 5/23/86 then end of digits
915 cmp al, ',' ;J.K. 5/23/86 ',' is a seperator!!!
916 jz B15 ;J.K. 5/23/86 then end of digits.
917 cmp al, TAB ;J.K. 5/23/86 TAB
918 jz B15 ;J.K.
919 CMP AL,SepChr ; allow 0 or special separators
920 JZ b15
921 cmp al,SWTCHR ; See if another switch follows
922 JZ b15
923 cmp al,LF ; Line-feed?
924 jz b15
925 cmp al,CR ; Carriage return?
926 jz b15
927 OR AL,AL ; end of line separator?
928 JNZ B2 ; no, try as a valid char...
929b15: INC COUNT ; one more character to s...
930 DEC CHRPTR ; back up over separator
931B1: MOV AX,BX ; get proper count
932 OR AX,AX ; Clears carry, sets Zero accordingly
933 pop bx
934 return
935
936SKIP_DELIM proc near ;J.K.
937;Skip the delimeters pointed by CHRPTR. AL will contain the first non delimeter
938;character encountered and CHRPTR will point to the next character.
939;This rouitne will assume the second "," found as a non delimiter character. So
940;in case if the string is " , , ", this routine will stop at the second ",". At
941;this time, Zero flag is set.
942;If COUNT is exhausted, then carry will be set.
943Skip_delim_char:
944 call getchr
945 jc Skip_delim_exit
946 cmp al, ',' ;the first comma?
947 je Skip_delim_next
948 call delim ;check the charater in AL.
949 jz Skip_delim_char
950 jmp short Skip_delim_exit ;found a non delim char
951Skip_delim_next:
952 call getchr
953 jc Skip_delim_exit
954 cmp al, ',' ;the second comma?
955 je Skip_delim_exit ;done
956 call delim
957 jz Skip_delim_next
958Skip_delim_exit:
959 return
960SKIP_DELIM endp
961
962;J.K. 5/26/86 *****************************************************************
963SetDOSCountryInfo proc near
964;Input: ES:DI -> pointer to DOS_COUNTRY_CDPG_INFO
965; DS:0 -> buffer.
966; SI = 0
967; AX = country id
968; DX = code page id. (If 0, then use ccSysCodePage as a default.)
969; BX = file handle
970; This routine can handle maxium 72 COUNTRY_DATA entries.
971;Output: DOS_country_cdpg_info set.
972; Carry set if any file read failure or wrong information in the file.
973; Carry set and CX = -1 if cannot find the matching COUNTRY_id, CODEPAGE
974; _id in the file.
975
976 push di
977 push ax
978 push dx
979
980 xor cx,cx
981 xor dx,dx
982 mov ax, 512 ;read 512 bytes
983 call ReadInControlBuffer ;Read the file header
984 jc SetDOSData_fail
985 push es
986 push si
987 push cs
988 pop es
989 mov di, offset COUNTRY_FILE_SIGNATURE
990 mov cx, 8 ;length of the signature
991 repz cmpsb
992 pop si
993 pop es
994 jnz SetDOSData_fail ;signature mismatch
995
996 add si, 18 ;SI -> county info type
997 cmp byte ptr ds:[si], 1 ;Only accept type 1 (Currently only 1 header type)
998 jne SetDOSData_fail ;cannot proceed. error return
999 inc si ;SI -> file offset
1000 mov dx, word ptr ds:[si] ;Get the INFO file offset.
1001 mov cx, word ptr ds:[si+2]
1002 mov ax, 1024 ;read 1024 bytes.
1003 call ReadInControlBuffer ;Read INFO
1004 jc SetDOSData_fail
1005 mov cx, word ptr ds:[si] ;get the # of country, codepage combination entries
1006 cmp cx, 72 ;cannot handle more than 72 entries.
1007 ja SetDOSData_fail
1008 inc si
1009 inc si ;SI -> entry information packet
1010 pop dx ;restore code page id
1011 pop ax ;restore country id
1012 pop di
1013
1014SetDOSCntry_find: ;Search for desired country_id,codepage_id.
1015 cmp ax, word ptr ds:[si+2] ;compare country_id
1016 jne SetDOSCntry_next
1017 cmp dx, 0 ;No user specified code page ?
1018 je SetDOSCntry_any_codepage;then no need to match code page id.
1019 cmp dx, word ptr ds:[si+4] ;compare code page id
1020 je SetDOSCntry_got_it
1021SetDOSCntry_next:
1022 add si, word ptr ds:[si] ;next entry
1023 inc si
1024 inc si ;take a word for size of entry itself
1025 loop SetDOSCntry_find
1026 mov cx, -1 ;signals that bad country id entered.
1027SetDOSCntry_fail:
1028 stc
1029 ret
1030
1031SetDOSData_fail:
1032 pop si
1033 pop cx
1034 pop di
1035 jmp short SetDOSCntry_fail
1036
1037SetDOSCntry_any_CodePage: ;use the code_page_id of the country_id found.
1038 mov dx, word ptr ds:[si+4]
1039SetDOSCntry_got_it: ;found the matching entry
1040 mov cs:CntryCodePage_Id, dx ;save code page ID for this country.
1041 mov dx, word ptr ds:[si+10] ;get the file offset of country data
1042 mov cx, word ptr ds:[si+12]
1043 mov ax, 512 ;read 512 bytes
1044 call ReadInControlBuffer
1045 jc SetDOSCntry_fail
1046 mov cx, word ptr ds:[si] ;get the number of entries to handle.
1047 inc si
1048 inc si ;SI -> first entry
1049
1050SetDOSCntry_data:
1051 push di ;ES:DI -> DOS_COUNTRY_CDPG_INFO
1052 push cx ;save # of entry left
1053 push si ;si -> current entry in Control buffer
1054
1055 mov al, byte ptr ds:[si+2] ;get data entry id
1056 call GetCountryDestination ;get the address of destination in ES:DI
1057 jc SetDOSCntry_data_next ;No matching data entry id in DOS
1058
1059
1060 mov dx, word ptr ds:[si+4] ;get offset of data
1061 mov cx, word ptr ds:[si+6]
1062 mov ax, 4200h
1063 stc
1064 int 21h ;move pointer
1065 jc SetDOSData_fail
1066 mov dx, 512 ;start of data buffer
1067; mov cx, word ptr es:[di] ;length of the corresponding data in DOS.
1068; add cx, 10 ;Signature + A word for the length itself
1069 mov cx, 20 ;read 20 bytes only. We only need to
1070 mov ah, 3fh ;look at the length of the data in the file.
1071 stc
1072 int 21h ;read the country.sys data
1073 jc SetDOSData_fail ;read failure
1074 cmp ax, cx
1075 jne SetDOSData_fail
1076
1077 mov dx, word ptr ds:[si+4] ;AN008;get offset of data again.
1078 mov cx, word ptr ds:[si+6] ;AN008;
1079 mov ax, 4200h ;AN008;
1080 stc ;AN008;
1081 int 21h ;AN008;move pointer back again
1082 jc SetDOSData_fail ;AN008;
1083
1084 push si ;AN008;
1085 mov si, (512+8) ;AN008;get length of the data from the file
1086 mov cx, word ptr ds:[si] ;AN008;
1087 pop si ;AN008;
1088 mov dx, 512 ;AN008;start of data buffer
1089 add cx, 10 ;AN008;Signature + A word for the length itself
1090 mov ah, 3fh ;AN008;Read the data from the file.
1091 stc ;AN008;
1092 int 21h ;AN008;
1093 jc SetDOSData_fail ;AN008;
1094 cmp ax, cx ;AN008;
1095 jne SetDOSData_fail ;AN008;
1096
1097 mov al, byte ptr ds:[si+2] ;save Data id for future use.
1098 mov si, (512+8) ;SI-> data buffer + id tag field
1099 mov cx, word ptr ds:[si] ;get the length of the file
1100 inc cx ;Take care of a word for lenght of tab
1101 inc cx ;itself.
1102 cmp cx, (2048 - 512 - 8) ;Fit into the buffer?
1103 ja SetDOSData_fail
1104 cmp al, SetCountryInfo ;is the data for SetCountryInfo table?
1105 jne SetDOSCntry_Mov ;no, don't worry
1106 push word ptr es:[di+ccMono_Ptr-ccCountryInfoLen] ;AN009;Cannot destroy ccMono_ptr address. Save them.
1107 push word ptr es:[di+ccMono_Ptr-ccCountryInfoLen+2] ;AN009;At this time DI -> ccCountryInfoLen
1108 push di ;save DI
1109
1110 push ax
1111 mov ax,cs:CntryCodePage_Id ;Do not use the Code Page info in Country_Info
1112 mov ds:[si+4], ax ;Use the saved one for this !!!!
1113 pop ax
1114
1115SetDOSCntry_Mov:
1116 rep movsb ;copy the table into DOS
1117 cmp al, SetCountryInfo ;was the ccMono_ptr saved?
1118 jne SetDOSCntry_data_next
1119 pop di ;restore DI
1120 pop word ptr es:[di+ccMono_Ptr-ccCountryInfoLen+2] ;AN009;restore
1121 pop word ptr es:[di+ccMono_Ptr-ccCountryInfoLen] ;AN009;
1122
1123SetDOSCntry_data_next:
1124 pop si ;restore control buffer pointer
1125 pop cx ;restore # of entries left
1126 pop di ;restore pointer to DSO_COUNTRY_CDPG
1127 add si, word ptr ds:[si] ;try to get the next entry
1128 inc si
1129 inc si ;take a word of entry length itself
1130; loop SetDOSCntry_data
1131 dec cx ;AN008;
1132 cmp cx,0 ;AN008;
1133 je SetDOSCntry_OK ;AN008;
1134 jmp SetDOSCntry_data ;AN008;
1135SetDOSCntry_OK: ;AN008;
1136 ret
1137SetDOSCountryInfo endp
1138;
1139
1140GetCountryDestination proc near
1141;Get the destination address in the DOS country info table.
1142;Input: AL - Data ID
1143; ES:DI -> DOS_COUNTRY_CDPG_INFO
1144;On return:
1145; ES:DI -> Destination address of the matching data id
1146; carry set if no matching data id found in DOS.
1147
1148 push cx
1149 add di, ccNumber_of_entries ;skip the reserved area, syscodepage etc.
1150 mov cx, word ptr es:[di] ;get the number of entries
1151 inc di
1152 inc di ;SI -> the first start entry id
1153GetCntryDest:
1154 cmp byte ptr es:[di], al
1155 je GetCntryDest_OK
1156 cmp byte ptr es:[di], SetCountryInfo ;was it SetCountryInfo entry?
1157 je GetCntryDest_1
1158 add di, 5 ;next data id
1159 jmp short GetCntryDest_loop
1160GetCntryDest_1:
1161 add di, NEW_COUNTRY_SIZE + 3 ;next data id
1162GetCntryDest_loop:
1163 loop GetCntryDest
1164 stc
1165 jmp short GetCntryDest_exit
1166GetCntryDest_OK:
1167 cmp al, SetCountryInfo ;select country info?
1168 jne GetCntryDest_OK1
1169 inc di ;now DI -> ccCountryInfoLen
1170 jmp short GetCntryDest_exit
1171GetCntryDest_OK1:
1172 les di, dword ptr es:[di+1] ;get the destination in ES:DI
1173GetCntryDest_Exit:
1174 pop cx
1175 ret
1176GetCountryDestination endp
1177
1178;
1179ReadInControlBuffer proc near
1180;Move file pointer to CX:DX
1181;Read AX bytes into the control buffer. (Should be less than 2 Kb)
1182;SI will be set to 0 hence DS:SI points to the control buffer.
1183;Entry: CX,DX offset from the start of the file where the read/write pointer
1184; be moved.
1185; AX - # of bytes to read
1186; BX - file handle
1187; DS - buffer seg.
1188;Return: The control data information is read into DS:0 - DS:0200.
1189; CX,DX value destroyed.
1190; Carry set if error in Reading file.
1191;
1192 push ax ;# of bytes to read
1193 mov ax, 4200h
1194 stc
1195 int 21h ;move pointer
1196 pop cx ;# of bytes to read
1197 jc RICB_exit
1198 xor dx,dx ;ds:dx -> control buffer
1199 xor si,si
1200 mov ah,3fh ;read into the buffer
1201 stc
1202 int 21h ;should be less than 1024 bytes.
1203RICB_exit:
1204 ret
1205ReadInControlBuffer endp
1206
1207;
1208SET_COUNTRY_PATH proc near
1209;In: DS - SYSINITSEG, ES - CONFBOT, SI -> start of the asciiz path string
1210; DOSINFO_EXT, CNTRY_DRV, CNTRY_ROOT, CNTRY_PATH
1211; Assumes current directory is the ROOT directory.
1212;Out: DS:DI -> full path (CNTRY_DRV).
1213; Set the CNTRY_DRV string from the COUNTRY=,,path command.
1214; DS, ES, SI value saved.
1215
1216 push si
1217 push ds ;switch ds, es
1218 push es
1219 pop ds
1220 pop es ;now DS -> CONFBOT, ES -> SYSINITSEG
1221
1222 call chk_drive_letter ;current DS:[SI] is a drive letter?
1223 jc SCP_Default_drv ;no, use current default drive.
1224 mov al, byte ptr DS:[SI]
1225 inc si
1226 inc si ;SI -> next char after ":"
1227 jmp short SCP_SetDrv
1228SCP_Default_drv:
1229 mov ah, 19h
1230 int 21h
1231 add al, "A" ;convert it to a character.
1232SCP_SetDrv:
1233 mov cs:CNTRY_DRV, al ;set the drive letter.
1234 mov di, offset CNTRY_PATH
1235 mov al, byte ptr DS:[SI]
1236 cmp al, "\"
1237 je SCP_Root_Dir
1238 cmp al, cs:SWTCHR ;let's accept "/" as an directory delim
1239 je SCP_Root_Dir
1240 jmp short SCP_Path
1241SCP_Root_Dir:
1242 dec di ;DI -> CNTRY_ROOT
1243SCP_Path:
1244 call MOVE_ASCIIZ ;copy it
1245 mov di, offset CNTRY_DRV
1246SCPath_Exit:
1247 push ds ;switch ds, es
1248 push es
1249 pop ds
1250 pop es ;DS, ES value restored
1251 pop si
1252 RET
1253SET_COUNTRY_PATH endp
1254
1255;
1256CHK_DRIVE_LETTER proc near
1257;Check if DS:[SI] is a drive letter followed by ":".
1258;Assume that every alpha charater is already converted to UPPER CASE.
1259;Carry set if not.
1260;
1261 push ax
1262 cmp byte ptr ds:[si], "A"
1263 jb CDLetter_NO
1264 cmp byte ptr ds:[si], "Z"
1265 ja CDLetter_NO
1266 cmp byte ptr ds:[si+1], ":"
1267 jne CDLetter_NO
1268 jmp short CDLetter_exit
1269CDLetter_NO:
1270 stc
1271CDLetter_exit:
1272 pop ax
1273 ret
1274CHK_DRIVE_LETTER endp
1275
1276;
1277MOVE_ASCIIZ proc near
1278;In: DS:SI -> source ES:DI -> target
1279;Out: copy the string until 0.
1280;Assumes there exists a 0.
1281MASCIIZ_loop:
1282 movsb
1283 cmp byte ptr DS:[SI-1], 0 ;Was it 0?
1284 jne MASCIIZ_loop
1285 ret
1286MOVE_ASCIIZ endp
1287
1288;
1289; DS:DX POINTS TO STRING TO OUTPUT (ASCIZ)
1290;
1291; PRINTS <BADLD_PRE> <STRING> <BADLD_POST>
1292;
1293;
1294;
1295BADFIL:
1296 PUSH CS
1297 POP ES
1298 MOV SI,DX
1299BADLOAD:
1300 MOV DX,OFFSET BADLD_PRE ;WANT TO PRINT CONFIG ERROR
1301; MOV BX,OFFSET BADLD_POST
1302 mov bx, offset CRLFM ;AN006;
1303PRNERR:
1304 PUSH CS
1305 POP DS
1306 call Print
1307PRN1: MOV DL,ES:[SI]
1308 OR DL,DL
1309 JZ PRN2
1310 MOV AH,STD_CON_OUTPUT
1311 INT 21H
1312 INC SI
1313 JMP PRN1
1314PRN2: MOV DX,BX
1315 call Print
1316 cmp DoNotShowNum, 1 ;AN000; suppress line number when handling COMMAND.COM
1317 je Prnexit
1318 call Error_Line
1319PRNEXIT:
1320 return
1321
1322PRINT: MOV AH,STD_CON_STRING_OUTPUT
1323 INT 21H
1324 return
1325
1326
1327 IF NOEXEC
1328;
1329; LOAD NON EXE FILE CALLED [DS:DX] AT MEMORY LOCATION ES:BX
1330;
1331LDFIL:
1332 PUSH AX
1333 PUSH BX
1334 PUSH CX
1335 PUSH DX
1336 PUSH SI
1337 PUSH DS
1338 PUSH BX
1339 XOR AX,AX ;OPEN THE FILE
1340 MOV AH,OPEN
1341 STC ;IN CASE OF INT 24
1342 INT 21H
1343 POP DX ;Clean stack in case jump
1344 JC LDRET
1345 PUSH DX
1346 MOV BX,AX ;Handle in BX
1347 XOR CX,CX
1348 XOR DX,DX
1349 MOV AX,(LSEEK SHL 8) OR 2
1350 STC ;IN CASE OF INT 24
1351 INT 21H ; Get file size in DX:AX
1352 JC LDCLSP
1353 OR DX,DX
1354 JNZ LDERRP ; File >64K
1355 POP DX
1356 PUSH DX
1357 MOV CX,ES ; CX:DX is xaddr
1358 ADD DX,AX ; Add file size to Xaddr
1359 JNC DOSIZE
1360 ADD CX,1000H ; ripple carry
1361DOSIZE:
1362 mov ax,dx
1363 call ParaRound
1364 mov dx,ax
1365
1366 ADD CX,DX
1367 CMP CX,[ALLOCLIM]
1368 JB OKLD
1369 JMP MEM_ERR
1370
1371OKLD:
1372 XOR CX,CX
1373 XOR DX,DX
1374 MOV AX,LSEEK SHL 8 ;Reset pointer to beginning of file
1375 STC ;IN CASE OF INT 24
1376 INT 21H
1377 JC LDCLSP
1378 POP DX
1379 PUSH ES ;READ THE FILE IN
1380 POP DS ;Trans addr is DS:DX
1381 MOV CX,0FF00H ; .COM files arn't any bigger than
1382 ; 64k-100H
1383 MOV AH,READ
1384 STC ;IN CASE OF INT 24
1385 INT 21H
1386 JC LDCLS
1387 MOV SI,DX ;CHECK FOR EXE FILE
1388 CMP WORD PTR [SI],"ZM"
1389 CLC ; Assume OK
1390 JNZ LDCLS ; Only know how to do .COM files
1391 STC
1392 JMP SHORT LDCLS
1393
1394LDERRP:
1395 STC
1396LDCLSP:
1397 POP DX ;Clean stack
1398LDCLS:
1399 PUSHF
1400 MOV AH,CLOSE ;CLOSE THE FILE
1401 STC
1402 INT 21H
1403 POPF
1404
1405LDRET: POP DS
1406 POP SI
1407 POP DX
1408 POP CX
1409 POP BX
1410 POP AX
1411 return
1412 ENDIF
1413
1414;
1415; OPEN DEVICE POINTED TO BY DX, AL HAS ACCESS CODE
1416; IF UNABLE TO OPEN DO A DEVICE OPEN NULL DEVICE INSTEAD
1417;
1418OPEN_DEV:
1419 CALL OPEN_FILE
1420 JNC OPEN_DEV3
1421OPEN_DEV1:
1422 MOV DX,OFFSET NULDEV
1423 CALL OPEN_FILE
1424 return
1425
1426OPEN_DEV3:
1427 MOV BX,AX ; Handle from open to BX
1428 XOR AX,AX ; GET DEVICE INFO
1429 MOV AH,IOCTL
1430 INT 21H
1431 TEST DL,10000000B
1432 retnz
1433 MOV AH,CLOSE
1434 INT 21H
1435 JMP OPEN_DEV1
1436
1437OPEN_FILE:
1438 MOV AH,OPEN
1439 STC
1440 INT 21H
1441 return
1442
1443;J.K. TEST INT24. Return back to DOS with the fake user response of "FAIL"
1444INT24:
1445 mov al, 3 ;AN000; Fail the system call
1446 iret ;AN000; Return back to DOS.
1447
1448
1449;INT24: ADD SP,6 ;RESTORE MACHINE STATE
1450; POP AX
1451; POP BX
1452; POP CX
1453; POP DX
1454; POP SI
1455; POP DI
1456; POP BP
1457; POP DS
1458; POP ES
1459; PUSH AX
1460; MOV AH,GET_DEFAULT_DRIVE ;INITIALIZE DOS
1461; INT 21H
1462; POP AX
1463; IRET ;BACK TO USER
1464
1465 IF ALTVECT
1466BOOTMES DB 13,10,"MS-DOS version "
1467 DB MAJOR_VERSION + "0"
1468 DB "."
1469 DB (MINOR_VERSION / 10) + "0"
1470 DB (MINOR_VERSION MOD 10) + "0"
1471 DB 13,10
1472 DB "Copyright 1981,88 Microsoft Corp.",13,10,"$"
1473 ENDIF
1474
1475include copyrigh.inc ;P1821; Copyright statement
1476
1477NULDEV DB "NUL",0
1478CONDEV DB "CON",0
1479AUXDEV DB "AUX",0
1480PRNDEV DB "PRN",0
1481
1482CONFIG DB "\CONFIG.SYS",0
1483
1484CNTRY_DRV DB "A:"
1485CNTRY_ROOT DB "\"
1486CNTRY_PATH DB "COUNTRY.SYS",0
1487 DB 52 DUP (0)
1488
1489COUNTRY_FILE_SIGNATURE db 0FFh,'COUNTRY'
1490
1491CntryCodePage_Id DW ?
1492
1493COMMND DB "\COMMAND.COM",0
1494 DB 51 dup (0)
1495
1496PathString db 64 dup (0) ;AN014;
1497LShare db "SHARE.EXE",0,"/NC",0Dh,0Ah ;AN014;AN015;To be used by Load/exec.
1498 ;/NC parm will disable file sharing check.
1499
1500COMTAB LABEL BYTE
1501;;;; DB 8,"AVAILDEV",'A' ; NO LONGER SUPPORTED
1502 DB 7,"BUFFERS", 'B'
1503 DB 5,"BREAK", 'C'
1504 DB 6,"DEVICE", 'D'
1505 DB 5,"FILES", 'F'
1506 DB 4,"FCBS", 'X'
1507 DB 9,"LASTDRIVE",'L'
1508 db 10,"MULTITRACK", 'M' ;AN002;
1509 DB 8,"DRIVPARM", 'P' ; RS for DOS 3.2
1510 IF STACKSW
1511 DB 6,"STACKS", 'K' ; BAS for DOS 3.2
1512 ENDIF
1513 DB 7,"COUNTRY", 'Q'
1514 DB 5,"SHELL", 'S'
1515 db 7,"INSTALL", 'I' ;AN000;
1516 db 3,"IFS", 'J' ;AN000;
1517 db 4,"CPSW", 'W' ;AN000;
1518;;;; DB 8,"SWITCHAR",'W' ; NO LONGER SUPPORTED
1519 db 7,"COMMENT", 'Y' ;AN000;
1520 db 3,"REM", '0' ;AN004;
1521 db 8,"SWITCHES", '1' ;AN013;
1522 DB 0
1523
1524public DeviceParameters
1525DeviceParameters a_DeviceParameters <0,DEV_3INCH720KB,0,80>
1526
1527hlim dw 2
1528slim dw 9
1529
1530public drive
1531drive db ?
1532
1533public switches
1534Switches dw 0
1535
1536;
1537; The following are the recommended BPBs for the media that we know of so
1538; far.
1539
1540; 48 tpi diskettes
1541
1542BPB48T DW 512
1543 DB 2
1544 DW 1
1545 DB 2
1546 DW 112
1547 DW 2*9*40
1548 DB 0FDH
1549 DW 2
1550 DW 9
1551 DW 2
1552 DD 0
1553 DD 0
1554
1555; 96tpi diskettes
1556
1557BPB96T DW 512
1558 DB 1
1559 DW 1
1560 DB 2
1561 DW 224
1562 DW 2*15*80
1563 DB 0F9H
1564 DW 7
1565 DW 15
1566 DW 2
1567 DD 0
1568 DD 0
1569
1570; 3 1/2 inch diskette BPB
1571
1572BPB35 DW 512
1573 DB 2
1574 DW 1
1575 DB 2
1576 DW 70h
1577 DW 2*9*80
1578 DB 0F9H
1579 DW 3
1580 DW 9
1581 DW 2
1582 DD 0
1583 DD 0
1584
1585BPB35H DW 0200H
1586 DB 01H
1587 DW 0001H
1588 DB 02H
1589 DW 0E0h
1590 DW 0B40H
1591 DB 0F0H
1592 DW 0009H
1593 DW 0012H
1594 DW 0002H
1595 DD 0
1596 DD 0
1597
1598BPBTable dw BPB48T ; 48tpi drives
1599 dw BPB96T ; 96tpi drives
1600 dw BPB35 ; 3.5" drives
1601; The following are not supported, so default to 3.5" media layout
1602 dw BPB35 ; Not used - 8" drives
1603 dw BPB35 ; Not Used - 8" drives
1604 dw BPB35 ; Not Used - hard files
1605 dw BPB35 ; Not Used - tape drives
1606 dw BPB35H ; 3-1/2" 1.44MB drive
1607
1608switchlist db 8,"FHSTDICN" ; Preserve the positions of N and C.
1609
1610; The following depend on the positions of the various letters in SwitchList
1611
1612switchnum equ 11111000B ; which switches require number
1613
1614flagec35 equ 00000100B ; electrically compatible 3.5 inch disk drive
1615flagdrive equ 00001000B
1616flagcyln equ 00010000B
1617flagseclim equ 00100000B
1618flagheads equ 01000000B
1619flagff equ 10000000B
1620
1621SWTCHR EQU "/" ; switch follows this character
1622
1623SYSINITSEG ENDS
1624 END