DOS 3.30 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

867 lines
23 KiB

4 years ago
  1. TITLE BIOS SYSTEM INITIALIZATION
  2. TRUE EQU 0FFFFh
  3. FALSE EQU 0
  4. ;IBMVER EQU TRUE
  5. ;IBM EQU IBMVER
  6. STACKSW EQU TRUE ;Include Switchable Hardware Stacks
  7. ;IBMJAPVER EQU FALSE ;If TRUE set KANJI true also
  8. ;MSVER EQU FALSE
  9. ;ALTVECT EQU FALSE ;Switch to build ALTVECT version
  10. ;KANJI EQU FALSE
  11. INCLUDE version.inc
  12. IF IBMJAPVER
  13. NOEXEC EQU TRUE
  14. ELSE
  15. NOEXEC EQU FALSE
  16. ENDIF
  17. DOSSIZE EQU 0A000H
  18. .xlist
  19. include smdossym.inc ; Reduced version of DOSSYM.INC ;3.30
  20. INCLUDE devsym.inc
  21. include ioctl.inc
  22. include BIOSTRUC.INC ;3.30
  23. .list
  24. IF NOT IBMJAPVER
  25. EXTRN RE_INIT:FAR
  26. ENDIF
  27. SYSINITSEG SEGMENT PUBLIC 'SYSTEM_INIT'
  28. ASSUME CS:SYSINITSEG,DS:NOTHING,ES:NOTHING,SS:NOTHING
  29. EXTRN BADOPM:BYTE,CRLFM:BYTE,BADCOM:BYTE,BADMEM:BYTE,BADBLOCK:BYTE
  30. EXTRN BADSIZ_PRE:BYTE,BADLD_PRE:BYTE
  31. EXTRN BADSIZ_POST:BYTE,BADLD_POST:BYTE
  32. EXTRN BADSTACK:BYTE,BADCOUNTRYCOM:BYTE ;3.30
  33. EXTRN SYSSIZE:BYTE,BADCOUNTRY:BYTE,INSUFMEMORY:BYTE ;3.30
  34. EXTRN CONDEV:BYTE,AUXDEV:BYTE,PRNDEV:BYTE,COMMND:BYTE,CONFIG:BYTE
  35. EXTRN Cntry_Drv:BYTE,Cntry_Root:BYTE,Cntry_Path:BYTE ;3.30
  36. EXTRN DeviceParameters:byte ;3.30
  37. EXTRN MEMORY_SIZE:word ;3.30
  38. EXTRN BUFFERS:word ;3.30
  39. EXTRN FILES:byte,NUM_CDS:byte ;3.30
  40. EXTRN DOSINFO:dword,ENTRY_POINT:dword ;3.30
  41. EXTRN FCBS:byte,KEEP:byte ;3.30
  42. EXTRN CONFBOT:word,ALLOCLIM:word,COMMAND_LINE:byte ;3.30
  43. EXTRN ZERO:byte,SEPCHR:byte ;3.30
  44. EXTRN COUNT:word,CHRPTR:word,CNTRYFILEHANDLE:word ;3.30
  45. EXTRN MEMLO:word,MEMHI:word,PRMBLK:word,LDOFF:word ;3.30
  46. EXTRN PACKET:byte,UNITCOUNT:byte,BREAK_ADDR:dword ;3.30
  47. EXTRN BPB_ADDR:dword,DRIVENUMBER:byte,SYSI_COUNTRY:dword ;3.30
  48. ;3.30
  49. EXTRN MEM_ERR:NEAR,SetDOSCountryInfo:NEAR ;3.30
  50. EXTRN PARAROUND:NEAR,TEMPCDS:NEAR ;3.30
  51. EXTRN Set_Country_Path:NEAR,Move_ASCIIZ:NEAR,DELIM:NEAR ;3.30
  52. EXTRN BADFIL:NEAR,ROUND:NEAR ;3.30
  53. IF STACKSW
  54. ;
  55. ; Internal Stack Parameters
  56. EntrySize equ 8
  57. MinCount equ 8
  58. DefaultCount equ 9
  59. MaxCount equ 64
  60. MinSize equ 32
  61. DefaultSize equ 128
  62. MaxSize equ 512
  63. extrn stack_count:word ;3.30
  64. extrn stack_size:word ;3.30
  65. extrn stack_addr:dword ;3.30
  66. ENDIF
  67. PUBLIC DOCONF ;3.30
  68. PUBLIC GETCHR ;3.30
  69. ;*************************************************************************;3.30
  70. ;Take care of Config.sys file. ;3.30
  71. DOCONF:
  72. PUSH CS
  73. POP DS
  74. ASSUME DS:SYSINITSEG
  75. MOV AX,(CHAR_OPER SHL 8) ;GET SWITCH CHARACTER
  76. INT 21H
  77. MOV [COMMAND_LINE+1],DL ; Set in default command line
  78. MOV DX,OFFSET CONFIG ;NOW POINTING TO FILE DESCRIPTION
  79. MOV AX,OPEN SHL 8 ;OPEN FILE "CONFIG.SYS"
  80. STC ;IN CASE OF INT 24
  81. INT 21H ;FUNCTION REQUEST
  82. JC ENDCONF ;Wasn't there, or couldn't open ;3.30
  83. JMP NOPROB ;PROBLEM WITH OPEN
  84. ENDCONF: ;3.30
  85. return ;3.30
  86. BADOP: MOV DX,OFFSET BADOPM ;WANT TO PRINT COMMAND ERROR
  87. invoke PRINT
  88. JMP COFF
  89. NOPROB: ;GET FILE SIZE (NOTE < 64K!!)
  90. MOV BX,AX
  91. XOR CX,CX
  92. XOR DX,DX
  93. MOV AX,(LSEEK SHL 8) OR 2
  94. INT 21H
  95. MOV [COUNT],AX
  96. XOR DX,DX
  97. MOV AX,LSEEK SHL 8 ;Reset pointer to beginning of file
  98. INT 21H
  99. MOV DX,CS
  100. MOV AX,[COUNT]
  101. call ParaRound
  102. SUB DX,AX
  103. SUB DX,11H ;ROOM FOR HEADER
  104. MOV [CONFBOT],DX ; Config starts here
  105. CALL TEMPCDS ; Finally get CDS to "safe" location
  106. ASSUME DS:NOTHING,ES:NOTHING
  107. MOV DX,[CONFBOT]
  108. MOV DS,DX
  109. MOV ES,DX
  110. XOR DX,DX
  111. MOV CX,[COUNT]
  112. MOV AH,READ
  113. STC ;IN CASE OF INT 24
  114. INT 21H ;Function request
  115. PUSHF
  116. ;
  117. ; Find the EOF mark in the file. If present, then trim length.
  118. ;
  119. SaveReg <AX,DI,CX>
  120. MOV AL,1Ah ; eof mark
  121. MOV DI,DX ; point ro buffer
  122. JCXZ PutEOL ; no chars
  123. REPNZ SCASB ; find end
  124. JNZ PutEOL ; none found and count exahusted
  125. ;
  126. ; We found a 1A. Back up
  127. ;
  128. DEC DI ; backup past 1A
  129. ;
  130. ; Just for the halibut, stick in an extra EOL
  131. ;
  132. PutEOL:
  133. MOV AL,13
  134. STOSB ; CR
  135. MOV AL,10
  136. STOSB ; LF
  137. SUB DI,DX ; difference moved
  138. MOV Count,DI ; new count
  139. ;
  140. ; Restore registers
  141. ;
  142. RestoreReg <CX,DI,AX>
  143. PUSH CS
  144. POP DS
  145. ASSUME DS:SYSINITSEG
  146. PUSH AX
  147. MOV AH,CLOSE
  148. INT 21H
  149. POP AX
  150. POPF
  151. JC CONFERR ;IF NOT WE'VE GOT A PROBLEM
  152. CMP CX,AX
  153. JZ GETCOM ;COULDN'T READ THE FILE
  154. CONFERR:
  155. MOV DX,OFFSET CONFIG ;WANT TO PRINT CONFIG ERROR
  156. CALL BADFIL
  157. ENDCONV:JMP ENDCONF ;3.30
  158. GETCOM:
  159. invoke ORGANIZE ;ORGANIZE THE FILE
  160. CALL GETCHR
  161. CONFLP: JC ENDCONV ;3.30
  162. MOV AH,AL
  163. CALL GETCHR
  164. JNC TryB
  165. JMP BADOP
  166. COFF: PUSH CS
  167. POP DS
  168. invoke NEWLINE
  169. JMP CONFLP
  170. ;------------------------------------------------------------------------------
  171. ; Buffer command
  172. ;------------------------------------------------------------------------------
  173. TryB: CMP AH,'B' ;BUFFER COMMAND?
  174. JNZ TRYC
  175. invoke GETNUM
  176. JZ TryBBad ; Gotta have at least one
  177. CMP AX,100 ; check for max number
  178. JB SaveBuf
  179. TryBBad:JMP BadOp
  180. SaveBuf:
  181. MOV [BUFFERS],AX
  182. CoffJ1: JMP COFF
  183. ;------------------------------------------------------------------------------
  184. ; Break command
  185. ;------------------------------------------------------------------------------
  186. TryC: CMP AH,'C'
  187. JZ GOTC
  188. JMP TRYD
  189. GOTC:
  190. CMP AL,'O' ;FIRST LETTER OF "ON" or "OFF"
  191. JNZ TryCBad
  192. CALL GETCHR
  193. JC TryCBad
  194. CMP AL,'N' ;SECOND LETTER OF "ON"
  195. JNZ TryCoff
  196. MOV AH,SET_CTRL_C_TRAPPING ;TURN ON CONTROL-C CHECK
  197. MOV AL,1
  198. MOV DL,AL
  199. INT 21H
  200. CoffJ2: JMP Coff
  201. TryCOff:CMP AL,'F'
  202. JNZ TryCBad ; Check for "OFF"
  203. CALL GetChr
  204. JC TryCBad
  205. CMP AL,'F'
  206. JZ COffJ2
  207. TryCBad:JMP BadOp
  208. ;------------------------------------------------------------------------------
  209. ; Device command
  210. ;------------------------------------------------------------------------------
  211. TRYD: CMP AH,'D'
  212. JZ GOTD
  213. JMP TRYQ
  214. GOTD: MOV BX,CS
  215. MOV DS,BX
  216. MOV WORD PTR [BPB_ADDR],SI
  217. MOV WORD PTR [BPB_ADDR+2],ES
  218. CALL ROUND
  219. XOR AX,AX
  220. MOV WORD PTR [ENTRY_POINT],AX
  221. MOV AX,[MEMHI]
  222. MOV WORD PTR [ENTRY_POINT+2],AX ;SET ENTRY POINT
  223. IF NOT NOEXEC
  224. MOV [LDOFF],AX ;SET LOAD OFFSET
  225. ENDIF
  226. PUSH ES
  227. POP DS
  228. ASSUME DS:NOTHING
  229. MOV DX,SI ;DS:DX POINTS TO FILE NAME
  230. IF NOEXEC
  231. LES BX,DWORD PTR CS:[MEMLO]
  232. CALL LDFIL ;LOAD IN THE DEVICE DRIVER
  233. ELSE
  234. ; We are going to open the cdevice driver and size it as is done
  235. ; in LDFIL. The reason we must do this is that EXEC does NO checking
  236. ; for us. We must make sure there is room to load the device without
  237. ; trashing SYSINIT. This code is not
  238. ; perfect (for instance .EXE device drivers are possible) because
  239. ; it does its sizing based on the assumption that the file being loaded
  240. ; is a .COM file. It is close enough to correctness to be usable.
  241. MOV ES,AX ;ES:0 is LOAD addr
  242. MOV AX,OPEN SHL 8 ;OPEN THE FILE
  243. STC ;IN CASE OF INT 24
  244. INT 21H
  245. JC BADLDRESET
  246. MOV BX,AX ;Handle in BX
  247. PUSH DX ; Save pointer to name
  248. XOR CX,CX
  249. XOR DX,DX
  250. MOV AX,(LSEEK SHL 8) OR 2
  251. STC ;IN CASE OF INT 24
  252. INT 21H ; Get file size in DX:AX
  253. JNC GO_AHEAD_LOAD
  254. MOV AH,CLOSE ; Close file
  255. INT 21H
  256. POP DX ; Clean stack
  257. STC ; Close may clear carry
  258. JMP SHORT BADLDRESET
  259. GO_AHEAD_LOAD:
  260. ; Convert size in DX:AX to para in AX
  261. ADD AX,15 ; Round up size for conversion to para
  262. ADC DX,0
  263. MOV CL,4
  264. SHR AX,CL
  265. MOV CL,12
  266. SHL DX,CL ; Low nibble of DX to high nibble
  267. OR AX,DX ; AX is now # of para for file
  268. MOV CX,ES ; CX:0 is xaddr
  269. ADD CX,AX ; New device will take up to here
  270. JC MEM_ERRJY ; WOW!!!!
  271. CMP CX,CS:[ALLOCLIM]
  272. JB OKLDX
  273. MEM_ERRJY:
  274. JMP MEM_ERR
  275. OKLDX:
  276. POP DX ; Recover name pointer
  277. MOV AH,CLOSE ; Close file
  278. INT 21H
  279. MOV BX,CS
  280. MOV ES,BX
  281. MOV BX,OFFSET PRMBLK ;ES:BX POINTS TO PARAMETERS
  282. MOV AL,3
  283. MOV AH,EXEC
  284. STC ;IN CASE OF INT 24
  285. INT 21H ;LOAD IN THE DEVICE DRIVER
  286. ENDIF
  287. BADLDRESET:
  288. PUSH DS
  289. POP ES ;ES:SI BACK TO CONFIG.SYS
  290. PUSH CS
  291. POP DS ;DS BACK TO SYSINIT
  292. ASSUME DS:SYSINITSEG
  293. JNC GOODLD
  294. BADBRK:
  295. cmp byte ptr es:[si], 13 ;file name is CR? ;3.30
  296. jne BADBRK_1 ;(entered "device=" without filename);3.30 ;3.30
  297. jmp BADOP ;"Unrecognized command in CONFIG.SYS";3.30
  298. BADBRK_1: ;3.30
  299. invoke BADLOAD
  300. JMP COFF
  301. GOODLD: SaveReg <ES,SI> ;INITIALIZE THE DEVICE
  302. Restore:MOV BL,ES:[SI] ; while ((c=*p) != 0)
  303. OR BL,BL
  304. JZ Got
  305. INC SI ; p++;
  306. JMP Restore
  307. Got: MOV BYTE PTR ES:[SI],' ' ; *p = ' ';
  308. SaveReg <ES,SI>
  309. PUSH CS
  310. POP ES
  311. MOV BX,SDEVSTRAT
  312. invoke CALLDEV ; CallDev (SDevStrat);
  313. MOV BX,SDEVINT
  314. invoke CALLDEV ; CallDev (SDevInt);
  315. RestoreReg <SI,DS>
  316. MOV BYTE PTR [SI],0 ; *p = 0;
  317. PUSH CS
  318. POP DS
  319. MOV AX,WORD PTR [BREAK_ADDR+2]
  320. CMP AX,[MEMORY_SIZE]
  321. JB BREAKOK
  322. POP SI
  323. POP ES
  324. JMP BADBRK
  325. BREAKOK:
  326. LDS DX,[ENTRY_POINT] ;SET DS:DX TO HEADER
  327. MOV SI,DX
  328. ADD SI,SDEVATT ;DS:SI POINTS TO ATTRIBUTES
  329. LES DI,CS:[DOSINFO] ;ES:DI POINT TO DOS INFO
  330. MOV AX,DS:[SI] ;GET ATTRIBUTES
  331. TEST AX,DEVTYP ;TEST IF BLOCK DEV
  332. JZ ISBLOCK
  333. invoke SET_BREAK ; Go ahead and alloc mem for device
  334. jc Erase_Dev ;dev driver's Init routine failed ;3.30
  335. TEST AX,ISCIN ;IS IT A CONSOLE IN?
  336. JZ TRYCLK
  337. MOV WORD PTR ES:[DI.SYSI_CON],DX
  338. MOV WORD PTR ES:[DI.SYSI_CON+2],DS
  339. TRYCLK: TEST AX,ISCLOCK ;IS IT A CLOCK DEVICE?
  340. JZ GOLINK
  341. MOV WORD PTR ES:[DI+SYSI_CLOCK],DX
  342. MOV WORD PTR ES:[DI+SYSI_CLOCK+2],DS
  343. GOLINK: JMP LINKIT
  344. ISBLOCK:
  345. MOV AL,CS:[UNITCOUNT] ;IF NO UNITS FOUND, erase the device
  346. OR AL,AL
  347. JNZ PERDRV
  348. ERASE_DEV:
  349. MOV AX,-1 ; No call to SET_BREAK yet, so no alloc
  350. JMP ENDDEV
  351. PERDRV:
  352. CBW ; WARNING NO DEVICE > 127 UNITS
  353. MOV CX,AX
  354. MOV DH,AH
  355. MOV DL,ES:[DI.SYSI_NUMIO] ;GET NUMBER OF DEVICES
  356. MOV AH,DL
  357. ADD AH,AL ; Check for too many devices
  358. CMP AH,26 ; 'A' - 'Z' is 26 devices
  359. JBE OK_BLOCK
  360. PUSH CS
  361. POP DS
  362. MOV DX,OFFSET BADBLOCK
  363. invoke PRINT
  364. JMP ERASE_DEV
  365. OK_BLOCK:
  366. invoke SET_BREAK ; Alloc the device
  367. ADD ES:[DI.SYSI_NUMIO],AL ;UPDATE THE AMOUNT
  368. ADD CS:DriveNumber,AL ; remember amount for next device
  369. LDS BX,CS:[BPB_ADDR] ;POINT TO BPB ARRAY
  370. PERUNIT:
  371. LES BP,CS:[DOSINFO]
  372. LES BP,DWORD PTR ES:[BP.SYSI_DPB] ;GET FIRST DPB
  373. SCANDPB:CMP WORD PTR ES:[BP.DPB_NEXT_DPB],-1
  374. JZ FOUNDPB
  375. LES BP,ES:[BP.DPB_NEXT_DPB]
  376. JMP SCANDPB
  377. FOUNDPB:
  378. MOV AX,CS:[MEMLO]
  379. MOV WORD PTR ES:[BP.DPB_NEXT_DPB],AX
  380. MOV AX,CS:[MEMHI]
  381. MOV WORD PTR ES:[BP.DPB_NEXT_DPB+2],AX
  382. LES BP,DWORD PTR CS:[MEMLO]
  383. ADD WORD PTR CS:[MEMLO],DPBSIZ
  384. CALL ROUND ;Check for alloc error
  385. MOV WORD PTR ES:[BP.DPB_NEXT_DPB],-1
  386. MOV ES:[BP.DPB_FIRST_ACCESS],-1
  387. MOV SI,[BX] ;DS:SI POINTS TO BPB
  388. INC BX
  389. INC BX ;POINT TO NEXT GUY
  390. MOV WORD PTR ES:[BP.DPB_DRIVE],DX
  391. MOV AH,SETDPB ;HIDDEN SYSTEM CALL
  392. INT 21H
  393. MOV AX,ES:[BP.DPB_SECTOR_SIZE] ;3.30
  394. PUSH ES ;3.30
  395. LES DI,CS:[DOSINFO] ;ES:DI POINT TO DOS INFO ;3.30
  396. CMP AX,ES:[DI.SYSI_MAXSEC] ;3.30
  397. POP ES ;3.30
  398. JBE NOTMAX ;3.30
  399. POP SI ;3.30
  400. POP ES ;3.30
  401. MOV DX,OFFSET BADSIZ_PRE ;3.30
  402. MOV BX,OFFSET BADSIZ_POST ;3.30
  403. invoke PRNERR ;3.30
  404. JMP COFF ;3.30
  405. NOTMAX: PUSH DS
  406. PUSH DX
  407. LDS DX,CS:[ENTRY_POINT]
  408. MOV WORD PTR ES:[BP.DPB_DRIVER_ADDR],DX
  409. MOV WORD PTR ES:[BP.DPB_DRIVER_ADDR+2],DS
  410. POP DX
  411. POP DS
  412. INC DX
  413. INC DH
  414. LOOP PERUNIT
  415. PUSH CS
  416. POP DS
  417. CALL TEMPCDS ; Set CDS for new drives
  418. LINKIT:
  419. LES DI,CS:[DOSINFO] ;ES:DI = DOS TABLE
  420. MOV CX,WORD PTR ES:[DI.SYSI_DEV] ;DX:CX = HEAD OF LIST
  421. MOV DX,WORD PTR ES:[DI.SYSI_DEV+2]
  422. LDS SI,CS:[ENTRY_POINT] ;DS:SI = DEVICE LOCATION
  423. MOV WORD PTR ES:[DI.SYSI_DEV],SI ;SET HEAD OF LIST IN DOS
  424. MOV WORD PTR ES:[DI.SYSI_DEV+2],DS
  425. MOV AX,DS:[SI] ;GET POINTER TO NEXT DEVICE
  426. MOV WORD PTR CS:[ENTRY_POINT],AX ;AND SAVE IT
  427. MOV WORD PTR DS:[SI],CX ;LINK IN THE DRIVER
  428. MOV WORD PTR DS:[SI+2],DX
  429. ENDDEV:
  430. POP SI
  431. POP ES
  432. INC AX ;AX = FFFF (no more devs if YES)?
  433. JZ COFFJ3
  434. JMP GOODLD ;OTHERWISE PRETEND WE LOADED IT IN
  435. COFFJ3: JMP COFF
  436. ;------------------------------------------------------------------------------
  437. ; Country command
  438. ; The syntax is: ;3.30
  439. ; COUNTRY=country id {,codepage {,path}} ;3.30
  440. ; COUNTRY=country id {,,path} :Default CODEPAGE ID in DOS ;3.30
  441. ;------------------------------------------------------------------------------
  442. TRYQ:
  443. CMP AH,'Q' ;3.30
  444. JZ TRYQ_CONT ;3.30
  445. JMP TRYF ;3.30
  446. TRYQ_CONT: ;3.30
  447. invoke GETNUM ;3.30
  448. JZ TryQBad ; 0 is never a valid code, or number is;3.30
  449. ; bad ;3.30
  450. MOV BX,AX ; Country code in BX ;3.30
  451. ;3.30
  452. ; 5/26/86 ;3.30
  453. MOV DX,0 ; assume no code page id ;3.30
  454. ;3.30
  455. invoke skip_delim ;skip the delimeters after the first nu;3.30m
  456. jc TryQ_Def_File ;no more characters left? then use defa;3.30ult file
  457. cmp al, 13 ; ;3.30
  458. je TryQ_Def_File ;3.30
  459. cmp al, 10 ;3.30
  460. jne TRYQ_YES_EXTENDED ;3.30
  461. inc [COUNT] ;This is for NEWLINE routine in COFF. ;3.30
  462. dec [CHRPTR] ;3.30
  463. COFFJ41: ;3.30
  464. JMP TryQ_Def_File ;O.K. no code page, no path specified. ;3.30Use default path.
  465. ;3.30
  466. TRYQ_YES_EXTENDED: ;3.30
  467. cmp al, ',' ;was the second comma? ;3.30
  468. jne TryQ_GETNUM ;3.30
  469. invoke skip_delim ;Yes, skip ',' and other possible delim;3.30
  470. jmp short TRYQ_PATH ;and No code page id entered. ;3.30
  471. TRYQ_GETNUM: ;3.30
  472. invoke GETNUM ;3.30
  473. jc TryQBadCOM ;"Country=xxx,path" will not be accepte;3.30d.
  474. ; jc TRYQ_PATH ;Codepage is not specified. No code pag;3.30e.
  475. ; ;At this point, AL already contain the ;3.30
  476. ; ;first char of the PATH. ;3.30
  477. jz TryQBad ;codepage=0 entered. Error ;3.30
  478. mov DX, AX ;save code page in DX ;3.30
  479. invoke skip_delim ;move CHRPTR to the path string ;3.30
  480. jc TryQ_Def_File ;no more char? then use default filenam;3.30e
  481. cmp al, 13 ;3.30
  482. je TryQ_Def_File ;3.30
  483. cmp al, 10 ;3.30
  484. jne TryQ_PATH ;path entered. ;3.30
  485. inc [COUNT] ;3.30
  486. dec [CHRPTR] ;3.30
  487. TryQ_Def_File: ;3.30
  488. push dx ;save code page ;3.30
  489. mov cs:CNTRY_DRV, 0 ;flag that the default path has been us;3.30ed!!!
  490. mov dx, offset CNTRY_ROOT ;the default path ;3.30
  491. jmp TRYQ_OPEN ;3.30
  492. ;3.30
  493. TryQBad: ;"Invalid country code or code page" ;3.30
  494. STC ;3.30
  495. MOV DX,OFFSET BADCOUNTRY ;3.30
  496. jmp TryQChkErr ;3.30
  497. ;3.30
  498. TryQBadCOM: ;Error in COUNTRY command ;3.30
  499. STC ;3.30
  500. MOV DX,OFFSET BADCOUNTRYCOM ;3.30
  501. jmp TryQChkErr ;3.30
  502. ;3.30
  503. TRYQ_PATH: ;DS - sysinitseg, ES - CONFBOT, ;3.30
  504. mov CX, [COUNT] ;AL - the first char of path ;3.30
  505. inc CX ;BX - country id, DX - codepage id, 0 =;3.30 No code page
  506. mov DI, SI ;3.30
  507. TRYQ_PATH_LOOP: ;find the end of path to put 0 after th;3.30at.
  508. mov AL, byte ptr ES:[DI] ;3.30
  509. call delim ;3.30
  510. jz TRYQ_PATH_END ;3.30
  511. cmp al, 13 ;3.30
  512. jz TRYQ_PATH_END ;3.30
  513. inc DI ;3.30
  514. jmp short TRYQ_PATH_LOOP ;3.30
  515. TryQBad_Brg:jmp short TryQBad ;3.30
  516. TRYQ_PATH_END: ;3.30
  517. mov es:byte ptr [di], 0 ;make it a ASCIIZ string. (Organize did;3.30 not handle this string)
  518. push ds ;switch ds,es ;3.30
  519. push es ;3.30
  520. pop ds ;3.30
  521. pop es ;3.30
  522. ;3.30
  523. mov di, offset CNTRY_DRV ;move the user specified path to CNTRY_;3.30DRV
  524. call Move_ASCIIZ ;3.30
  525. ;3.30
  526. push ds ;restore ds,es ;3.30
  527. push es ;3.30
  528. pop ds ;3.30
  529. pop es ;3.30
  530. ;3.30
  531. ; call Set_Country_Path ;set CNTRY_DRV ;3.30
  532. ;3.30
  533. push dx ;save DX ;3.30
  534. mov dx, offset CNTRY_DRV ;Now DS:DX -> CNTRY_DRV ;3.30
  535. TRYQ_OPEN: ;3.30
  536. mov ax, 3d00h ;open a file ;3.30
  537. stc ;3.30
  538. int 21h ;3.30
  539. pop dx ;restore codepage id ;3.30
  540. jc TryQFileBad ;open failure ;3.30
  541. ;3.30
  542. mov cs:CntryFileHandle, ax ;save file handle ;3.30
  543. xchg ax, bx ;now, AX = country id, BX = file handle;3.30
  544. mov cx, cs:[MEMHI] ;3.30
  545. add cx, 128 ;I need 2K buffer to handle COUNTRY.SYS;3.30
  546. cmp cx, cs:[ALLOCLIM] ;3.30
  547. ja TryQMemory ;cannot allocate the buffer for country;3.30.sys
  548. ;3.30
  549. mov si, offset CNTRY_DRV ;DS:SI -> CNTRY_DRV ;3.30
  550. cmp byte ptr [si],0 ;default path? ;3.30
  551. jne TRYQ_Set_for_DOS ;3.30
  552. inc si ;3.30
  553. inc si ;DS:SI -> CNTRY_ROOT ;3.30
  554. TRYQ_Set_for_DOS: ;3.30
  555. les di, cs:SYSI_Country ;ES:DI -> country info tab in DOS ;3.30
  556. push di ;save di ;3.30
  557. add di, ccPath_CountrySys ;3.30
  558. call MOVE_ASCIIZ ;Set the path to COUNTRY.SYS in DOS. ;3.30
  559. pop di ;ES:DI -> country info tab again. ;3.30
  560. mov cx, cs:[MEMHI] ;3.30
  561. mov ds, cx ;3.30
  562. xor si, si ;DS:SI -> 2K buffer to be used. ;3.30
  563. call SetDOSCountryInfo ;now do the job!!! ;3.30
  564. jnc TryQchkERR ;read error or could not find country,c;3.30ode page combination
  565. cmp cx, -1 ;Could not find matching country_id,cod;3.30e page?
  566. je TryQBad_Brg ;then "Invalid country code or code pag;3.30e"
  567. TryQFileBad: ;3.30
  568. cmp cs:CNTRY_DRV,0 ;Is the default file used? ;3.30
  569. je TryQDefBad ;3.30
  570. mov si, cs:[CONFBOT] ;3.30
  571. mov es, si ;3.30
  572. mov si, cs:[CHRPTR] ;3.30
  573. dec si ;ES:SI -> path in CONFBOT ;3.30
  574. jmp short TryQBADLOAD ;3.30
  575. TryQDefBad: ;Default file has been used. ;3.30
  576. push cs ;3.30
  577. pop es ;3.30
  578. mov si, offset CNTRY_ROOT ;ES:SI -> \COUNTRY.SYS in SYSINIT_SEG ;3.30
  579. TryQBADLOAD: ;3.30
  580. call BADLOAD ;DS will be restored to SYSINIT_SEG ;3.30
  581. mov cx, cs:[CONFBOT] ;3.30
  582. mov es, cx ;Restore ES -> CONFBOT. ;3.30
  583. jmp short CoffJ4 ;3.30
  584. TryQMemory: ;3.30
  585. MOV DX,OFFSET INSUFMEMORY ;3.30
  586. TryQChkErr: ;3.30
  587. mov cx, cs:[CONFBOT] ;3.30
  588. mov es, cx ;restore ES -> CONFBOT seg ;3.30
  589. push cs ;3.30
  590. pop ds ;retore DS to SYSINIT_SEG ;3.30
  591. jnc CoffJ4 ;if no error, then exit ;3.30
  592. invoke PRINT ;else show error message ;3.30
  593. CoffJ4: ;3.30
  594. mov bx, CntryFileHandle ;3.30
  595. mov ah, 3eh ;3.30
  596. int 21h ;close a file. Don't care even if it fa;3.30ils.
  597. JMP COFF ;3.30
  598. ;------------------------------------------------------------------------------
  599. ; Files command
  600. ;------------------------------------------------------------------------------
  601. TRYF:
  602. CMP AH,'F'
  603. JNZ TRYL
  604. invoke GETNUM
  605. CMP AX,5
  606. JB TryFBad ; Gotta have at least 5
  607. CMP AX,256
  608. JAE TryFBad ; Has to be a byte
  609. MOV [FILES],AL
  610. CoffJ5: JMP COFF
  611. TryFBad:JMP BadOp
  612. ;------------------------------------------------------------------------------
  613. ; LastDrive command
  614. ;------------------------------------------------------------------------------
  615. TRYL:
  616. CMP AH,'L'
  617. JNZ TRYP
  618. OR AL,020h
  619. SUB AL,'a'
  620. JB TryLBad
  621. INC AL
  622. CMP AL,26 ; a-z are allowed
  623. JA TryLBad
  624. MOV [NUM_CDS],AL
  625. CoffJ6: JMP COFF
  626. TryLBad:JMP BadOp
  627. ;-------------------------------------------------------------------------------
  628. ; Setting Drive Parameters
  629. ;-------------------------------------------------------------------------------
  630. TRYP:
  631. CMP AH,'P'
  632. JNZ TRYK
  633. invoke PARSELINE
  634. JC TryLBad
  635. invoke SETPARMS
  636. INVOKE DIDDLEBACK
  637. jc TryLBad
  638. JMP COFF
  639. ;-------------------------------------------------------------------------------
  640. ; Setting Internal Stack Parameters
  641. ; STACK=M,N where
  642. ; M is the number of stacks (range 8 to 64, default 9)
  643. ; N is the stack size (range 32 to 512 bytes, default 128)
  644. ; 5/5/86: STACKS=0,0 implies no stack installation. ;3.30
  645. ; Any combinations that are not within the specified limits will ;3.30
  646. ; result in "Unrecognized command" error. ;3.30
  647. ;-------------------------------------------------------------------------------
  648. TRYK:
  649. CMP AH,'K'
  650. JNZ TRYW
  651. IF STACKSW ;3.30
  652. MOV SepChr,','
  653. INVOKE GetNum ; Get number of stacks
  654. MOV SepChr,0
  655. cmp ax, 0 ; 5/5/86 ;3.30
  656. je TRYK_0 ; Let's accept 0. ;3.30
  657. CMP AX, MinCount ; 8 <= Number of Stacks <= 64
  658. JB TryKBad
  659. CMP AX, MaxCount
  660. JA TryKBad
  661. TRYK_0: ;3.30
  662. MOV [STACK_COUNT], AX
  663. ;
  664. ; Skip delimiters after the ,
  665. ;
  666. invoke Skip_delim ; ;3.30
  667. JC TryKBad
  668. INVOKE GetNum ; Get size of individual stack
  669. JC TryKBad ; Number bad
  670. cmp ax, 0 ; 5/5/86 ;3.30
  671. je TRYK_SIZE0 ; 5/5/86. Accept 0 ;3.30
  672. CMP AX, MinSize ; 32 <= Stack Size <= 512
  673. JB TryKBad
  674. CMP AX, MaxSize
  675. JA TryKBad
  676. TRYK_SIZE0: ;3.30
  677. MOV [STACK_SIZE], AX
  678. cmp ax,0 ;3.30
  679. je TRYK_BOTH0 ;3.30
  680. TRYK_OK: ;3.30
  681. mov word ptr [stack_addr], -1 ;set flag. user entered stacks= ;3.30
  682. JMP COFF
  683. TRYK_BOTH0: ;3.30
  684. cmp [STACK_COUNT],0 ;stack_size=0. Stack_Count=0 too? ;3.30
  685. je TRYK_OK ;yes. accepted. ;3.30
  686. TryKBad:
  687. MOV DX, OFFSET BADSTACK ; 5/26/86 "Invalid stack parameter";3.30
  688. invoke PRINT ;3.30
  689. JMP COFF ;3.30
  690. ENDIF ;3.30
  691. ;------------------------------------------------------------------------------
  692. ; Switch command
  693. ;------------------------------------------------------------------------------
  694. TRYW:
  695. CMP AH,'W'
  696. JNZ TRYA
  697. JMP BadOp ; no longer implemented
  698. ; MOV DL,AL
  699. ; MOV AX,(CHAR_OPER SHL 8) OR 1 ;SET SWITCH CHARACTER
  700. ; MOV [COMMAND_LINE+1],DL
  701. ; INT 21H
  702. ; JMP COFF
  703. ;------------------------------------------------------------------------------
  704. ; Availdev command
  705. ;------------------------------------------------------------------------------
  706. TRYA:
  707. CMP AH,'A'
  708. JNZ TRYS
  709. JMP BadOp ; NO LONGER IMPLEMENTED
  710. ; CMP AL,'F' ;FIRST LETTER OF "FALSE"
  711. ; JNZ COFFJ7
  712. ; MOV AX,(CHAR_OPER SHL 8) OR 3 ;TURN ON "/DEV" PREFIX
  713. ; XOR DL,DL
  714. ; INT 21H
  715. ;COFFJ7: JMP COFF
  716. ;------------------------------------------------------------------------------
  717. ; shell command
  718. ;------------------------------------------------------------------------------
  719. TRYS:
  720. CMP AH,'S'
  721. JNZ TRYX
  722. MOV [COMMAND_LINE+1],0
  723. MOV DI,OFFSET COMMND + 1
  724. MOV [DI-1],AL
  725. STORESHELL:
  726. CALL GETCHR
  727. OR AL,AL
  728. JZ GETSHPARMS
  729. CMP AL," "
  730. JB ENDSH
  731. MOV [DI],AL
  732. INC DI
  733. JMP STORESHELL
  734. ENDSH:
  735. MOV BYTE PTR [DI],0
  736. CALL GETCHR
  737. CMP AL,10
  738. JNZ CONV
  739. CALL GETCHR
  740. CONV: JMP CONFLP
  741. ;------------------------------------------------------------------------------
  742. ; FCBS Command
  743. ;------------------------------------------------------------------------------
  744. TRYX:
  745. CMP AH,'X'
  746. JNZ TRYZ
  747. invoke GETNUM
  748. JZ TryXBad ; gotta have at least one
  749. CMP AX,256
  750. JAE TryXBad ; Can't be more than 8 bits worth
  751. MOV [FCBS],AL
  752. ;
  753. ; Skip delimiters after the ,
  754. ;
  755. invoke Skip_delim ; ;3.30
  756. jc tryxbad
  757. invoke GetNum
  758. JC TryXBad ; Number bad (Zero is OK here)
  759. CMP AX,256
  760. JAE TryXBad
  761. CMP AL,FCBS
  762. JA TryXBad
  763. MOV Keep,AL
  764. JMP COFF
  765. TryXBad:JMP BadOp
  766. ;------------------------------------------------------------------------------
  767. ; Bogus command
  768. ;------------------------------------------------------------------------------
  769. TRYZ:
  770. JMP BADOP
  771. GETSHPARMS:
  772. MOV BYTE PTR [DI],0
  773. MOV DI,OFFSET COMMAND_LINE+1
  774. PARMLOOP:
  775. CALL GETCHR
  776. CMP AL," "
  777. JB ENDSH
  778. MOV [DI],AL
  779. INC DI
  780. JMP PARMLOOP
  781. GETCHR:
  782. PUSH CX
  783. MOV CX,COUNT
  784. JCXZ NOCHAR
  785. MOV SI,CHRPTR
  786. MOV AL,ES:[SI]
  787. DEC COUNT
  788. INC CHRPTR
  789. CLC
  790. GET_RET:
  791. POP CX
  792. return
  793. NOCHAR: STC
  794. JMP SHORT GET_RET
  795. SYSINITSEG ENDS
  796. END
  797.