4 ; KERMIT - (Celtic for "FREE")
6 ; This is the CP/M-80 implementation of the Columbia University
7 ; KERMIT file transfer protocol.
11 ; Copyright June 1981,1982,1983,1984,1985
14 ; Originally written by Bill Catchings of the Columbia University Center for
15 ; Computing Activities, 612 W. 115th St., New York, NY 10025.
17 ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,
18 ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many
21 ; CPXMRL.ASM created 16 July, 1987 from submitted code by William Rose.
23 ; Kermit system dependent file for Rair Black Box (British Telecom
24 ; Merlin, ICL PC etc) originally submitted by William Rose, and
25 ; modified by OBSchou to work with the Kermit-80 V4.08 and later
26 ; files. Wills original overlay file a stripped down CPXSYS.ASM
29 ; KERSYS.ASM - version 0.6A dated 17 Jun 87.
31 ; Cutdown CP4SYS.ASM for Telecom Merlin M2215 only. (ICL PC, Rair Black Box)
33 ; This uses TTY1: only, and cannot alter it's parameters. It resets the
34 ; interrupt flag to prevent use of the buffer, and is generally a kludge.
35 ; However it runs at 4800 baud, and tidying the code might get 9600.
37 ; Revision History (Last entry first)
39 ; edit 2, 22 July by OBSchou to massage frile to fit with CPXCOM.ASM
41 ; edit 1, 17 July by OBSchou for Will Rose, to make file suitable for V4.08
44 ; Keep module name, edit number, and last revision date in memory.
46 family: db 'CPXMRL.ASM (2) 22-Jun-87 $' ; Telecom Merlin added
49 ; Assembly time message to let me know I'm building the right version.
53 .printx * Assembling Kermit-80 for Merlin M2215 *
56 IF m2215 ;equates removed because interrupts stopped port access
57 ;iobase equ 14h ; base address of TTY1
58 ;mnport equ iobase ; rx and tx data ports
59 ;mnprts equ iobase+1 ; status port
60 ;mnmode equ iobase+2 ; mode port
61 ;mncmd equ iobase+3 ; PCI command port
62 ;txrdy equ 1 ; tx ready bit set if free
64 ;rxrdy equ 2 ; RX ready bit
66 z80 equ false ; For Merlin M2215
70 sysxin: ; Continue system initialisation fro sysinit
72 IF FALSE ; unable to penetrate the 8085 interrupts
73 in mncmd ; clear command register counter
74 mvi a,4eh ; 0100$1110 - 1 stop bit, 8 data bits,
77 mvi a,30h+7 ; 0011$0000 - select internal rate generator
78 ; use 1200 baud by default
80 mvi a,27h ; 0010$0111 - enable tx and rx, RTS and DTR low
84 shld speed ; to show its been set up
90 porbuf: ds 3 ; original port settings
93 ; system-dependent KERMIT termination processing
94 ; If we've changed anything, this is our last chance to put it back.
100 ; system-dependent processing for start of CONNECT command
105 conmsg: ; Messages printed when entering transparent (CONNECT) mode:
110 ; syscls - system-dependent close routine
111 ; called when exiting transparent session.
117 ; sysinh - help for system-dependent special functions.
118 ; called in response to <escape>?, after listing all the
119 ; system-independent escape sequences.
122 ; still can't pentrate interrupts
125 ; Additional, system-dependent help for transparent mode
126 ; (two-character escape sequences)
131 db cr, lf, 'B Transmit a BREAK'
134 db '$' ; string terminator
137 ; sysint - system dependent special functions
138 ; called when transparent escape character has been typed;
139 ; the second character of the sequence is in A (and in B).
141 ; non-skip: sequence has been processed
142 ; skip: seqence was not recognized
144 sysint: ani 137O ; convert lower case to upper, for testing...
147 cpi 'B' ; send break ?
150 jmp rskp ; take skip return - command not recognised
157 ani 04h ; make sure shift reg is clear
160 mvi a,2fh ; set for a break
162 mvi a,100 ; wait a bit
164 mvi a,27h ; restore mode
173 ; sysflt - system-dependent filter
174 ; called with character in E.
175 ; if this character should not be printed, return with A = zero.
176 ; preserves bc, de, hl.
177 ; note: <xon>,<xoff>,<del>, and <nul> are always discarded.
180 mov a,e ; get character for testing
184 ; mdmflt - modem filter
185 ; called with character to be sent to printer in E
186 ; with parity set as appropriate.
187 ; return with accumulator = 0 do do nothing,
188 ; <> 0 to send char in E.
190 mov a,e ; get character to test
194 ; prtflt - printer filter
195 ; called with character to be sent to printer in E
196 ; returns with a = 0 to do nothing
197 ; a <> 0 to print it.
199 ; this routine for those printer that automatically insert
200 ; a lf on cr, or cr for lf. Should this be shifted to
201 ; the system indep. stuff, in say 4.06?
204 mov a,e ; get character to test
206 IF FALSE ; strip out lf from printer stream
207 ani 7fh ; make sure it is parity less
208 cpi lf ; is it a line feed?
210 ; xra a ; yes, don't.
217 ; system-dependent processing for BYE command.
223 ; This is the system-dependent command to change the baud rate.
224 ; DE contains the two-byte value from the baud rate table; both
225 ; bytes of this value are also stored in 'speed'.
230 in mncmd ; clear register counter
231 mvi a,4eh ; set for 1 stop, 8 data bits
232 out mnmode ; save in mode 1 port
233 mvi a,30h ; set bits for rate etc..
234 add e ; add baud rate (bits 0 - 3)
235 out mnmode ; set mode port 2
236 mvi a,27h ; set tx/rx ready, RTS CTS active
240 ret ; if routine not supported
243 ; (Note that speed tables MUST be in alphabetical order for later
244 ; lookup procedures, and must begin with a value showing the total
245 ; number of entries. The speed help tables are just for us poor
248 ; db string length, string, divisor (2 bytes or 1 word, ab)
249 ; the data byte a is return in A and E, and b in D
250 ; only byte 'a' is the key for the table
253 spdtbl: db 16 ; sixteen entries for PCI
271 sphtbl: db ' 50 75 110 134 150 300 600 1200 '
272 db cr,lf,'1800 2000 2400 3600 4800 7200 9600 19200$'
276 spdtbl equ 0 ; routine unsupported
281 ; This is the system-dependent SET PORT command.
282 ; HL contains the argument from the command table.
287 prttbl equ 0 ; SET PORT is not supported
288 prhtbl equ 0 ; Merlin M2215 could, I suppose
292 ; selmdm - select modem port
293 ; selcon - select console port
294 ; selmdm is called before using inpmdm or outmdm;
295 ; selcon is called before using inpcon or outcon.
296 ; For iobyt systems, diddle the I/O byte to select console or comm port;
297 ; For the rest, does nothing.
298 ; preserves bc, de, hl.
307 ; Get character from console, or return zero.
308 ; result is returned in A. destroys bc, de, hl.
311 call 0f55dh ;CONST BIOS vector
314 call 0f56eh ;CONIN BIOS vector
318 ; Output character in E to the console.
319 ; destroys bc, de, hl
323 call 0f57fh ;CONOUT BIOS vector
327 ; outmdm - output a char from E to the modem.
328 ; the parity bit has been set as necessary.
329 ; returns nonskip; bc, de, hl preserved.
342 call 0f6a2h ;PUN BIOS vector
353 ; for IOBYT systems, the modem port has already been selected.
354 ; destroys bc, de, hl.
360 lda 0fa32h ; ie. tty1:
364 mvi a, 1 ; RDR BIOS vector
372 sta 0fa32h ; remove interrupt flag
373 sta 0f2d3h ; zero buffer counter
384 ; flsmdm - flush comm line.
386 ; Currently, just gets characters until none are available.
390 call inpmdm ; Try to get a character
392 jnz flsmdm ; If so, try for another
393 ret ; Receiver is drained. Return.
399 ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not.
402 call bprtst ; get status
406 xra a ; assume it is ok.. this may not be necessary
410 ; outlpt - output character in E to printer
411 ; console is selected.
415 push d ; save DE in either case
416 call prtflt ; go through printer filter [30]
417 ana a ; if A = 0 do nothing,
418 jz outlp1 ; if a=0 do nothing
420 outlp1: pop d ; restore saved register pair
423 ; delchr - make delete look like a backspace. Unless delete is a printing
424 ; character, we just need to print a backspace. (we'll output clrspc
428 mvi e,bs ;get a backspace
431 ; erase the character at the current cursor position
434 mvi e,bs ;get a backspace
437 ; erase the current line
441 ; erase the whole screen, and go home. preserves b (but not c)
447 sysver: db 'BT Merlin M2215, port TTY1:, settings unchanged.$'
450 tstmsg: db 'Test message',cr,lf,'$'
453 LINK CPXVDU.ASM ; link to the Terminal definition tables