3 \ call DOS executables in hForth
\r
5 \ By 1994.12 Lee,Sheen
\r
7 \ 1995. 10. 28. Revised by Wonyong Koh.
\r
8 \ 1996. 12. 14. Revise (DOSEXEC).
\r
11 \ parseDOSEXEC ( c_addr u -- )
\r
12 \ Extract DOS program name from the string 'c_addr u', pass the
\r
13 \ remaining string to the DOS program and empty the input source.
\r
14 \ DOS> ( "program_name command_line" -- )
\r
15 \ Parse the following input source and transfer it to 'parseDOSEXEC'.
\r
16 \ Program name should include full directory path.
\r
18 \ DOS> C:\BIN\DOS\EDIT.COM TEST.TXT
\r
19 \ Q ( "command_line" -- )
\r
20 \ Start Q editor. Current path is C:\BIN\Q.EXE.
\r
21 \ U ( "command_line" -- )
\r
22 \ Start U editor. Current path is C:\BIN\UEDIT\U.EXE.
\r
25 GET-ORDER GET-CURRENT
\r
27 NONSTANDARD-WORDLIST SET-CURRENT
\r
29 BL WORD DOS-WORDLIST FIND NIP [IF]
\r
30 GET-ORDER DOS-WORDLIST SWAP 1+ SET-ORDER
\r
31 DOS-WORDLIST SET-CURRENT
\r
35 CREATE PARA-BLOCK \ Parameter block for EXEC dos fuction
\r
36 0 , \ environment block
\r
37 0 , \ offset of CMD-LINE
\r
38 DS@ , \ segment of CMD-LINE
\r
39 0 , 0 , \ no data in PSP #1
\r
40 0 , 0 , \ no data in PSP #2
\r
42 CODE ((DOSEXEC)) ( asciiz-addr command-line-addr -- 0 | error-code )
\r
43 BX PARA-BLOCK CELL+ ) MOV,
\r
45 1000 # BX MOV, \ reserve 64 KB
\r
49 CHAR " PARSE model" ENVIRONMENT? DROP
\r
50 CHAR " PARSE EXE Model" COMPARE 0=
\r
52 10 # AX SUB, \ PSP//code-segment//data-segment/HERE
\r
53 AX ES MOV, \ HERE 16 / 1+ CS DS - 10 + +
\r
54 DS CX MOV, \ is program size in # paragraphs
\r
59 4A # AH MOV, \ function number for SET BLOCK function
\r
60 21 INT, \ ES: memory area segment address
\r
62 DX POP, \ name of the program
\r
65 PARA-BLOCK # BX MOV, \ ES:BX points to parameter block
\r
66 4B00 # AX MOV, \ function number for EXEC function
\r
67 21 INT, \ call dos function
\r
77 \ Make all other tasks sleep except SystemTask before calling DOS program.
\r
78 \ Call DOS program, then awake the tasks temperarily being slept.
\r
79 CHAR " PARSE model" ENVIRONMENT? DROP
\r
80 CHAR " PARSE ROM Model" COMPARE 0=
\r
81 CHAR " PARSE model" ENVIRONMENT? DROP
\r
82 CHAR " PARSE RAM Model" COMPARE 0= OR
\r
85 0 >R \ # of tasks to be awaken
\r
86 \ save active task list on return stack
\r
87 follower \ current task's follower
\r
89 @ CELL+ \ next task's follower
\r
92 DUP cell- DUP @ ['] wake = IF R> SWAP >R 1+ >R ELSE DROP THEN
\r
96 \ restore active tasks
\r
98 WHILE R> ['] wake SWAP ! 1- >R
\r
101 CHAR " PARSE model" ENVIRONMENT? DROP
\r
102 CHAR " PARSE EXE Model" COMPARE 0=
\r
105 0 >R \ # of tasks to be awaken
\r
106 \ save active task list on return stack
\r
107 follower \ current task's follower
\r
109 @ code@ CELL+ CELL+ code@ \ next task's follower
\r
112 DUP @ cell- DUP code@ ['] wake = IF R> SWAP >R 1+ >R ELSE DROP THEN
\r
116 \ restore active tasks
\r
118 WHILE R> ['] wake SWAP code! 1- >R
\r
122 \ Call DOS program identified with the name and pass remaining input source
\r
123 \ to the program. This word modifies input source, which is against ANS
\r
124 \ Forth Standard recommandation.
\r
125 : parseDOSEXEC ( c_addr u -- )
\r
126 asciiz SOURCE >IN @ /STRING \ asciiz c_addr u
\r
128 SWAP 1- TUCK C! \ asciiz c_addr-1
\r
130 SOURCE >IN ! DROP ;
\r
132 NONSTANDARD-WORDLIST SET-CURRENT
\r
133 BL WORD Ðe
\8bi·³Â
\89\9db-WORDLIST FIND NIP [IF]
\r
134 GET-ORDER Ðe
\8bi·³Â
\89\9db-WORDLIST SWAP 1+ SET-ORDER
\r
137 : DOS> ( "program_name command_line" -- )
\r
138 BL PARSE parseDOSEXEC ;
\r
140 : Q ( "command_line" -- )
\r
141 [ BL WORD Ðe
\8bi·³Â
\89\9db-WORDLIST FIND NIP [IF]
\r
142 ] GRAPHIC? DUP IF TEXT THEN
\r
143 S" C:\BIN\Q.EXE" parseDOSEXEC IF HGRAPHIC THEN [ [ELSE]
\r
144 ] S" C:\BIN\Q.EXE" parseDOSEXEC [ [THEN] ]
\r
147 : U ( "command_line" -- )
\r
148 S" C:\BIN\UEDIT\U.EXE" parseDOSEXEC ;
\r
150 SET-CURRENT SET-ORDER
\r
153 CHAR " PARSE FILE" ENVIRONMENT?
\r
155 0= [IF] << CON [THEN]
\r