]>
Commit | Line | Data |
---|---|---|
e58a7a25 L |
1 | ; CPSMIT.ASM\r |
2 | ; KERMIT - (Celtic for "FREE")\r | |
3 | ;\r | |
4 | ; This is the CP/M-80 implementation of the Columbia University\r | |
5 | ; KERMIT file transfer protocol.\r | |
6 | ;\r | |
7 | ; Version 4.0\r | |
8 | ;\r | |
9 | ; Copyright June 1981,1982,1983,1984,1985\r | |
10 | ; Columbia University\r | |
11 | ;\r | |
12 | ; Originally written by Bill Catchings of the Columbia University Center for\r | |
13 | ; Computing Activities, 612 W. 115th St., New York, NY 10025.\r | |
14 | ;\r | |
15 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,\r | |
16 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many\r | |
17 | ; others. \r | |
18 | ;\r | |
19 | ; This file contains the system-independent initialization, the main\r | |
20 | ; loop, and the commands that don't have any place better to go.\r | |
21 | ; All the SET xxx and status routines now in CPSCOM.ASM as CPSMIT.ASM\r | |
22 | ; was getting too big.\r | |
23 | ;\r | |
24 | ; revision history:\r | |
25 | ;\r | |
26 | ;edit 30, 29-Mar-1991 by MF. When looking up a TAKE-file in a TAKE command\r | |
27 | ; and the file is not found, complain if it's not the first TAKE of\r | |
28 | ; the current program execution (the automatic TAKE of KERMIT.INI)\r | |
29 | ;edit 29, 25-Mar-1991 by MF. Add STAY command as a synonym for SET NO-EXIT\r | |
30 | ; command per Martin J. Carter of Nottingham University in the U.K.\r | |
31 | ;edit 28, 21-Mar-1991 by MF. Modify code after "inp2a" in INPUT command\r | |
32 | ; so a ^C will halt TAKE-file processing\r | |
33 | ;edit 27, 27-Feb-1991 by MF. Add QUIT as a synonym for EXIT per code of\r | |
34 | ; Dr. Martin J. Carter of Nottingham University, U.K. Recognizing QUIT\r | |
35 | ; helps those who forget they're not in MS-Kermit, C-Kermit,\r | |
36 | ; Kermit-32 etc. Also add commands so that CONNECT, RECEIVE and SEND may\r | |
37 | ; be abbreviated to C, R and S, respectively.\r | |
38 | ;edit 26, 5-Nov-1990 by MF. Cosmetic changes to main HELP messages for\r | |
39 | ; COPY and RENAME commands.\r | |
40 | ;edit 25, 1-Nov-1990 by MF. Made the following command-name changes in the\r | |
41 | ; interest of uniformity of nomenclature (per suggestions of FDC):\r | |
42 | ; FCOPY to COPY, FRENAME to RENAME and STRING to OUTPUT.\r | |
43 | ; This means we'll have to type "CO" for CONNECT and "REC" for \r | |
44 | ; RECEIVE but with REMOTE now with us we have to do the latter anyway.\r | |
45 | ;edit 24, 18-Sep-1990 by MF. Implemented FRENAME command to rename a\r | |
46 | ; CP/M file.\r | |
47 | ;edit 23, 9-Sep-1990 by MF. Implemented commands to be sent to a\r | |
48 | ; remote Kermit Server (Remote commands).\r | |
49 | ; Implemented setting of packet sizes for RECEIVE and SEND.\r | |
50 | ; Put DIRECTORY/STRING help texts in proper alphabetical position.\r | |
51 | ; edit 22, July 6th, 1987 by OBSchou. Added a dummy Commandline to be\r | |
52 | ; loaded for debugging purposes as DDT destroys any command line at 80H\r | |
53 | ; Also fixed a bug or two...\r | |
54 | ;\r | |
55 | ; edit 21, April 8th, 1987.\r | |
56 | ; Various bits, including more SET SENDRECEIVE options, and make \r | |
57 | ; PADDING and PADCHAR valid options. Have I wasted my time, or \r | |
58 | ; there still systems that use padding?? Fixed a bug in the INPUT\r | |
59 | ; command so we know how many characters there are to check for. Also\r | |
60 | ; hived off the SET commands to make a new file, CPSCOM.ASM thereby\r | |
61 | ; reducing the size of CPSMIT.ASM. Also rename COPY command to FCOPY\r | |
62 | ; hence retaining a single C to imply connect.\r | |
63 | ;\r | |
64 | ; edit 20, March 30, 1987 by OBSchou. \r | |
65 | ; added code for no exit to CPM if a command tail is done (optional)\r | |
66 | ; by the SET NO-EXIT command. Added bits for SET AUTORECEIVE to enable \r | |
67 | ; or inhibit automatic receive of several files (if something is coming \r | |
68 | ; along from the remote side, do a receive. Toss first packet away.) \r | |
69 | ; This is first step to SERVER???\r | |
70 | ; Also added back the INPUT command.\r | |
71 | ;\r | |
72 | ; edit 19, March 16, 1987. Moved the code to check for and execute \r | |
73 | ; command tails (See Richard Russells submission below). \r | |
74 | ; Added flags to exit to CP/M after executing a command tail. \r | |
75 | ; The KERMIT.INI file is taken before the command tail is issued.\r | |
76 | ;\r | |
77 | ; edit 18, March 11, 1987 by OBSchou.\r | |
78 | ; Added in code for TYPE <file> and PRINT <file>. Hope to add COPY \r | |
79 | ; later on. Also added in code submitted by Richard Russel, to accept\r | |
80 | ; a command tail on entry to kermit (eg KERMIT CONNECT). This facility\r | |
81 | ; if used, will replace the automatic TAKE function on loading Kermit.\r | |
82 | ; Unfortunately, you will not be dropped back to CP/M after the command\r | |
83 | ; In the future, it may be possible to either accept several commands\r | |
84 | ; on the command tail, and possibly accept the automatic TAKE facility\r | |
85 | ; as well. Low on my list of things to do.\r | |
86 | ;\r | |
87 | ; edit 17, January 28, 1987 by OBSchou for DJ Roberts of Leicester\r | |
88 | ; Also added a couple of fixes [obs]\r | |
89 | ;\r | |
90 | ; DJR January 1987 David J. Roberts.\r | |
91 | ; USER made a SET option\r | |
92 | ; STATUS output placed in alphabetical order\r | |
93 | ; Report DEBUG mode and default disk \r | |
94 | ; Name of LOG file on SHOW/STATUS display\r | |
95 | ;\r | |
96 | ;\r | |
97 | ; edit 16 December 1st, OBSchou. Fixed bug in that if the overlay is not in\r | |
98 | ; place or correct then prtstr is not called to print the error message\r | |
99 | ; (As prtstr has been moved out of the system independent code)\r | |
100 | ;\r | |
101 | ; edit 15 November 10, 1986 by OBSchou. Re-inserted Pause and Break \r | |
102 | ; commands for release.\r | |
103 | ;\r | |
104 | ; edit 14 August 29, 1986. Removed PAUSE,BREAK,INPUT and SET CASE as \r | |
105 | ; these have not been fully coded or debugged. (For next \r | |
106 | ; version of Kermit-80...). Also tidied up a bit.\r | |
107 | ;\r | |
108 | ; 13 by OBSchou for Godfrey Nix. He writes:\r | |
109 | ; edit August 11,1986 Godfrey Nix, Nottingham University [gnn]\r | |
110 | ; To insert code for setting the packet start character on\r | |
111 | ; both send and receive packets (default is still 01H)\r | |
112 | ; and make GET and RECEIVE to be separate;\r | |
113 | ; use with edits to CP4PKT, CP4UTL\r | |
114 | ;\r | |
115 | ; edit 12: 19 June, 1986 by OBSchou. Added PAUSE and BREAK facility.\r | |
116 | ; Breaks simulate a call to sysint which tests for a B being passed.\r | |
117 | ; Note this is only useful if the system dependent code supports breaks,\r | |
118 | ; and an appropriate message is returned if breaks are not possible.\r | |
119 | ; Also added is the command entry for INPUT, which waits for a string\r | |
120 | ; from the host for a given time. The time is a very variable counter\r | |
121 | ; incremented every BDOS call. Trial and error will give a reasonable\r | |
122 | ; value. STRING acceps a string from the use and then sends it on \r | |
123 | ; to the host. These new commands allow a user to (almost) set up auto\r | |
124 | ; log on files, where BREAKS/INPUT/STRING/STRING partially emulate a user\r | |
125 | ; (AI LURES OK and all that). Still could do with a test, eg if not a\r | |
126 | ; correctly returned string go back n steps. This would make a fairly \r | |
127 | ; simple TAKE command a lot more complicated.\r | |
128 | ;\r | |
129 | ;edit 11: 30 May, 1986 OBSchou. Added in a couple of more routines and such\r | |
130 | ;\r | |
131 | ;edit 10: 27 May, 1986 OBSchou. Added in support for USER function\r | |
132 | ; removed XMIT test and routine, but also added SET FLOW-CONTROL\r | |
133 | ; (set for XON/XOFF flow control in both directions) and a \r | |
134 | ; SET CASE-SENSITIVE ON/OFF (if on => a # A, if ON => a=A)\r | |
135 | ;\r | |
136 | ;edit 9: 13 May, 1986 OBSchou, Loughborough University, UK\r | |
137 | ; Added in code for SET XMIT character to allow setting of the\r | |
138 | ; character to wait for from the host during TRANSMIT. It is\r | |
139 | ; a line feed by default. Also added a TAKE command, to take: commands\r | |
140 | ; from a named disk file. If a file is TAKEn, then all BDOS calls \r | |
141 | ; are trapped and tested for console input. If so, we substitute a \r | |
142 | ; character (or buffer) from the TAKE file specified.\r | |
143 | ; This may also be used in the future for a CPKERMIT.INI \r | |
144 | ; to be evaluated during Kermit initialsation.\r | |
145 | ;\r | |
146 | ; edit 8: February 6, 1895\r | |
147 | ; Add a PORT status/show routine for those machines that have more\r | |
148 | ; than one they can talk to. It also required a port storage variable\r | |
149 | ; a la SPEED and the necessary code to handle it in the SET routine.\r | |
150 | ; [Hal Hostetler]\r | |
151 | ;\r | |
152 | ; edit 7: 13-Jan-85 by Vanya J.Cooper Pima Commun. College Tel: 602-884-6809\r | |
153 | ;\r | |
154 | ;pcc003-pcc005 2-Jan-85 vjc modules:cp4mit,cp4tt,cp4utl\r | |
155 | ; These edits must all be installed together and change the way\r | |
156 | ; logging is handled. The log file spec is moved to a separate\r | |
157 | ; fcb, and not opened until an actual CONNECT command is given.\r | |
158 | ; This takes care of a NASTY bug that if you used any other file\r | |
159 | ; command between the LOG and CONNECT, the log file would get\r | |
160 | ; written over the last file used. This also allows logging to\r | |
161 | ; be "permanently" enabled until an CLOSE (new command) for all\r | |
162 | ; CONNECT sessions, like most other kermits do. If a log file\r | |
163 | ; already exists, it will be appended to. Also add two new\r | |
164 | ; CONNECT mode commands <esc>Q to suspend logging and <esc>R to\r | |
165 | ; resume. <esc>R means something else during TRANSMIT, but\r | |
166 | ; logging is never on then, so there shouldn't be any conflict.\r | |
167 | ; I also changed the write code, so that it can handle one more\r | |
168 | ; character after the XOFF is send to stop the host. This allows\r | |
169 | ; a little "slop" for systems that don't stop immediately (such\r | |
170 | ; as TOPS10), but it didn't help much.\r | |
171 | ;\r | |
172 | ;pcc012 4-Jan-85 vjc modules:cp4mit,cp4tt,cp4utl\r | |
173 | ; Use the big buffer for the log file. Move the log file back\r | |
174 | ; into the common fcb and only save the drive, name, and\r | |
175 | ; extension between connects. Add new routines to cp4utl to\r | |
176 | ; create or append to an existing file, and to conditionally\r | |
177 | ; advance buffers only if in memory. Remove edit pcc003 that\r | |
178 | ; allows one more character after the xoff, since it didn't\r | |
179 | ; really work very well and does not fit in well with the way\r | |
180 | ; the buffer advancing routines are set up. If someone still\r | |
181 | ; thinks this would be useful, it could be put back in with a\r | |
182 | ; little more work.\r | |
183 | ; \r | |
184 | ; While testing this edit, I also noticed another bug that\r | |
185 | ; the command parsing routines do not limit or check the\r | |
186 | ; length of command lines or file specs, trashing what ever\r | |
187 | ; comes after them. Currently because of where the fcb and\r | |
188 | ; command buffer are located, this does not usually cause a\r | |
189 | ; problem, but could if an extremely long line was typed in,\r | |
190 | ; or in the future multiple fcbs defined elsewhere in memory\r | |
191 | ; were used. Maybe this should be put on the bug list\r | |
192 | ; somewhere.\r | |
193 | ;\r | |
194 | ;pcc013 8-Jan-85 vjc modules:cp4mit,cp4utl,cp4typ\r | |
195 | ; Replace CLOSE command to cancel session logging to SET\r | |
196 | ; LOGGING ON/OFF. This seems to fit in with the command\r | |
197 | ; structure better. Default the log file to KERMIT.LOG\r | |
198 | ; incase no previous LOG command. Logging is also enabled\r | |
199 | ; by LOG command, as before.\r | |
200 | ;\r | |
201 | ; edit 6: September 8, 1984\r | |
202 | ; Add VERSION command, to display the internal version strings.\r | |
203 | ; Move command tables here from CP4UTL, and translate string\r | |
204 | ; lengths in them to decimal (how many fingers do YOU got?).\r | |
205 | ; Replace some jump tables with dispatch addresses in tables.\r | |
206 | ; Make help text for SET command consistent with top level help text.\r | |
207 | ;\r | |
208 | ; edit 5: August 21, 1984\r | |
209 | ; Add word at 0100H to allow us to exit cleanly from DDT (shifting\r | |
210 | ; entry section by two bytes).\r | |
211 | ;\r | |
212 | ; edit 4: August 3, 1984 (CJC)\r | |
213 | ; Remove "mover" from entry section, as it now lives in CP4SYS.\r | |
214 | ;\r | |
215 | ; edit 3: July 27, 1984 (CJC)\r | |
216 | ; Merge LASM support from Toad Hall: most of CP4MIT is now in CP4UTL.\r | |
217 | ; When assembling with LASM, CP4MIT is linked by CP4DEF; it links to\r | |
218 | ; CP4PKT. Add SET TACTRAP command. Separate out display routines so\r | |
219 | ; we can eventually do "SHOW <parameter>". Save both bytes of baud\r | |
220 | ; rate in speed, and check both bytes when displaying baud rate. Move\r | |
221 | ; header info to CP4KER.ASM. Add onoff and chkkey routines to simplify\r | |
222 | ; SET command (Toad Hall)\r | |
223 | ;\r | |
224 | ; edit 2: June 8, 1984\r | |
225 | ; formatting and documentation; delete unreferenced variables and some\r | |
226 | ; unnecessary labels; move setpar here from cp4pkt; add module version\r | |
227 | ; string; make this version 4.01.\r | |
228 | ;\r | |
229 | ; edit 1: May, 1984\r | |
230 | ; extracted from CPMBASE.M80 version 3.9; modifications are described\r | |
231 | ; in the accompanying .UPD file.\r | |
232 | \r | |
233 | ;\f\r | |
234 | ASEG\r | |
235 | ORG 100H\r | |
236 | \r | |
237 | ; The CCP invokes programs with a CALL 100H, with the stack pointer set to\r | |
238 | ; 100H. When we exit to CP/M, we do so with a RET, avoiding a warm boot.\r | |
239 | ; Unfortunately, DDT starts programs with a jump, not a call, so when we\r | |
240 | ; attempt to return to CP/M, we blow the stack and use the word at 100H as\r | |
241 | ; the new PC. Put a 0 there so we reboot instead of dying horribly.\r | |
242 | ; (Fortunately, this happens to be two NOP's).\r | |
243 | dw 0\r | |
244 | jmp start ; Bypass entry section\r | |
245 | \r | |
246 | ;\r | |
247 | ; Entry section for system-independent part. This contains\r | |
248 | ; jumps to routines needed by the system support module.\r | |
249 | ;\r | |
250 | entries:\r | |
251 | jmp kermit ; reentry address\r | |
252 | jmp nout ; output HL in decimal\r | |
253 | entsiz equ $-entries ; length of entry section\r | |
254 | ;\r | |
255 | ; End of entry section. As a consistency check, the expected\r | |
256 | ; length of this section is stored by the system-dependent\r | |
257 | ; module in the linkage section at the end of Kermit, and\r | |
258 | ; tested at initialization.\r | |
259 | \r | |
260 | mitver: db 'CPSMIT.ASM (30) 29-Mar-1991$' ; name, edit number, date\r | |
261 | ;\f\r | |
262 | ;\r | |
263 | ; Initialization\r | |
264 | ;\r | |
265 | start: lxi h,0 ; Clear out hl pair\r | |
266 | dad sp ; and fetch the system stack pointer\r | |
267 | shld oldsp ; and save for later restoral\r | |
268 | lxi sp,stack ; move in our own stack.\r | |
269 | lxi d,version ; print Kermit version\r | |
270 | call prtstx ; before we do too much (Use fudged prtstr)\r | |
271 | mvi c,rddrv ;Get our logged in drive\r | |
272 | call BDOS\r | |
273 | inr a ;relative 1\r | |
274 | sta CURDSK ;and save it for later\r | |
275 | \r | |
276 | lda vtflg ; [OBS] Hangover from VT52 ems not possible...\r | |
277 | cpi 0ffh ; ... if 0ff stored, assume terminal = off\r | |
278 | mvi a,vtdefo\r | |
279 | jnz start0\r | |
280 | sta vtflg ; if 0ffh make it VT52 off\r | |
281 | start0:\r | |
282 | \r | |
283 | \r | |
284 | IF debug\r | |
285 | ;vvvvvvvvvvvvvvvv remove this for run time\r | |
286 | ; OBS edit 22 - add in a dummy command line to 80H\r | |
287 | lxi h,dcomln ;[22] load up dummy command line\r | |
288 | lxi d,81h ;[22] where to put it\r | |
289 | lxi b,endcoml-dcomln\r | |
290 | mov a,c ; get length to a\r | |
291 | sta 80h ; ... and save as command line length\r | |
292 | call mover ; ... and save rest of line\r | |
293 | jmp starta\r | |
294 | dcomln: db 'set baud 4800',semico\r | |
295 | db 'set dir on',semico\r | |
296 | db 'dir'\r | |
297 | db 0,0 ; just to make up space\r | |
298 | endcoml:\r | |
299 | ;^^^^^^^^^^^^^^^^ remove this for run time\r | |
300 | ENDIF ;debug\r | |
301 | \r | |
302 | \r | |
303 | starta:\r | |
304 | ;\r | |
305 | ; Make sure the overlay is in place...\r | |
306 | ;\r | |
307 | lhld lnkflg\r | |
308 | mov a,h\r | |
309 | ora l ; if lnkflg is still zero,\r | |
310 | jz start1 ; the configuration overlay is missing.\r | |
311 | lxi d,-lnksiz ; if it's not equal to lnksiz,\r | |
312 | dad d ; we've probably got the wrong\r | |
313 | mov a,h ; version of the configuration overlay.\r | |
314 | ora l\r | |
315 | jnz start2\r | |
316 | lhld lnkent ; make sure the overlay knows how long\r | |
317 | lxi d,-entsiz ; our entry section is, so they don't miss.\r | |
318 | dad d\r | |
319 | mov a,h\r | |
320 | ora l\r | |
321 | jnz start2\r | |
322 | ; might be ok.\r | |
323 | lxi h,bdos ; set xbdos address to bdos trap in our code.\r | |
324 | shld xbdos+1 ; (they may never use it...)\r | |
325 | call sysinit ; do system-dependent initialization\r | |
326 | lda bufsec ; get the max no of buffers allowed by system\r | |
327 | sta maxbsc ; save for SET BUFFER use to compare\r | |
328 | lxi d,inms26 ; offer some advice on getting help\r | |
329 | call prtstr\r | |
330 | lxi h,buff ;[19] we copy any potential command tail across\r | |
331 | lxi d,cbuff\r | |
332 | lxi b,80h ;[19] copy all 128 bytes. May use none.\r | |
333 | call mover\r | |
334 | lda 80h ; see if there is a command tail...\r | |
335 | \r | |
336 | ana a\r | |
337 | \r | |
338 | \r | |
339 | \r | |
340 | ; Remove for runtime use\r | |
341 | ; xra a ; make out there is no command tail\r | |
342 | ; Runtime => no XRA above\r | |
343 | \r | |
344 | jz startz\r | |
345 | dcr a\r | |
346 | jz startz ; one character tail...\r | |
347 | lda takflg ; if more characters, say we are have tail\r | |
348 | ori 10h ; set bit 4\r | |
349 | sta takflg\r | |
350 | sta nexitf ; exit back to CP/M after command line\r | |
351 | startz:\r | |
352 | mvi a,0ffh ; when here, system basically initiallised,...\r | |
353 | sta initflg ; apart from KERMIT.INI, so say initialised.\r | |
354 | \r | |
355 | call take1 ;[9] take a KERMIT.INI file\r | |
356 | xra a ;[MF] Say we've done it\r | |
357 | sta initak ;[MF] ...\r | |
358 | jmp kermit ; Start main loop.\r | |
359 | \r | |
360 | start1: lxi d,erms20 ; "Kermit has not been configured"\r | |
361 | call prtstx ; print error message (Use bodge for prtstr)\r | |
362 | jmp exit2 ; and exit.\r | |
363 | \r | |
364 | start2: lxi d,erms21 ; "Consistency check on configuration failed"\r | |
365 | call prtstx ; print error message\r | |
366 | jmp exit2 ; and exit.\r | |
367 | ;\f\r | |
368 | ;This is the main KERMIT loop. It prompts for and gets the users commands.\r | |
369 | \r | |
370 | kermit: lxi sp,stack ; get new stack pointer, old one might be bad.\r | |
371 | call selcon ; make sure console is selected.\r | |
372 | xra a\r | |
373 | sta mfflg1 ;reset MFNAME\r | |
374 | sta mfflg2 ;ditto\r | |
375 | sta mfflg3\r | |
376 | sta getrxflg ; clear the get/receive flag\r | |
377 | ;0=> receive, non 0 => get\r | |
378 | sta cmbflg ;[MF]Initial keyword must not be blank\r | |
379 | sta cmqflg ;[MF]Allow character-echoing during commands\r | |
380 | sta remtxt ;[MF] Clear remote-text-to-screen flag\r | |
381 | lda curdsk ; update the prompt\r | |
382 | adi 'A'-1\r | |
383 | sta kerm1+2\r | |
384 | call getun ;[11] get the user number into temp1/2\r | |
385 | lda temp1+1 ;[11] get ms value of user number\r | |
386 | cpi '0' ;[11] less than 10 => do a space\r | |
387 | jnz kerm4 ;[11] else do MS digit of user number\r | |
388 | mvi a,' ' ;[11]\r | |
389 | kerm4: sta kerm1 ;[11]\r | |
390 | lda temp1 ;[11] get ls digit of user number\r | |
391 | sta kerm1+1 ;[11] save that\r | |
392 | lda takflg ; are we in TAKE or command line??\r | |
393 | ani 11h ; strip out both bits\r | |
394 | jnz kerm5 ; still in either or both...\r | |
395 | lda nexitf ; if neither, and no-exit-flag set, we quit.\r | |
396 | ana a\r | |
397 | jnz exit ;... back to CP/M, else as you were...\r | |
398 | kerm5:\r | |
399 | lxi d,kerm\r | |
400 | call prompt ;Prompt the user.\r | |
401 | \r | |
402 | kerm7: lxi d,comtab\r | |
403 | lxi h,tophlp\r | |
404 | call keycmd ; Get a keyword\r | |
405 | xchg ; Get result (dispatch address) into HL\r | |
406 | pchl ; Dispatch.\r | |
407 | \r | |
408 | ; here from: log, setcom, read, cfmcmd\r | |
409 | kermt3: lxi d,ermes3 ;"Not confirmed"\r | |
410 | call prtstr\r | |
411 | jmp kermit ;Do it again.\r | |
412 | \r | |
413 | ; Structure of command table:\r | |
414 | ;\r | |
415 | ; 1) Number of entries.\r | |
416 | ; 2) Each entry is arranged as follows:\r | |
417 | ; a) length of command in bytes.\r | |
418 | ; b) 'name of command and $-sign'\r | |
419 | ; c) address of routine to process command\r | |
420 | ;\r | |
421 | ; ---> Note this command table is in alphabetic order.\r | |
422 | ;\r | |
423 | \r | |
424 | comtab: db 32 ; added remote\r | |
425 | ;[obs] added in COPY command, now called FCOPY\r | |
426 | ;[obs] removed remote simply to issue V4.09\r | |
427 | ;[MF]Make FCOPY/FRENAME COPY/RENAME for\r | |
428 | ;[MF]Version 4.10\r | |
429 | ;[MF]Add QUIT as a synonym for EXIT and\r | |
430 | ;[MF]C, R and S as abbreviations for\r | |
431 | ;[MF]CONNECT, RECEIVE and SEND, respectively\r | |
432 | ;[MF]Add STAY as a synonym for SET NO-EXIT\r | |
433 | db 5, 'BREAK$'\r | |
434 | dw break\r | |
435 | db 3, 'BYE$'\r | |
436 | dw bye\r | |
437 | db 1,'C$'\r | |
438 | dw telnet ;[MF]Abbreviation for CONNECT\r | |
439 | db 7, 'CONNECT$'\r | |
440 | dw telnet\r | |
441 | db 4,'COPY$'\r | |
442 | dw copy\r | |
443 | db 9, 'DIRECTORY$'\r | |
444 | dw dir\r | |
445 | db 5, 'ERASE$'\r | |
446 | dw era\r | |
447 | db 4, 'EXIT$'\r | |
448 | dw exit\r | |
449 | db 6, 'FINISH$'\r | |
450 | dw finish\r | |
451 | db 3, 'GET$'\r | |
452 | dw read ; [gnn] entry for GET\r | |
453 | db 4, 'HELP$'\r | |
454 | dw help\r | |
455 | db 5, 'INPUT$'\r | |
456 | dw input\r | |
457 | db 3, 'LOG$'\r | |
458 | dw log\r | |
459 | db 6, 'LOGOUT$'\r | |
460 | dw logout\r | |
461 | db 6, 'OUTPUT$'\r | |
462 | dw string\r | |
463 | db 5, 'PAUSE$'\r | |
464 | dw pause\r | |
465 | db 5, 'PRINT$'\r | |
466 | dw printf ;[obs] print a file\r | |
467 | db 4,'QUIT$'\r | |
468 | dw exit ;[MF]Synonym for EXIT\r | |
469 | db 1,'R$'\r | |
470 | dw read0 ;[MF]Abbreviation for RECEIVE\r | |
471 | db 7, 'RECEIVE$'\r | |
472 | dw read0 ; [gnn] not same as GET now\r | |
473 | db 6, 'REMOTE$'\r | |
474 | dw remote\r | |
475 | db 6,'RENAME$'\r | |
476 | dw rename ;[MF]\r | |
477 | db 1,'S$'\r | |
478 | dw send ;[MF]Abbreviation for SEND\r | |
479 | db 4, 'SEND$'\r | |
480 | dw send\r | |
481 | db 3, 'SET$'\r | |
482 | dw setcom\r | |
483 | db 4, 'SHOW$'\r | |
484 | dw show\r | |
485 | db 6, 'STATUS$'\r | |
486 | dw status\r | |
487 | db 4,'STAY$'\r | |
488 | dw noexit ;STAY (SET NO-EXIT)\r | |
489 | db 4, 'TAKE$' ;[9]\r | |
490 | dw take\r | |
491 | db 8, 'TRANSMIT$'\r | |
492 | dw xmit\r | |
493 | db 4, 'TYPE$'\r | |
494 | dw type ;[obs] type a file command\r | |
495 | db 7, 'VERSION$'\r | |
496 | dw shover\r | |
497 | ; db 4, 'USER$' ; removed [DRJ]\r | |
498 | ; dw user ;[10] removed [DRJ]\r | |
499 | ; top-level help message. Caps indicate keywords.\r | |
500 | ; this text is also printed by the HELP command.\r | |
501 | \r | |
502 | tophlp: \r | |
503 | db cr,lf,'BREAK to send a break to the host'\r | |
504 | db cr,lf,'BYE to host (LOGOUT) and exit to CP/M'\r | |
505 | db cr,lf,'CONNECT to host on selected port'\r | |
506 | db cr,lf,'COPY to copy a CP/M file'\r | |
507 | db cr,lf,'DIRECTORY of current used Micro-disk'\r | |
508 | db cr,lf,'ERASE a CP/M file'\r | |
509 | db cr,lf,'EXIT to CP/M'\r | |
510 | db cr,lf,'FINISH running Kermit on the host'\r | |
511 | db cr,lf,'GET a file from the host'\r | |
512 | db cr,lf,'HELP by giving this message'\r | |
513 | db cr,lf,'INPUT to make the micro wait for a string from the host'\r | |
514 | db cr,lf,'LOG the terminal sessions to a file'\r | |
515 | db cr,lf,'LOGOUT the host'\r | |
516 | db cr,lf,'OUTPUT to send a specified string to the host'\r | |
517 | db cr,lf,'PAUSE to wait for a little time'\r | |
518 | db cr,lf,'PRINT a file to the printer'\r | |
519 | db cr,lf,'QUIT to CP/M'\r | |
520 | db cr,lf,'RECEIVE file from host'\r | |
521 | db cr,lf,'REMOTE to send commands to a remote server'\r | |
522 | db cr,lf,'RENAME to rename a CP/M file'\r | |
523 | db cr,lf,'SEND file to host'\r | |
524 | db cr,lf,'SET a parameter'\r | |
525 | db cr,lf,'SHOW the parameters'\r | |
526 | db cr,lf,'STATUS of Kermit'\r | |
527 | db cr,lf,'STAY at Kermit command-level after a command tail'\r | |
528 | db cr,lf,'TAKE commands from a file' ;[9]\r | |
529 | db cr,lf,'TRANSMIT file to host (in connect state)'\r | |
530 | db cr,lf,'TYPE a file to the console'\r | |
531 | db cr,lf,'VERSION of Kermit running' ;[pcc005]\r | |
532 | ; db cr,lf,'USER to set a different user number' ;removed [DJR]\r | |
533 | db '$' ;[obs] added it here to allow for expansion\r | |
534 | \r | |
535 | ;\f\r | |
536 | ; This is the BREAK command. It sends a 'B' to the system dependent\r | |
537 | ; interrupt routines (test for escape-cokebottle xxx) and do a break\r | |
538 | ; if the overlay can. Else, we tell user not to be so silly.\r | |
539 | break: call cfmcmd ; get return\r | |
540 | mvi a,'B' ; were gonna do a break if the overlay can\r | |
541 | call sysint ; try doing it..\r | |
542 | jmp kermit ; if we can do it, else\r | |
543 | lxi d,inms12 ;... say not implemented\r | |
544 | jmp kermit\r | |
545 | \r | |
546 | ;\r | |
547 | ;\r | |
548 | ; This is the BYE command. It tells the remote KERSRV to logout,\r | |
549 | ; then exits.\r | |
550 | \r | |
551 | bye: call cfmcmd\r | |
552 | call logo ;Tell the main frame to logout.\r | |
553 | jmp kermit ;If it fails, don't exit.\r | |
554 | call sysbye ; success. do system-dependent cleanup\r | |
555 | jmp exit1 ;Exit Kermit.\r | |
556 | \r | |
557 | ; This is the EXIT command. It leaves KERMIT and returns to CP/M.\r | |
558 | ; alternate entries: exit1, from BYE command;\r | |
559 | ; exit2, from initialization (if it fails)\r | |
560 | \r | |
561 | exit: call cfmcmd ; confirm...\r | |
562 | exit1: call sysexit ; do system-dependent termination\r | |
563 | exit2: \r | |
564 | jmp 0 ; return to CP/M via JUMP instead of RET.\r | |
565 | \r | |
566 | ; lhld oldsp ;Get back the system stack\r | |
567 | ; sphl ;and restore it.\r | |
568 | ; ret ;Then return to system.\r | |
569 | \r | |
570 | ; Input command. Syntax:\r | |
571 | ; INPUT [Wait period] [string]\r | |
572 | ; where\r | |
573 | ; Wait period is a time period to wat for\r | |
574 | ; string is a string to expect back from the host. Control\r | |
575 | ; characters are entered as \ and an octal number.\r | |
576 | ;\r | |
577 | ; I can see uses for this command from other routines...\r | |
578 | ;\r | |
579 | input: mvi a,cmnum ; first get the number\r | |
580 | call comnd ; get it\r | |
581 | jmp kermit ; if we dont understand it...\r | |
582 | lhld number\r | |
583 | shld waitp ; and save as the wait period\r | |
584 | lxi d,stbuff ; where to put the string\r | |
585 | mvi a,cmtxt ; get text\r | |
586 | call comnd\r | |
587 | jmp kermit ; not quite correct...\r | |
588 | sta strcnt ; string count returned in a\r | |
589 | call cfmcmd ; get a confirm\r | |
590 | \r | |
591 | lhld waitp ; multiply the number by\r | |
592 | dad h\r | |
593 | dad h ; ... 4\r | |
594 | dad h ; ... 8\r | |
595 | inx h ; but make sure it is at least 1\r | |
596 | shld waitp ; and save it away again\r | |
597 | shld waitp1 ; save in case we need to reset counter\r | |
598 | \r | |
599 | ; Right, now wait for characters comming from the line, within the\r | |
600 | ; time allowed (very fuzzy). Compare with STRING buffer\r | |
601 | ;\r | |
602 | inp1: xra a\r | |
603 | sta repcnt ; clear the host prompt chars.counter\r | |
604 | inp2: lhld waitp ; have we waited long enough\r | |
605 | dcx h\r | |
606 | shld waitp ; count less one\r | |
607 | mov a,h ; test to see if both zero\r | |
608 | ora l\r | |
609 | jnz inp20 ; nope\r | |
610 | mvi a,3 ; error is three ie total failure\r | |
611 | sta errorc\r | |
612 | jmp inp5 ; take error exit\r | |
613 | \r | |
614 | inp20: call rd1chl ; read a character from the line\r | |
615 | ani 7fh ; set flags\r | |
616 | jnz inp4 ; Not zero => we have a character from host\r | |
617 | call ckchr ; see if *WE* have a character from console\r | |
618 | push psw ; restore to modem\r | |
619 | call selmdm ; reselect the modem port\r | |
620 | pop psw\r | |
621 | ani 7fh ; strip parity (should not be there)\r | |
622 | jnz inp2a ; if a null, try again\r | |
623 | lda strcnt ; if the string length is zero, dont wait.\r | |
624 | ana a\r | |
625 | jnz inp2 ; so loop back again\r | |
626 | jmp kermit ; else drop out\r | |
627 | \r | |
628 | inp2a: cpi cntlc ; do we want to abort?\r | |
629 | ;[MF]Change following line\r | |
630 | ; jz kermit ; in which case exit back to command loop\r | |
631 | jnz inp2b ;[MF] No\r | |
632 | lda takflg ;[MF] Yes, are we TAKEing\r | |
633 | ani 1 ;[MF] commands from a file?\r | |
634 | cnz closet ;[MF] Yes, close and reset to get\r | |
635 | ;[MF] commands from the command-line\r | |
636 | jmp kermit ;[MF] and exit back to command loop\r | |
637 | inp2b: cpi cntlz ; if control z exit back to command loop\r | |
638 | jz kermit ; else try for other characters [MF]\r | |
639 | jmp inp2\r | |
640 | \r | |
641 | inp4: mov e,a ; save it for a while\r | |
642 | lda repcnt ; see if this character matches with one in buffer\r | |
643 | lxi h,stbuff ; point to string buffer\r | |
644 | add l ; make hl = hl + a\r | |
645 | mov l,a\r | |
646 | mvi a,0 ; ie make hl = hl + character count\r | |
647 | adc h\r | |
648 | mov h,a ; not using xra, as that clears the Carry flag\r | |
649 | mov a,e ; get the character back again\r | |
650 | cmp m ; is it = to what we expect?\r | |
651 | jnz inp1 ; no, clear counter and try again\r | |
652 | lda repcnt ; yes, then update the pointer, and ...\r | |
653 | inr a ; ... see if we have received all ...\r | |
654 | sta repcnt ; ... we should have received\r | |
655 | lhld waitp1 ; get original counter\r | |
656 | shld waitp ; and reset the loop (timer) counter\r | |
657 | mov e,a ; save length into E again\r | |
658 | lda strcnt ; get the length to compare\r | |
659 | sub e ; if (e) > string length, we have it\r | |
660 | jnz inp2 ; else wait for a little longer\r | |
661 | \r | |
662 | xra a ; no errors\r | |
663 | sta errorc\r | |
664 | jmp kermit ; so say nothing\r | |
665 | ;else if error...\r | |
666 | \r | |
667 | inp5: lxi d,erms30 ; say message not receive in time...\r | |
668 | call prtstr\r | |
669 | jmp kermit ; have string, so exit\r | |
670 | \r | |
671 | ;\r | |
672 | ;\r | |
673 | \r | |
674 | ; This is the HELP command. It gives a list of the commands.\r | |
675 | \r | |
676 | help: call cfmcmd\r | |
677 | lxi d,tophlp ;The address of the help message.\r | |
678 | call p20ln ;Print at most 20 lines then pause\r | |
679 | ; call prtstr\r | |
680 | jmp kermit\r | |
681 | ;\f\r | |
682 | ; This is the LOG command. It logs a session to a file.\r | |
683 | \r | |
684 | log: mvi a,cmofi ;[pcc005] Parse an output file spec.\r | |
685 | lxi d,fcb ;[pcc012] where to put it\r | |
686 | call comnd\r | |
687 | jmp kermt3\r | |
688 | call cfmcmd\r | |
689 | lxi h,fcb ;[pcc012] copy file name and ext\r | |
690 | lxi d,lognam ;[pcc012] to a safe place\r | |
691 | lxi b,12 ;[pcc012] 12 bytes\r | |
692 | call mover ;[pcc012] zap ...\r | |
693 | mvi a,1 ;[pcc005] set flag for logging\r | |
694 | sta logflg ;[pcc005]\r | |
695 | jmp kermit ;[pcc005]\r | |
696 | \r | |
697 | ;\r | |
698 | ; PAUSE [Wait period]. Just wait for a couple of tics...\r | |
699 | pause: mvi a,cmnum ; get the number of the wait period\r | |
700 | call comnd ; get it\r | |
701 | jmp kermit ; we canna do it, so get next command\r | |
702 | lhld number\r | |
703 | xchg ; move to d\r | |
704 | lhld clkbit+1 ; get clock bits 8 to 23\r | |
705 | mov a,h ; strip ms bit so we have space for a possible carry\r | |
706 | ani 7fh\r | |
707 | mov h,a\r | |
708 | dad d ; add the number (ie get the number to wait to\r | |
709 | shld number ; save it somewhere\r | |
710 | ;\r | |
711 | ; Now, wait for time to be equal to newer NUMBER with Carry\r | |
712 | ploop: \r | |
713 | call clock ; increment clock\r | |
714 | lda takflg ; test if keyboard interrupt.. not for takes\r | |
715 | ana a\r | |
716 | jnz ploop1 ; do nothing for take command files\r | |
717 | mvi c,dconio ; get status from console\r | |
718 | mvi e,0ffh ; just get the character\r | |
719 | call bdos\r | |
720 | ana a ; if non zero return, then quit\r | |
721 | jnz kermit ; we got something, so quit\r | |
722 | ploop1: lhld number\r | |
723 | xchg\r | |
724 | lhld clkbit+1 ; get bits 8 to 23\r | |
725 | mov a,h\r | |
726 | ani 7fh ; make it 15 bits for a carry...\r | |
727 | mov h,a\r | |
728 | mov a,e ; now, do (DE with carry) - HL\r | |
729 | sub l\r | |
730 | mov e,a\r | |
731 | mov a,d\r | |
732 | sbb h\r | |
733 | ora e ; a = OR of result\r | |
734 | jnz ploop\r | |
735 | jmp kermit ; otherwise we are done.\r | |
736 | \r | |
737 | ; PRINT - Print a file to the console and printer. \r | |
738 | ; This command is active only from the command level, and not \r | |
739 | ; from the connect state. Unfortunately, the print command is \r | |
740 | ; not going to be a background utility.\r | |
741 | printf: mvi a,0ffh ; set the print flag on\r | |
742 | typent: sta prnfl ; Type file entry. Common for PRINT and TYPE\r | |
743 | call type ; and do the rest of the print via type\r | |
744 | xra a\r | |
745 | sta prnfl ; next clear the print flag\r | |
746 | jmp kermit\r | |
747 | \r | |
748 | ; TYPE - Type a file to the console.\r | |
749 | ; This command is really the same as the print command, but the output\r | |
750 | ; is not copied to the printer.\r | |
751 | typef: xra a ; we want to clear the printer on flag\r | |
752 | jmp typent ; go to the type entry in printfile above\r | |
753 | \r | |
754 | \r | |
755 | ;\f\r | |
756 | ; This is the TAKE command. It take input from a file.\r | |
757 | ; TAKE1 is the entry for automatically TAKE-ing KERMIT.INI (or whatever\r | |
758 | ; the file name at taknam is) from the default drive\r | |
759 | ; [18] code added to accept command tails. See note [18] above\r | |
760 | ;\r | |
761 | take: mvi a,cmifi ;[9] Get filename from user\r | |
762 | lxi d,takfcb ;[9] Take file fcb space\r | |
763 | call comnd ;[9] get the file spec\r | |
764 | jmp kermit ;[9] User failed to specify a good file spec\r | |
765 | call take2 ;[MF] Now TAKE the file\r | |
766 | jmp kermit ;[MF] Go back to main Kermit command loop\r | |
767 | ;\r | |
768 | take1: lxi b,12 ;[9] copy default drive and file name to take fcb\r | |
769 | lxi d,takfcb\r | |
770 | lxi h,taknam\r | |
771 | call mover ;[9] and do it (all other extents etc are zero)\r | |
772 | ;[MF][30]No longer need the following line\r | |
773 | ; jmp take2 ; got the file name, now take it.\r | |
774 | ;\r | |
775 | ;[9] get the file name, now lets open it \r | |
776 | ;\r | |
777 | take2:\r | |
778 | lda takflg ; check to see we have not tak-take\r | |
779 | ani 1 ; if set, we are in a take already\r | |
780 | ;[MF]We can do the following test/call more efficiently\r | |
781 | ; jz take21\r | |
782 | ; call closet ; so close current take file\r | |
783 | cnz closet ;[MF] So close current take file\r | |
784 | take21:\r | |
785 | mvi c,setdma\r | |
786 | lxi d,takdma ;[9] tell bdos where to send data\r | |
787 | call BDOS\r | |
788 | xra a ;[9] clear all these extents etc\r | |
789 | sta takfcb+14\r | |
790 | sta takfcb+32\r | |
791 | lxi d,takfcb ;[9] open the file\r | |
792 | mvi c,openf ;[9] open the file\r | |
793 | call BDOS\r | |
794 | inr a ;[9] if FF returned, problems\r | |
795 | ;[MF]Complain if failure and not seeking KERMIT.INI\r | |
796 | ; jz kermit ;[9] for now, say nowt if no ini file. Else..\r | |
797 | jz ntake ;[9] We'll say file not found\r | |
798 | ;[MF] unless the initial TAKE (KERMIT.INI)\r | |
799 | ; jmp take3 ; a test\r | |
800 | ; mvi c,readf ;[9] read first bytes from file\r | |
801 | ; lxi d,takfcb ;[9]\r | |
802 | ; call BDOS\r | |
803 | \r | |
804 | take3: lxi h,0\r | |
805 | shld takptr ;[9] point to first byte of take file\r | |
806 | lda takflg ; get current flag\r | |
807 | ori 1 ;[9] and set flag to tell Kermit we're taking\r | |
808 | sta takflg\r | |
809 | ;[MF][30]Redo next lines so can flag initial TAKE of KERMIT.INI\r | |
810 | ; call rnsect ;[9] read a sector\r | |
811 | ; jmp kermit ;(Should use a ret, but this will do)\r | |
812 | jmp rnsect ;[9] read a sector and return\r | |
813 | \r | |
814 | ntake: lda initak ;[MF]Is this the initial TAKE (KERMIT.INI)?\r | |
815 | ora a ;[MF]...\r | |
816 | rnz ;[MF]Yes, don't complain\r | |
817 | lxi d,erms15 ;[9] Say file not found\r | |
818 | call prtstr\r | |
819 | ;[MF][30]Make next line a "jmp" since we've called TAKE2\r | |
820 | ; call rstdma ;[9] reset the DMA addres for other files\r | |
821 | ; jmp kermit\r | |
822 | jmp rstdma ;[9] reset the DMA addres for other files\r | |
823 | ;[MF] and return\r | |
824 | \r | |
825 | \r | |
826 | ; Little code to allow some expansion of code without changing\r | |
827 | ; every futher address, only up to the end of this file.\r | |
828 | ; TO BE REMOVED FRO RELEASE!\r | |
829 | \r | |
830 | ; org ($+100h) AND 0FF00H\r | |
831 | \r | |
832 | IF lasm\r | |
833 | LINK CPSCOM\r | |
834 | ENDIF ;lasm\r |