Leaked source code of windows server 2003
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.

1993 lines
42 KiB

  1. page ,160
  2. title bios system initialization
  3. ;
  4. ;----------------------------------------------------------------------------
  5. ;
  6. ; Modification history
  7. ;
  8. ; 26-Feb-1991 sudeepb Ported for NT DOSEm
  9. ;----------------------------------------------------------------------------
  10. include version.inc ; set version build flags
  11. include biosseg.inc ; establish bios segment structure
  12. lf equ 10
  13. cr equ 13
  14. tab equ 9
  15. ; the following depends on the positions of the various letters in switchlist
  16. switchnum equ 11111000b ; which switches require number
  17. ifdef NEC_98
  18. include bpb.inc
  19. endif ;NEC_98
  20. include syscall.inc
  21. include doscntry.inc
  22. include devsym.inc
  23. include ioctl.inc
  24. include devmark.inc ; needed
  25. ifndef NEC_98
  26. stacksw equ true ;include switchable hardware stacks
  27. else ;NEC_98
  28. stacksw equ false ;include switchable hardware stacks
  29. endif ;NEC_98
  30. if ibmjapver
  31. noexec equ true
  32. else
  33. noexec equ false
  34. endif
  35. ifdef NEC_98
  36. Bios_Data segment
  37. extrn ec35_flag: byte
  38. Bios_Data ends
  39. endif ;NEC_98
  40. sysinitseg segment public
  41. assume cs:sysinitseg,ds:nothing,es:nothing,ss:nothing
  42. extrn badopm:byte,crlfm:byte,badcom:byte,badmem:byte,badblock:byte
  43. extrn badsiz_pre:byte,badld_pre:byte
  44. extrn dosinfo:dword
  45. extrn memory_size:word,fcbs:byte,keep:byte
  46. extrn default_drive:byte,confbot:word,alloclim:word
  47. extrn buffers:word,zero:byte,sepchr:byte
  48. extrn files:byte
  49. extrn count:word,chrptr:word
  50. extrn bufptr:byte,memlo:word,prmblk:byte,memhi:word
  51. extrn ldoff:word,area:word,packet:byte,unitcount:byte,
  52. extrn break_addr:dword,bpb_addr:dword,drivenumber:byte
  53. extrn com_level:byte, cmmt:byte, cmmt1:byte, cmmt2:byte
  54. extrn cmd_indicator:byte
  55. extrn donotshownum:byte
  56. extrn multdeviceflag:byte
  57. extrn devmark_addr:word
  58. extrn setdevmarkflag:byte
  59. extrn org_count:word
  60. extrn pararound:near
  61. extrn getchr:near
  62. extrn stall:near
  63. extrn error_line:near
  64. extrn DevEntry:dword
  65. insert_blank db 0 ; M051: indicates that blank has been
  66. ; M051: inserted
  67. ifdef JAPAN
  68. extrn badmem2:byte,badld_pre2:byte
  69. extrn IsDBCSCodePage:near
  70. endif
  71. public int24,open_dev,organize,mem_err,newline,calldev,badload
  72. public prndev,auxdev,config,commnd,condev,getnum,badfil,prnerr
  73. public round,delim,print
  74. ifndef NEC_98
  75. public parseline,
  76. else ;NEC_98
  77. public setparms, parseline, diddleback
  78. endif ;NEC_98
  79. public setdoscountryinfo,set_country_path,move_asciiz
  80. public cntry_drv,cntry_root,cntry_path
  81. public delim
  82. public pathstring
  83. public MseDev ; NTVDM internal mouse driver
  84. ifdef NEC_98
  85. ;----------------------------------------------------------------------------
  86. ;
  87. ; procedure : setparms
  88. ;
  89. ; the following set of routines is used to parse the drivparm = command in
  90. ; the config.sys file to change the default drive parameters.
  91. ;
  92. ;----------------------------------------------------------------------------
  93. ;
  94. setparms proc near
  95. push ds
  96. push ax
  97. push bx
  98. push cx
  99. push dx
  100. push cs
  101. pop ds
  102. assume ds:sysinitseg
  103. xor bx,bx
  104. mov bl,byte ptr drive
  105. inc bl ; get it correct for ioctl
  106. ; call (1=a,2=b...)
  107. mov dx,offset deviceparameters
  108. mov ah,ioctl
  109. mov al,generic_ioctl
  110. mov ch,rawio
  111. mov cl,set_device_parameters
  112. int 21h
  113. test word ptr switches, flagec35
  114. jz not_ec35
  115. mov cl,byte ptr drive ; which drive was this for?
  116. mov ax,Bios_Data ; get Bios_Data segment
  117. mov ds,ax ; set Bios_Data segment
  118. assume ds:Bios_Data
  119. mov al,1 ; assume drive 0
  120. shl al,cl ; set proper bit depending on drive
  121. or ds:ec35_flag,al ; set the bit in the permanent flags
  122. not_ec35:
  123. pop dx ; fix up all the registers
  124. pop cx
  125. pop bx
  126. pop ax
  127. pop ds
  128. assume ds:nothing
  129. ret
  130. setparms endp
  131. ;
  132. ;----------------------------------------------------------------------------
  133. ;
  134. ; procedure : diddleback
  135. ;
  136. ; replace default values for further drivparm commands
  137. ;
  138. ;----------------------------------------------------------------------------
  139. ;
  140. diddleback proc near
  141. push ds
  142. push cs
  143. pop ds
  144. assume ds:sysinitseg
  145. mov word ptr deviceparameters.dp_cylinders,80
  146. mov byte ptr deviceparameters.dp_devicetype, dev_3inch720kb
  147. mov word ptr deviceparameters.dp_deviceattributes,0
  148. mov word ptr switches,0 ; zero all switches
  149. pop ds
  150. assume ds:nothing
  151. ret
  152. diddleback endp
  153. endif ;NEC_98
  154. ;
  155. ;----------------------------------------------------------------------------
  156. ;
  157. ; procedure : parseline
  158. ;
  159. ; entry point is parseline. al contains the first character in command line.
  160. ;
  161. ;----------------------------------------------------------------------------
  162. ;
  163. parseline proc near
  164. ; don't get character first time
  165. push ds
  166. push cs
  167. pop ds
  168. assume ds:sysinitseg
  169. nextswtch:
  170. cmp al,cr ; carriage return?
  171. jz done_line
  172. cmp al,lf ; linefeed?
  173. jz put_back ; put it back and done
  174. ; anything less or equal to a space is ignored.
  175. cmp al,' ' ; space?
  176. jbe get_next ; skip over space
  177. cmp al,'/'
  178. jz getparm
  179. stc ; mark error invalid-character-in-input
  180. jmp short exitpl
  181. getparm:
  182. call check_switch
  183. mov word ptr switches,bx ; save switches read so far
  184. jc swterr
  185. get_next:
  186. call getchr
  187. jc done_line
  188. jmp nextswtch
  189. swterr:
  190. jmp short exitpl ; exit if error
  191. done_line:
  192. test word ptr switches,flagdrive ; see if drive specified
  193. jnz okay
  194. stc ; mark error no-drive-specified
  195. jmp short exitpl
  196. okay:
  197. ifndef NEC_98
  198. ; mov ax,word ptr switches
  199. ; and ax,0003h ; get flag bits for changeline and non-rem
  200. ; mov word ptr deviceparameters.dp_deviceattributes,ax
  201. ; mov word ptr deviceparameters.dp_tracktableentries, 0
  202. ; clc ; everything is fine
  203. ; call setdeviceparameters
  204. else ;NEC_98
  205. mov ax,word ptr switches
  206. and ax,0003h ; get flag bits for changeline and non-rem
  207. mov word ptr deviceparameters.dp_deviceattributes,ax
  208. mov word ptr deviceparameters.dp_tracktableentries, 0
  209. clc ; everything is fine
  210. call setdeviceparameters
  211. endif ;NEC_98
  212. exitpl:
  213. pop ds
  214. ret
  215. put_back:
  216. inc count ; one more char to scan
  217. dec chrptr ; back up over linefeed
  218. jmp short done_line
  219. parseline endp
  220. ;
  221. ;----------------------------------------------------------------------------
  222. ;
  223. ; procedure : check_switch
  224. ;
  225. ; processes a switch in the input. it ensures that the switch is valid, and
  226. ; gets the number, if any required, following the switch. the switch and the
  227. ; number *must* be separated by a colon. carry is set if there is any kind of
  228. ; error.
  229. ;
  230. ;----------------------------------------------------------------------------
  231. ;
  232. check_switch proc near
  233. call getchr
  234. jc err_check
  235. and al,0dfh ; convert it to upper case
  236. cmp al,'A'
  237. jb err_check
  238. cmp al,'Z'
  239. ja err_check
  240. push es
  241. push cs
  242. pop es
  243. mov cl,byte ptr switchlist ; get number of valid switches
  244. mov ch,0
  245. mov di,1+offset switchlist ; point to string of valid switches
  246. repne scasb
  247. pop es
  248. jnz err_check
  249. mov ax,1
  250. shl ax,cl ; set bit to indicate switch
  251. mov bx,word ptr switches ; get switches so far
  252. or bx,ax ; save this with other switches
  253. mov cx,ax
  254. test ax, switchnum ; test against switches that require number to follow
  255. jz done_swtch
  256. call getchr
  257. jc err_swtch
  258. cmp al,':'
  259. jnz err_swtch
  260. call getchr
  261. push bx ; preserve switches
  262. mov byte ptr cs:sepchr,' ' ; allow space separators
  263. call getnum
  264. mov byte ptr cs:sepchr,0
  265. pop bx ; restore switches
  266. ; because getnum does not consider carriage-return or line-feed as ok, we do
  267. ; not check for carry set here. if there is an error, it will be detected
  268. ; further on (hopefully).
  269. call process_num
  270. done_swtch:
  271. clc
  272. ret
  273. err_swtch:
  274. xor bx,cx ; remove this switch from the records
  275. err_check:
  276. stc
  277. ret
  278. check_switch endp
  279. ;
  280. ;----------------------------------------------------------------------------
  281. ;
  282. ; procedure : process_num
  283. ;
  284. ; this routine takes the switch just input, and the number following (if any),
  285. ; and sets the value in the appropriate variable. if the number input is zero
  286. ; then it does nothing - it assumes the default value that is present in the
  287. ; variable at the beginning. zero is ok for form factor and drive, however.
  288. ;
  289. ;----------------------------------------------------------------------------
  290. ;
  291. process_num proc near
  292. test word ptr switches,cx ; if this switch has been done before,
  293. jnz done_ret ; ignore this one.
  294. test cx,flagdrive
  295. jz try_f
  296. mov byte ptr drive,al
  297. jmp short done_ret
  298. try_f:
  299. test cx,flagff
  300. jz try_t
  301. ; ensure that we do not get bogus form factors that are not supported
  302. ifndef NEC_98
  303. ; mov byte ptr deviceparameters.dp_devicetype,al
  304. else ;NEC_98
  305. mov byte ptr deviceparameters.dp_devicetype,al
  306. endif ;NEC_98
  307. jmp short done_ret
  308. try_t:
  309. or ax,ax
  310. jz done_ret ; if number entered was 0, assume default value
  311. test cx,flagcyln
  312. jz try_s
  313. ifndef NEC_98
  314. ; mov word ptr deviceparameters.dp_cylinders,ax
  315. else ;NEC_98
  316. mov word ptr deviceparameters.dp_cylinders,ax
  317. endif ;NEC_98
  318. jmp short done_ret
  319. try_s:
  320. test cx,flagseclim
  321. jz try_h
  322. mov word ptr slim,ax
  323. jmp short done_ret
  324. ; must be for number of heads
  325. try_h:
  326. mov word ptr hlim,ax
  327. done_ret:
  328. clc
  329. ret
  330. process_num endp
  331. ifdef NEC_98
  332. ; M047 -- Begin modifications (too numerous to mark specifically)
  333. ;
  334. ;----------------------------------------------------------------------------
  335. ;
  336. ; procedure : setdeviceparameters
  337. ;
  338. ; setdeviceparameters sets up the recommended bpb in each bds in the
  339. ; system based on the form factor. it is assumed that the bpbs for the
  340. ; various form factors are present in the bpbtable. for hard files,
  341. ; the recommended bpb is the same as the bpb on the drive.
  342. ; no attempt is made to preserve registers since we are going to jump to
  343. ; sysinit straight after this routine.
  344. ;
  345. ; if we return carry, the DRIVPARM will be aborted, but presently
  346. ; we always return no carry
  347. ;
  348. ;
  349. ; note: there is a routine by the same name in msdioctl.asm
  350. ;
  351. ;----------------------------------------------------------------------------
  352. ;
  353. setdeviceparameters proc near
  354. push es
  355. push cs
  356. pop es
  357. assume es:sysinitseg
  358. xor bx,bx
  359. mov bl,byte ptr deviceparameters.dp_devicetype
  360. cmp bl,dev_5inch
  361. jnz got_80
  362. mov word ptr deviceparameters.dp_cylinders,40 ; 48 tpi=40 cyl
  363. got_80:
  364. shl bx,1 ; get index into bpb table
  365. mov si,bpbtable[bx] ; get address of bpb
  366. mov di,offset deviceparameters.dp_bpb ; es:di -> bpb
  367. mov cx,size A_BPB
  368. cld
  369. repe movsb
  370. pop es
  371. assume es:nothing
  372. test word ptr switches,flagseclim
  373. jz see_heads
  374. mov ax,word ptr slim
  375. mov word ptr deviceparameters.dp_bpb.bpb_sectorspertrack,ax
  376. see_heads:
  377. test word ptr switches,flagheads
  378. jz heads_not_altered
  379. mov ax,word ptr hlim
  380. mov word ptr deviceparameters.dp_bpb.bpb_heads,ax
  381. heads_not_altered:
  382. ; set up correct media descriptor byte and sectors/cluster
  383. ; sectors/cluster is always 2 except for any one sided disk or 1.44M
  384. mov byte ptr deviceparameters.dp_bpb.bpb_sectorspercluster,2
  385. mov bl,0f0h ; get default mediabyte
  386. ; preload the mediadescriptor from the bpb into bh for convenient access
  387. mov bh,byte ptr deviceparameters.dp_bpb.bpb_mediadescriptor
  388. cmp word ptr deviceparameters.dp_bpb.bpb_heads,2 ; >2 heads?
  389. ja got_correct_mediad ; just use default if heads>2
  390. jnz only_one_head ; one head, do one head stuff
  391. ; two head drives will use the mediadescriptor from the bpb
  392. mov bl,bh ; get mediadescriptor from bpb
  393. ; two sided drives have two special cases to look for. One is
  394. ; a 320K diskette (40 tracks, 8 secs per track). It uses
  395. ; a mediaid of 0fch. The other is 1.44M, which uses only
  396. ; one sector/cluster.
  397. ; any drive with 18secs/trk, 2 heads, 80 tracks, will be assumed
  398. ; to be a 1.44M and use only 1 sector per cluster. Any other
  399. ; type of 2 headed drive is all set.
  400. cmp deviceparameters.dp_bpb.bpb_sectorspertrack,18
  401. jnz not_144m
  402. cmp deviceparameters.dp_cylinders,80
  403. jnz not_144m
  404. ; We've got cyl=80, heads=2, secpertrack=18. Set cluster size to 1.
  405. jmp short got_one_secperclus_drive
  406. ; check for 320K
  407. not_144m:
  408. cmp deviceparameters.dp_cylinders,40
  409. jnz got_correct_mediad
  410. cmp deviceparameters.dp_bpb.bpb_sectorspertrack,8
  411. jnz got_correct_mediad
  412. mov bl,0fch
  413. jmp short got_correct_mediad
  414. only_one_head:
  415. ; if we don't have a 360K drive, then just go use 0f0h as media descr.
  416. cmp deviceparameters.dp_devicetype,dev_5inch
  417. jnz got_one_secperclus_drive
  418. ; single sided 360K drive uses either 0fch or 0feh, depending on
  419. ; whether sectorspertrack is 8 or 9. For our purposes, anything
  420. ; besides 8 will be considered 0fch
  421. mov bl,0fch ; single sided 9 sector media id
  422. cmp word ptr deviceparameters.dp_bpb.bpb_sectorspertrack,8
  423. jnz got_one_secperclus_drive ; okay if anything besides 8
  424. mov bl,0feh ; 160K mediaid
  425. ; we've either got a one sided drive, or a 1.44M drive
  426. ; either case we'll use 1 sector per cluster instead of 2
  427. got_one_secperclus_drive:
  428. mov byte ptr deviceparameters.dp_bpb.bpb_sectorspercluster,1
  429. got_correct_mediad:
  430. mov byte ptr deviceparameters.dp_bpb.bpb_mediadescriptor,bl
  431. ; Calculate the correct number of Total Sectors on medium
  432. ;
  433. mov ax,deviceparameters.dp_cylinders
  434. mul word ptr deviceparameters.dp_bpb.bpb_heads
  435. mul word ptr deviceparameters.dp_bpb.bpb_sectorspertrack
  436. mov word ptr deviceparameters.dp_bpb.bpb_totalsectors,ax
  437. clc ; we currently return no errors
  438. ret
  439. setdeviceparameters endp
  440. ; M047 -- end rewritten routine
  441. endif ;NEC_98
  442. ;
  443. ;----------------------------------------------------------------------------
  444. ;
  445. ; procedure : organize
  446. ;
  447. ;----------------------------------------------------------------------------
  448. ;
  449. assume ds:nothing, es:nothing
  450. organize proc near
  451. mov cx,[count]
  452. jcxz nochar1
  453. call mapcase
  454. xor si,si
  455. mov di,si
  456. xor ax,ax
  457. mov com_level, 0
  458. ;org1: call get ;skip leading control characters
  459. ; cmp al,' '
  460. ; jb org1
  461. org1:
  462. call skip_comment
  463. jz end_commd_line ; found a comment string and skipped.
  464. call get2 ; not a comment string. then get a char.
  465. cmp al, lf
  466. je end_commd_line ; starts with a blank line.
  467. cmp al, ' '
  468. jbe org1 ; skip leading control characters
  469. jmp short findit
  470. end_commd_line:
  471. stosb ; store line feed char in buffer for the linecount.
  472. mov com_level, 0 ; reset the command level.
  473. jmp org1
  474. nochar1:
  475. stc
  476. ret
  477. findit:
  478. push cx
  479. push si
  480. push di
  481. mov bp,si
  482. dec bp
  483. mov si,offset comtab ;prepare to search command table
  484. mov ch,0
  485. findcom:
  486. mov di,bp
  487. mov cl,[si]
  488. inc si
  489. jcxz nocom
  490. repe cmpsb
  491. lahf
  492. add si,cx ;bump to next position without affecting flags
  493. sahf
  494. lodsb ;get indicator letter
  495. jnz findcom
  496. cmp byte ptr es:[di], cr ;the next char might be cr,lf
  497. je gotcom0 ; such as in "rem",cr,lf case.
  498. cmp byte ptr es:[di], lf
  499. je gotcom0
  500. push ax
  501. mov al, byte ptr es:[di] ;now the next char. should be a delim.
  502. call delim
  503. pop ax
  504. jnz findcom
  505. gotcom0:
  506. pop di
  507. pop si
  508. pop cx
  509. jmp short gotcom
  510. nocom:
  511. pop di
  512. pop si
  513. pop cx
  514. mov al,'Z'
  515. stosb ; save indicator char.
  516. skip_line:
  517. call get2
  518. cmp al, lf ; skip this bad command line
  519. jne skip_line
  520. jmp end_commd_line ; handle next command line
  521. gotcom: stosb ;save indicator char in buffer
  522. mov cmd_indicator, al ; save it for the future use.
  523. org2: call get2 ;skip the commad name until delimiter
  524. cmp al, lf
  525. je org21
  526. cmp al, cr
  527. je org21
  528. call delim
  529. jnz org2
  530. jmp short org3
  531. org21: ;if cr or lf then
  532. dec si ; undo si, cx register
  533. inc cx ; and continue
  534. org3:
  535. cmp cmd_indicator, 'Y' ; comment= command?
  536. je get_cmt_token
  537. cmp cmd_indicator, 'I' ; install= command?
  538. je org_file
  539. cmp cmd_indicator, 'D' ; device= command?
  540. je org_file
  541. cmp cmd_indicator, 'S' ; shell= is a special one!!!
  542. je org_file
  543. cmp cmd_indicator, '1' ; switches= command?
  544. je org_switch
  545. jmp org4
  546. org_switch:
  547. call skip_comment
  548. jz end_commd_line_brdg
  549. call get2
  550. call org_delim
  551. jz org_switch
  552. stosb
  553. jmp org5
  554. org_file: ; get the filename and put 0 at end,
  555. call skip_comment
  556. jz org_put_zero
  557. call get2 ; not a comment
  558. call delim
  559. jz org_file ; skip the possible delimeters
  560. stosb ; copy the first non delim char found in buffer
  561. org_copy_file:
  562. call skip_comment ; comment char in the filename?
  563. jz org_put_zero ; then stop copying filename at that point
  564. call get2
  565. cmp al, '/' ; a switch char? (device=filename/xxx)
  566. je end_file_slash ; this will be the special case.
  567. stosb ; save the char. in buffer
  568. call delim
  569. jz end_copy_file
  570. cmp al, ' '
  571. ja org_copy_file ; keep copying
  572. jmp short end_copy_file ; otherwise, assume end of the filename.
  573. get_cmt_token: ; get the token. just max. 2 char.
  574. call get2
  575. cmp al, ' ' ; skip white spaces or "=" char.
  576. je get_cmt_token ; (we are allowing the other special
  577. cmp al, tab ; charaters can used for comment id.
  578. je get_cmt_token ; character.)
  579. cmp al, '=' ; = is special in this case.
  580. je get_cmt_token
  581. cmp al, cr
  582. je get_cmt_end ; cannot accept the carridge return
  583. cmp al, lf
  584. je get_cmt_end
  585. mov cmmt1, al ; store it
  586. mov cmmt, 1 ; 1 char. so far.
  587. call get2
  588. cmp al, ' '
  589. je get_cmt_end
  590. cmp al, tab
  591. je get_cmt_end
  592. cmp al, cr
  593. je get_cmt_end
  594. cmp al, lf
  595. je end_commd_line_brdg
  596. mov cmmt2, al
  597. inc cmmt
  598. get_cmt_end:
  599. call get2
  600. cmp al, lf
  601. jne get_cmt_end ; skip it.
  602. end_commd_line_brdg: jmp end_commd_line ; else jmp to end_commd_line
  603. org_put_zero: ; make the filename in front of
  604. mov byte ptr es:[di], 0 ; the comment string to be an asciiz.
  605. inc di
  606. jmp end_commd_line ; (maybe null if device=/*)
  607. end_file_slash: ; al = "/" option char.
  608. mov byte ptr es:[di],0 ; make a filename an asciiz
  609. inc di ; and
  610. stosb ; store "/" after that.
  611. jmp short org5 ; continue with the rest of the line
  612. end_copy_file:
  613. mov byte ptr es:[di-1], 0 ; make it an asciiz and handle the next char.
  614. cmp al, lf
  615. je end_commd_line_brdg
  616. jmp short org5
  617. org4: ; org4 skips all delimiters after the command name except for '/'
  618. call skip_comment
  619. jz end_commd_line_brdg
  620. call get2
  621. call org_delim ; skip delimiters except '/' (mrw 4/88)
  622. jz org4
  623. jmp short org51
  624. org5: ; rest of the line
  625. call skip_comment ; comment?
  626. jz end_commd_line_brdg
  627. call get2 ; not a comment.
  628. org51:
  629. stosb ; copy the character
  630. cmp al, '"' ; a quote ?
  631. je at_quote
  632. cmp al, ' '
  633. ja org5
  634. ; M051 - Start
  635. cmp cmd_indicator, 'U' ; Q: is this devicehigh
  636. jne not_dh ; N:
  637. cmp al, lf ; Q: is this line feed
  638. je org_dhlf ; Y: stuff a blank before the lf
  639. cmp al, cr ; Q: is this a cr
  640. jne org5 ; N:
  641. mov byte ptr es:[di-1], ' ' ; overwrite cr with blank
  642. stosb ; put cr after blank
  643. inc [insert_blank] ; indicate that blank has been
  644. ; inserted
  645. jmp org5
  646. not_dh: ; M051 - End
  647. cmp al, lf ; line feed?
  648. je org1_brdg ; handles the next command line.
  649. jmp org5 ; handles next char in this line.
  650. org_dhlf: ; M051 - Start
  651. cmp [insert_blank], 1 ; Q:has a blank already been inserted
  652. je org1_brdg ; Y:
  653. mov byte ptr es:[di-1], ' ' ; overwrite lf with blank
  654. stosb ; put lf after blank
  655. ; M051 - End
  656. org1_brdg:
  657. mov [insert_blank], 0 ; M051: clear blank indicator for
  658. ; M051: devicehigh
  659. jmp org1
  660. at_quote:
  661. cmp com_level, 0
  662. je up_level
  663. mov com_level, 0 ; reset it.
  664. jmp org5
  665. up_level:
  666. inc com_level ; set it.
  667. jmp org5
  668. organize endp
  669. ;
  670. ;----------------------------------------------------------------------------
  671. ;
  672. ; procedure : get2
  673. ;
  674. ;----------------------------------------------------------------------------
  675. ;
  676. get2 proc near
  677. jcxz noget
  678. mov al,es:[si]
  679. inc si
  680. dec cx
  681. od_ret:
  682. ret
  683. noget:
  684. pop cx
  685. mov count,di
  686. mov org_count, di
  687. xor si,si
  688. mov chrptr,si
  689. ng_ret:
  690. ret
  691. get2 endp
  692. ;
  693. ;----------------------------------------------------------------------------
  694. ;
  695. ; procedure : skip_comment
  696. ;
  697. ;skip the commented string until lf, if current es:si-> a comment string.
  698. ;in) es:si-> sting
  699. ; cx -> length.
  700. ;out) zero flag not set if not found a comment string.
  701. ; zero flag set if found a comment string and skipped it. al will contain
  702. ; the line feed charater at this moment when return.
  703. ; ax register destroyed.
  704. ; if found, si, cx register adjusted accordingly.
  705. ;
  706. ;----------------------------------------------------------------------------
  707. ;
  708. skip_comment proc near
  709. jcxz noget ; get out of the organize routine.
  710. cmp com_level, 0 ; only check it if parameter level is 0.
  711. jne no_commt ; (not inside quotations)
  712. cmp cmmt, 1
  713. jb no_commt
  714. mov al, es:[si]
  715. cmp cmmt1, al
  716. jne no_commt
  717. cmp cmmt, 2
  718. jne skip_cmmt
  719. mov al, es:[si+1]
  720. cmp cmmt2, al
  721. jne no_commt
  722. skip_cmmt:
  723. jcxz noget ; get out of organize routine.
  724. mov al, es:[si]
  725. inc si
  726. dec cx
  727. cmp al, lf ; line feed?
  728. jne skip_cmmt
  729. no_commt:
  730. ret
  731. skip_comment endp
  732. ;
  733. ;----------------------------------------------------------------------------
  734. ;
  735. ; procedure : delim
  736. ;
  737. ;----------------------------------------------------------------------------
  738. ;
  739. delim proc near
  740. cmp al,'/' ; ibm will assume "/" as an delimeter.
  741. jz delim_ret
  742. cmp al, 0 ; special case for sysinit!!!
  743. jz delim_ret
  744. org_delim: ; used by organize routine except for getting
  745. cmp al,' ' ;the filename.
  746. jz delim_ret
  747. cmp al,9
  748. jz delim_ret
  749. cmp al,'='
  750. jz delim_ret
  751. cmp al,','
  752. jz delim_ret
  753. cmp al,';'
  754. delim_ret:
  755. ret
  756. delim endp
  757. ;
  758. ;----------------------------------------------------------------------------
  759. ;
  760. ; procedure : newline
  761. ;
  762. ; newline returns with first character of next line
  763. ;
  764. ;----------------------------------------------------------------------------
  765. ;
  766. newline proc near
  767. call getchr ;skip non-control characters
  768. jc nl_ret
  769. cmp al,lf ;look for line feed
  770. jnz newline
  771. call getchr
  772. nl_ret:
  773. ret
  774. newline endp
  775. ;
  776. ;----------------------------------------------------------------------------
  777. ;
  778. ; procedure : mapcase
  779. ;
  780. ;----------------------------------------------------------------------------
  781. ;
  782. mapcase proc near
  783. push cx
  784. push si
  785. push ds
  786. push es
  787. pop ds
  788. xor si,si
  789. convloop:
  790. lodsb
  791. ifdef DBCS
  792. call testkanj
  793. jz normconv ; if this is not lead byte
  794. mov ah,al
  795. lodsb ; get tail byte
  796. cmp ax,DB_SPACE
  797. jnz @f ; if this is not dbcs space
  798. mov word ptr [si-2],' ' ; set 2 single space
  799. @@:
  800. dec cx
  801. jcxz convdone ;just ignore 1/2 kanji error
  802. jmp short noconv
  803. ;fall through, know al is not in 'a'-'z' range
  804. normconv:
  805. endif
  806. cmp al,'a'
  807. jb noconv
  808. cmp al,'z'
  809. ja noconv
  810. sub al,20h
  811. mov [si-1],al
  812. noconv:
  813. loop convloop
  814. convdone:
  815. pop ds
  816. pop si
  817. pop cx
  818. ret
  819. ifdef DBCS
  820. public testkanj
  821. testkanj:
  822. push si
  823. push ds
  824. push ax
  825. mov ax,6300h ; get dos dbcs vector
  826. int 21h
  827. pop ax
  828. bdbcs_do:
  829. cmp ds:word ptr [si],0 ; end of lead byte info?
  830. jz bdbcs_notfound ; jump if so
  831. cmp al,ds:[si] ; less than first byte character?
  832. jb bdbcs_next ; jump if not
  833. cmp al,ds:[si+1] ; grater than first byte character?
  834. ja bdbcs_next
  835. bdbcs_found:
  836. push ax
  837. xor ax,ax
  838. inc ax ; reset zero flag
  839. pop ax
  840. bdbcs_exit:
  841. pop ds
  842. pop si
  843. ret
  844. bdbcs_notfound:
  845. push ax
  846. xor ax,ax ; set zero flag
  847. pop ax
  848. jmp short bdbcs_exit
  849. bdbcs_next:
  850. add si,2 ; points next lead byte table
  851. jmp short bdbcs_do
  852. endif ; DBCS
  853. mapcase endp
  854. ;
  855. ;----------------------------------------------------------------------------
  856. ;
  857. ; procedure : round
  858. ;
  859. ; round the values in memlo and memhi to paragraph boundary.
  860. ; perform bounds check.
  861. ;
  862. ;----------------------------------------------------------------------------
  863. ;
  864. round proc near
  865. push ax
  866. mov ax,[memlo]
  867. call pararound ; para round up
  868. add [memhi],ax
  869. mov [memlo],0
  870. mov ax,memhi ; ax = new memhi
  871. cmp ax,[alloclim] ; if new memhi >= alloclim, error
  872. jae mem_err
  873. test cs:[setdevmarkflag], for_devmark
  874. jz skip_set_devmarksize
  875. push es
  876. push si
  877. mov si, cs:[devmark_addr]
  878. mov es, si
  879. sub ax, si
  880. dec ax
  881. mov es:[devmark_size], ax ; paragraph
  882. and cs:[setdevmarkflag], not_for_devmark
  883. pop si
  884. pop es
  885. skip_set_devmarksize:
  886. pop ax
  887. clc ;clear carry
  888. ret
  889. mem_err:
  890. mov dx,offset badmem
  891. ifdef JAPAN
  892. call IsDBCSCodePage
  893. jz @f
  894. mov dx,offset badmem2
  895. @@:
  896. endif
  897. push cs
  898. pop ds
  899. call print
  900. jmp stall
  901. round endp
  902. ;
  903. ;----------------------------------------------------------------------------
  904. ;
  905. ; procedure : calldev
  906. ;
  907. ;----------------------------------------------------------------------------
  908. ;
  909. calldev proc near
  910. mov ds,word ptr cs:[DevEntry+2]
  911. add bx,word ptr cs:[DevEntry] ;do a little relocation
  912. mov ax,ds:[bx]
  913. push word ptr cs:[DevEntry]
  914. mov word ptr cs:[DevEntry],ax
  915. mov bx,offset packet
  916. call [DevEntry]
  917. pop word ptr cs:[DevEntry]
  918. ret
  919. calldev endp
  920. ;
  921. ;----------------------------------------------------------------------------
  922. ;
  923. ; procedure : todigit
  924. ;
  925. ;----------------------------------------------------------------------------
  926. ;
  927. todigit proc near
  928. sub al,'0'
  929. jb notdig
  930. cmp al,9
  931. ja notdig
  932. clc
  933. ret
  934. notdig:
  935. stc
  936. ret
  937. todigit endp
  938. ;
  939. ;----------------------------------------------------------------------------
  940. ;
  941. ; procedure : getnum
  942. ;
  943. ; getnum parses a decimal number.
  944. ; returns it in ax, sets zero flag if ax = 0 (may be considered an
  945. ; error), if number is bad carry is set, zero is set, ax=0.
  946. ;
  947. ;----------------------------------------------------------------------------
  948. ;
  949. getnum proc near
  950. push bx
  951. xor bx,bx ; running count is zero
  952. b2:
  953. call todigit ; do we have a digit
  954. jc badnum ; no, bomb
  955. xchg ax,bx ; put total in ax
  956. push bx ; save digit
  957. mov bx,10 ; base of arithmetic
  958. mul bx ; shift by one decimal di...
  959. pop bx ; get back digit
  960. add al,bl ; get total
  961. adc ah,0 ; make that 16 bits
  962. jc badnum ; too big a number
  963. xchg ax,bx ; stash total
  964. call getchr ;get next digit
  965. jc b1 ; no more characters
  966. cmp al, ' ' ; space?
  967. jz b15 ; then end of digits
  968. cmp al, ',' ; ',' is a seperator!!!
  969. jz b15 ; then end of digits.
  970. cmp al, tab ; tab
  971. jz b15
  972. cmp al,sepchr ; allow 0 or special separators
  973. jz b15
  974. cmp al,'/' ; see if another switch follows
  975. nop ; cas - remnant of old bad code
  976. nop
  977. jz b15
  978. cmp al,lf ; line-feed?
  979. jz b15
  980. cmp al,cr ; carriage return?
  981. jz b15
  982. or al,al ; end of line separator?
  983. jnz b2 ; no, try as a valid char...
  984. b15:
  985. inc count ; one more character to s...
  986. dec chrptr ; back up over separator
  987. b1:
  988. mov ax,bx ; get proper count
  989. or ax,ax ; clears carry, sets zero accordingly
  990. pop bx
  991. ret
  992. badnum:
  993. mov sepchr,0
  994. xor ax,ax ; set zero flag, and ax = 0
  995. pop bx
  996. stc ; and carry set
  997. ret
  998. getnum endp
  999. ;*****************************************************************
  1000. setdoscountryinfo proc near
  1001. ;input: es:di -> pointer to dos_country_cdpg_info
  1002. ; ds:0 -> buffer.
  1003. ; si = 0
  1004. ; ax = country id
  1005. ; dx = code page id. (if 0, then use ccsyscodepage as a default.)
  1006. ; bx = file handle
  1007. ; this routine can handle maxium 438 country_data entries.
  1008. ;
  1009. ;output: dos_country_cdpg_info set.
  1010. ; carry set if any file read failure or wrong information in the file.
  1011. ; carry set and cx = -1 if cannot find the matching country_id, codepage
  1012. ; _id in the file.
  1013. push di
  1014. push ax
  1015. push dx
  1016. xor cx,cx
  1017. xor dx,dx
  1018. mov ax,512 ;read 512 bytes
  1019. call readincontrolbuffer ;read the file header
  1020. jc setdosdata_fail
  1021. push es
  1022. push si
  1023. push cs
  1024. pop es
  1025. mov di,offset country_file_signature
  1026. mov cx,8 ;length of the signature
  1027. repz cmpsb
  1028. pop si
  1029. pop es
  1030. jnz setdosdata_fail ;signature mismatch
  1031. add si,18 ;si -> county info type
  1032. cmp byte ptr ds:[si],1 ;only accept type 1 (currently only 1 header type)
  1033. jne setdosdata_fail ;cannot proceed. error return
  1034. inc si ;si -> file offset
  1035. mov dx,word ptr ds:[si] ;get the info file offset.
  1036. mov cx,word ptr ds:[si+2]
  1037. mov ax,6144 ;read 6144 bytes.
  1038. call readincontrolbuffer ;read info
  1039. jc setdosdata_fail
  1040. mov cx, word ptr ds:[si] ;get the # of country, codepage combination entries
  1041. cmp cx, 438 ;cannot handle more than 438 entries.
  1042. ;
  1043. ja setdosdata_fail
  1044. inc si
  1045. inc si ;si -> entry information packet
  1046. pop dx ;restore code page id
  1047. pop ax ;restore country id
  1048. pop di
  1049. setdoscntry_find: ;search for desired country_id,codepage_id.
  1050. cmp ax, word ptr ds:[si+2] ;compare country_id
  1051. jne setdoscntry_next
  1052. cmp dx, 0 ;no user specified code page ?
  1053. je setdoscntry_any_codepage;then no need to match code page id.
  1054. cmp dx, word ptr ds:[si+4] ;compare code page id
  1055. je setdoscntry_got_it
  1056. setdoscntry_next:
  1057. add si, word ptr ds:[si] ;next entry
  1058. inc si
  1059. inc si ;take a word for size of entry itself
  1060. loop setdoscntry_find
  1061. mov cx, -1 ;signals that bad country id entered.
  1062. setdoscntry_fail:
  1063. stc
  1064. ret
  1065. setdosdata_fail:
  1066. pop si
  1067. pop cx
  1068. pop di
  1069. jmp short setdoscntry_fail
  1070. setdoscntry_any_codepage: ;use the code_page_id of the country_id found.
  1071. mov dx, word ptr ds:[si+4]
  1072. setdoscntry_got_it: ;found the matching entry
  1073. mov cs:cntrycodepage_id, dx ;save code page id for this country.
  1074. mov dx, word ptr ds:[si+10] ;get the file offset of country data
  1075. mov cx, word ptr ds:[si+12]
  1076. mov ax, 512 ;read 512 bytes
  1077. call readincontrolbuffer
  1078. jc setdoscntry_fail
  1079. mov cx, word ptr ds:[si] ;get the number of entries to handle.
  1080. inc si
  1081. inc si ;si -> first entry
  1082. setdoscntry_data:
  1083. push di ;es:di -> dos_country_cdpg_info
  1084. push cx ;save # of entry left
  1085. push si ;si -> current entry in control buffer
  1086. mov al, byte ptr ds:[si+2] ;get data entry id
  1087. call getcountrydestination ;get the address of destination in es:di
  1088. jc setdoscntry_data_next ;no matching data entry id in dos
  1089. mov dx, word ptr ds:[si+4] ;get offset of data
  1090. mov cx, word ptr ds:[si+6]
  1091. mov ax,4200h
  1092. stc
  1093. int 21h ;move pointer
  1094. jc setdosdata_fail
  1095. mov dx,512 ;start of data buffer
  1096. mov cx,20 ;read 20 bytes only. we only need to
  1097. mov ah,3fh ;look at the length of the data in the file.
  1098. stc
  1099. int 21h ;read the country.sys data
  1100. jc setdosdata_fail ;read failure
  1101. cmp ax,cx
  1102. jne setdosdata_fail
  1103. mov dx,word ptr ds:[si+4] ;get offset of data again.
  1104. mov cx,word ptr ds:[si+6]
  1105. mov ax,4200h
  1106. stc
  1107. int 21h ;move pointer back again
  1108. jc setdosdata_fail
  1109. push si
  1110. mov si,(512+8) ;get length of the data from the file
  1111. mov cx,word ptr ds:[si]
  1112. pop si
  1113. mov dx,512 ;start of data buffer
  1114. add cx,10 ;signature + a word for the length itself
  1115. mov ah,3fh ;read the data from the file.
  1116. stc
  1117. int 21h
  1118. jc setdosdata_fail
  1119. cmp ax, cx
  1120. jne setdosdata_fail
  1121. mov al,byte ptr ds:[si+2] ;save data id for future use.
  1122. mov si,(512+8) ;si-> data buffer + id tag field
  1123. mov cx,word ptr ds:[si] ;get the length of the file
  1124. inc cx ;take care of a word for lenght of tab
  1125. inc cx ;itself.
  1126. cmp cx,(2048 - 512 - 8) ;fit into the buffer?
  1127. ja setdosdata_fail
  1128. if bugfix
  1129. call setdbcs_before_copy
  1130. endif
  1131. cmp al, setcountryinfo ;is the data for setcountryinfo table?
  1132. jne setdoscntry_mov ;no, don't worry
  1133. push word ptr es:[di+ccmono_ptr-cccountryinfolen] ;cannot destroy ccmono_ptr address. save them.
  1134. push word ptr es:[di+ccmono_ptr-cccountryinfolen+2] ;at this time di -> cccountryinfolen
  1135. push di ;save di
  1136. push ax
  1137. mov ax,cs:cntrycodepage_id ;do not use the code page info in country_info
  1138. mov ds:[si+4], ax ;use the saved one for this !!!!
  1139. pop ax
  1140. setdoscntry_mov:
  1141. rep movsb ;copy the table into dos
  1142. cmp al, setcountryinfo ;was the ccmono_ptr saved?
  1143. jne setdoscntry_data_next
  1144. pop di ;restore di
  1145. pop word ptr es:[di+ccmono_ptr-cccountryinfolen+2] ;restore
  1146. pop word ptr es:[di+ccmono_ptr-cccountryinfolen]
  1147. setdoscntry_data_next:
  1148. pop si ;restore control buffer pointer
  1149. pop cx ;restore # of entries left
  1150. pop di ;restore pointer to dso_country_cdpg
  1151. add si, word ptr ds:[si] ;try to get the next entry
  1152. inc si
  1153. inc si ;take a word of entry length itself
  1154. dec cx
  1155. cmp cx,0
  1156. je setdoscntry_ok
  1157. jmp setdoscntry_data
  1158. setdoscntry_ok:
  1159. ret
  1160. setdoscountryinfo endp
  1161. if bugfix
  1162. setdbcs_before_copy proc near
  1163. cmp al,setdbcs ; dbcs vector set?
  1164. jnz @f ; jump if not
  1165. cmp word ptr es:[di], 0 ; zero byte data block?
  1166. jz @f ; jump if so
  1167. push di
  1168. push ax
  1169. push cx
  1170. mov cx,es:[di] ; load block length
  1171. add di,2 ; points actual data
  1172. xor al,al ; fill bytes
  1173. rep stosb ; clear data block
  1174. pop cx
  1175. pop ax
  1176. pop di
  1177. @@:
  1178. ret
  1179. setdbcs_before_copy endp
  1180. endif
  1181. getcountrydestination proc near
  1182. ;get the destination address in the dos country info table.
  1183. ;input: al - data id
  1184. ; es:di -> dos_country_cdpg_info
  1185. ;on return:
  1186. ; es:di -> destination address of the matching data id
  1187. ; carry set if no matching data id found in dos.
  1188. push cx
  1189. add di,ccnumber_of_entries ;skip the reserved area, syscodepage etc.
  1190. mov cx,word ptr es:[di] ;get the number of entries
  1191. inc di
  1192. inc di ;si -> the first start entry id
  1193. getcntrydest:
  1194. cmp byte ptr es:[di],al
  1195. je getcntrydest_ok
  1196. cmp byte ptr es:[di],setcountryinfo ;was it setcountryinfo entry?
  1197. je getcntrydest_1
  1198. add di,5 ;next data id
  1199. jmp short getcntrydest_loop
  1200. getcntrydest_1:
  1201. add di,new_country_size + 3 ;next data id
  1202. getcntrydest_loop:
  1203. loop getcntrydest
  1204. stc
  1205. jmp short getcntrydest_exit
  1206. getcntrydest_ok:
  1207. cmp al,setcountryinfo ;select country info?
  1208. jne getcntrydest_ok1
  1209. inc di ;now di -> cccountryinfolen
  1210. jmp short getcntrydest_exit
  1211. getcntrydest_ok1:
  1212. les di,dword ptr es:[di+1] ;get the destination in es:di
  1213. getcntrydest_exit:
  1214. pop cx
  1215. ret
  1216. getcountrydestination endp
  1217. readincontrolbuffer proc near
  1218. ;move file pointer to cx:dx
  1219. ;read ax bytes into the control buffer. (should be less than 2 kb)
  1220. ;si will be set to 0 hence ds:si points to the control buffer.
  1221. ;entry: cx,dx offset from the start of the file where the read/write pointer
  1222. ; be moved.
  1223. ; ax - # of bytes to read
  1224. ; bx - file handle
  1225. ; ds - buffer seg.
  1226. ;return: the control data information is read into ds:0 - ds:0200.
  1227. ; cx,dx value destroyed.
  1228. ; carry set if error in reading file.
  1229. push ax ;# of bytes to read
  1230. mov ax, 4200h
  1231. stc
  1232. int 21h ;move pointer
  1233. pop cx ;# of bytes to read
  1234. jc ricb_exit
  1235. xor dx,dx ;ds:dx -> control buffer
  1236. xor si,si
  1237. mov ah,3fh ;read into the buffer
  1238. stc
  1239. int 21h ;should be less than 1024 bytes.
  1240. ricb_exit:
  1241. ret
  1242. readincontrolbuffer endp
  1243. set_country_path proc near
  1244. ;in: ds - sysinitseg, es - confbot, si -> start of the asciiz path string
  1245. ; dosinfo_ext, cntry_drv, cntry_root, cntry_path
  1246. ; assumes current directory is the root directory.
  1247. ;out: ds:di -> full path (cntry_drv).
  1248. ; set the cntry_drv string from the country=,,path command.
  1249. ; ds, es, si value saved.
  1250. push si
  1251. push ds ;switch ds, es
  1252. push es
  1253. pop ds
  1254. pop es ;now ds -> confbot, es -> sysinitseg
  1255. call chk_drive_letter ;current ds:[si] is a drive letter?
  1256. jc scp_default_drv ;no, use current default drive.
  1257. mov al, byte ptr ds:[si]
  1258. inc si
  1259. inc si ;si -> next char after ":"
  1260. jmp short scp_setdrv
  1261. scp_default_drv:
  1262. mov ah, 19h
  1263. int 21h
  1264. add al, "A" ;convert it to a character.
  1265. scp_setdrv:
  1266. mov cs:cntry_drv, al ;set the drive letter.
  1267. mov di, offset cntry_path
  1268. mov al, byte ptr ds:[si]
  1269. cmp al, "\"
  1270. je scp_root_dir
  1271. cmp al,"/" ;let's accept "/" as an directory delim
  1272. je scp_root_dir
  1273. jmp short scp_path
  1274. scp_root_dir:
  1275. dec di ;di -> cntry_root
  1276. scp_path:
  1277. call move_asciiz ;copy it
  1278. mov di, offset cntry_drv
  1279. scpath_exit:
  1280. push ds ;switch ds, es
  1281. push es
  1282. pop ds
  1283. pop es ;ds, es value restored
  1284. pop si
  1285. ret
  1286. set_country_path endp
  1287. chk_drive_letter proc near
  1288. ;check if ds:[si] is a drive letter followed by ":".
  1289. ;assume that every alpha charater is already converted to upper case.
  1290. ;carry set if not.
  1291. push ax
  1292. cmp byte ptr ds:[si], "A"
  1293. jb cdletter_no
  1294. cmp byte ptr ds:[si], "Z"
  1295. ja cdletter_no
  1296. cmp byte ptr ds:[si+1], ":"
  1297. jne cdletter_no
  1298. jmp short cdletter_exit
  1299. cdletter_no:
  1300. stc
  1301. cdletter_exit:
  1302. pop ax
  1303. ret
  1304. chk_drive_letter endp
  1305. move_asciiz proc near
  1306. ;in: ds:si -> source es:di -> target
  1307. ;out: copy the string until 0.
  1308. ;assumes there exists a 0.
  1309. masciiz_loop:
  1310. movsb
  1311. cmp byte ptr ds:[si-1],0 ;was it 0?
  1312. jne masciiz_loop
  1313. ret
  1314. move_asciiz endp
  1315. ;
  1316. ; ds:dx points to string to output (asciz)
  1317. ;
  1318. ; prints <badld_pre> <string> <badld_post>
  1319. badfil:
  1320. push cs
  1321. pop es
  1322. mov si,dx
  1323. badload:
  1324. mov dx,offset badld_pre ;want to print config error
  1325. ifdef JAPAN
  1326. call IsDBCSCodePage
  1327. jz @f
  1328. mov dx,offset badld_pre2
  1329. @@:
  1330. endif
  1331. mov bx, offset crlfm
  1332. prnerr:
  1333. push cs
  1334. pop ds
  1335. call print
  1336. prn1:
  1337. mov dl,es:[si]
  1338. or dl,dl
  1339. jz prn2
  1340. mov ah,std_con_output
  1341. int 21h
  1342. inc si
  1343. jmp prn1
  1344. prn2:
  1345. mov dx,bx
  1346. call print
  1347. cmp donotshownum,1 ; suppress line number when handling command.com
  1348. je prnexit
  1349. call error_line
  1350. prnexit:
  1351. ret
  1352. print:
  1353. cmp cs:bEchoConfig, 0 ; NTVDM skip print call, Jonle
  1354. je prnexit
  1355. mov ah,std_con_string_output
  1356. int 21h
  1357. ret
  1358. if noexec
  1359. ; load non exe file called [ds:dx] at memory location es:bx
  1360. ldfil:
  1361. push ax
  1362. push bx
  1363. push cx
  1364. push dx
  1365. push si
  1366. push ds
  1367. push bx
  1368. xor ax,ax ;open the file
  1369. mov ah,open
  1370. stc ;in case of int 24
  1371. int 21h
  1372. pop dx ;clean stack in case jump
  1373. jc ldret
  1374. push dx
  1375. mov bx,ax ;handle in bx
  1376. xor cx,cx
  1377. xor dx,dx
  1378. mov ax,(lseek shl 8) or 2
  1379. stc ;in case of int 24
  1380. int 21h ; get file size in dx:ax
  1381. jc ldclsp
  1382. or dx,dx
  1383. jnz lderrp ; file >64k
  1384. pop dx
  1385. push dx
  1386. mov cx,es ; cx:dx is xaddr
  1387. add dx,ax ; add file size to xaddr
  1388. jnc dosize
  1389. add cx,1000h ; ripple carry
  1390. dosize:
  1391. mov ax,dx
  1392. call pararound
  1393. mov dx,ax
  1394. add cx,dx
  1395. cmp cx,[alloclim]
  1396. jb okld
  1397. jmp mem_err
  1398. okld:
  1399. xor cx,cx
  1400. xor dx,dx
  1401. mov ax,lseek shl 8 ;reset pointer to beginning of file
  1402. stc ;in case of int 24
  1403. int 21h
  1404. jc ldclsp
  1405. pop dx
  1406. push es ;read the file in
  1407. pop ds ;trans addr is ds:dx
  1408. mov cx,0ff00h ; .com files arn't any bigger than
  1409. ; 64k-100h
  1410. mov ah,read
  1411. stc ;in case of int 24
  1412. int 21h
  1413. jc ldcls
  1414. mov si,dx ;check for exe file
  1415. cmp word ptr [si],"ZM"
  1416. clc ; assume ok
  1417. jnz ldcls ; only know how to do .com files
  1418. stc
  1419. jmp short ldcls
  1420. lderrp:
  1421. stc
  1422. ldclsp:
  1423. pop dx ;clean stack
  1424. ldcls:
  1425. pushf
  1426. mov ah,close ;close the file
  1427. stc
  1428. int 21h
  1429. popf
  1430. ldret: pop ds
  1431. pop si
  1432. pop dx
  1433. pop cx
  1434. pop bx
  1435. pop ax
  1436. ret
  1437. endif
  1438. ;
  1439. ; open device pointed to by dx, al has access code
  1440. ; if unable to open do a device open null device instead
  1441. ;
  1442. open_dev:
  1443. call open_file
  1444. jnc open_dev3
  1445. open_dev1:
  1446. mov dx,offset nuldev
  1447. call open_file
  1448. of_ret:
  1449. ret
  1450. open_dev3:
  1451. mov bx,ax ; handle from open to bx
  1452. xor ax,ax ; get device info
  1453. mov ah,ioctl
  1454. int 21h
  1455. test dl,10000000b
  1456. jnz of_ret
  1457. mov ah,close
  1458. int 21h
  1459. jmp open_dev1
  1460. open_file:
  1461. mov ah,open
  1462. stc
  1463. int 21h
  1464. ret
  1465. ; test int24. return back to dos with the fake user response of "fail"
  1466. int24:
  1467. mov al, 3 ; fail the system call
  1468. iret ; return back to dos.
  1469. include copyrigh.inc ; copyright statement
  1470. nuldev db "NUL",0
  1471. condev db "CON",0
  1472. auxdev db "AUX",0
  1473. prndev db "PRN",0
  1474. MseDev db "MOUSE",0 ; NTVDM for internal spc mouse
  1475. ; NTVDM we use a temp file for config.sys 23-Nov-1992 Jonle
  1476. ; config db "C:\CONFIG.SYS",0
  1477. config db 64 dup (0)
  1478. cntry_drv db "A:"
  1479. cntry_root db "\"
  1480. cntry_path db "COUNTRY.SYS",0
  1481. db 52 dup (0)
  1482. country_file_signature db 0ffh,'COUNTRY'
  1483. cntrycodepage_id dw ?
  1484. commnd db "\COMMAND.COM",0
  1485. db 51 dup (0)
  1486. pathstring db 64 dup (0)
  1487. comtab label byte
  1488. ; cmd len command cmd code
  1489. ; ------- ------- --------
  1490. ;
  1491. db 7, "BUFFERS", 'B'
  1492. db 5, "BREAK", 'C'
  1493. db 6, "DEVICE", 'D'
  1494. db 10, "DEVICEHIGH", 'U'
  1495. db 5, "FILES", 'F'
  1496. db 4, "FCBS", 'X'
  1497. db 9, "LASTDRIVE", 'L'
  1498. db 10, "MULTITRACK", 'M'
  1499. db 8, "DRIVPARM", 'P'
  1500. if stacksw
  1501. db 6, "STACKS", 'K'
  1502. endif
  1503. db 7, "COUNTRY", 'Q'
  1504. db 5, "SHELL", 'S'
  1505. db 7, "INSTALL", 'I'
  1506. db 7, "COMMENT", 'Y'
  1507. db 3, "REM", '0'
  1508. db 8, "SWITCHES", '1'
  1509. db 3, "DOS", 'H'
  1510. db 10, "ECHOCONFIG", 'E' ; NTVDM 14-Aug-1992 Jonle
  1511. db 11, "NTCMDPROMPT", 'T' ; NTVDM 06-May-1993 sudeepb
  1512. db 7, "DOSONLY", 'O' ; NTVDM 06-May-1993 sudeepb
  1513. db 0
  1514. ifdef NEC_98
  1515. public deviceparameters
  1516. deviceparameters a_deviceparameters <0,dev_3inch720kb,0,80>
  1517. endif ;NEC_98
  1518. hlim dw 2
  1519. slim dw 9
  1520. public bEchoConfig ; NTVDM - 14-Aug-1992 Jonle
  1521. bEchoConfig db 0
  1522. public drive
  1523. drive db ?
  1524. public switches
  1525. switches dw 0
  1526. ifdef NEC_98
  1527. ; the following are the recommended bpbs for the media that we know of so
  1528. ; far.
  1529. ; 48 tpi diskettes
  1530. bpb48t dw 512
  1531. db 2
  1532. dw 1
  1533. db 2
  1534. dw 112
  1535. dw 2*9*40
  1536. db 0fdh
  1537. dw 2
  1538. dw 9
  1539. dw 2
  1540. dd 0
  1541. dd 0
  1542. ; 96tpi diskettes
  1543. bpb96t dw 512
  1544. db 1
  1545. dw 1
  1546. db 2
  1547. dw 224
  1548. dw 2*15*80
  1549. db 0f9h
  1550. dw 7
  1551. dw 15
  1552. dw 2
  1553. dd 0
  1554. dd 0
  1555. ; 3 1/2 inch diskette bpb
  1556. bpb35 dw 512
  1557. db 2
  1558. dw 1
  1559. db 2
  1560. dw 70h
  1561. dw 2*9*80
  1562. db 0f9h
  1563. dw 3
  1564. dw 9
  1565. dw 2
  1566. dd 0
  1567. dd 0
  1568. bpb35h dw 0200h
  1569. db 01h
  1570. dw 0001h
  1571. db 02h
  1572. dw 0e0h
  1573. dw 0b40h
  1574. db 0f0h
  1575. dw 0009h
  1576. dw 0012h
  1577. dw 0002h
  1578. dd 0
  1579. dd 0
  1580. ;
  1581. ; m037 - BEGIN
  1582. ;
  1583. bpb288 dw 0200h
  1584. db 02h
  1585. dw 0001h
  1586. db 02h
  1587. dw 240
  1588. dw 2*36*80
  1589. db 0f0h
  1590. dw 0009h
  1591. dw 36
  1592. dw 0002h
  1593. dd 0
  1594. dd 0
  1595. ;
  1596. ; m037 - END
  1597. ;
  1598. bpbtable 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. dw bpb35 ; ERIMO m037
  1608. dw bpb288 ; 2.88 MB diskette drives m037
  1609. endif ;NEC_98
  1610. switchlist db 8,"FHSTDICN" ; preserve the positions of n and c.
  1611. ; the following depend on the positions of the various letters in switchlist
  1612. ;switchnum equ 11111000b ; which switches require number
  1613. flagec35 equ 00000100b ; electrically compatible 3.5 inch disk drive
  1614. flagdrive equ 00001000b
  1615. flagcyln equ 00010000b
  1616. flagseclim equ 00100000b
  1617. flagheads equ 01000000b
  1618. flagff equ 10000000b
  1619. sysinitseg ends
  1620. end
  1621.