home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / a / cpxgni.asm < prev    next >
Assembly Source File  |  2020-01-01  |  13KB  |  441 lines

  1. ; CPXGNI.ASM
  2. ;       KERMIT - (Celtic for "FREE")
  3. ;
  4. ;       This is the CP/M-80 implementation of the Columbia University
  5. ;       KERMIT file transfer protocol.
  6. ;
  7. ;       Version 4.0
  8. ;
  9. ;       Copyright June 1981,1982,1983,1984,1985
  10. ;       Columbia University
  11. ;
  12. ; Originally written by Bill Catchings of the Columbia University Center for
  13. ; Computing Activities, 612 W. 115th St., New York, NY 10025.
  14. ;
  15. ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,
  16. ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many
  17. ; others.
  18. ;
  19. ;       This file contains the system-dependent code and data for various
  20. ;       Genie 3  CPM kermit 
  21. ;
  22. ; This has the Family name of CPXGNI.ASM.
  23. ;
  24. ; revision history (last edit first)
  25. ; edit 3: 27 October, a987 by OBSchou.  Massaged file to suit V4.09 structure.
  26. ;
  27. ; Edit 2: Aug 27 1987 GDS Put in code for BREAK and fillited out
  28. ;         a lot of unnecessary IF's
  29. ;
  30. ;Edit 1: Nov. 28, 1986 Geof Smith Clinical Research centre Harrow UK.
  31.  
  32. .printx * Assembling for Eaca Genie 3 *
  33. ;
  34. drtime  EQU     05H     ;Default receive time out interval.
  35. ;
  36. ; the basics...
  37. ;
  38. mnport EQU 0E8H
  39. mnprts EQU 0EDH
  40. output EQU 20H
  41. input  EQU 01H
  42. lctrl  EQU 0EBH
  43. divlsb EQU 0E8H
  44. divmsb EQU 0E9H
  45. z80    EQU TRUE
  46. brkval EQU 40H
  47.  
  48. defesc EQU ']'-100O ;The default escape character.
  49.  
  50.  
  51. ;Select initial setting for VT-52 emulation flag.
  52.  
  53. ; default to VT52-EMULATION ON.
  54. ;
  55. vtval   EQU     1
  56. ;
  57. ;
  58.  
  59. ;    Family is the string used in VERSION to say which of several 
  60. ;       smaller overlay files are used.  These are (will be) derived from 
  61. ;       the huge CP4SYS.ASM file, in which case we will never get here.  
  62. ;       Just a Dollar, but put a sting in for a family of machines.
  63. ;
  64. family:db      'CPXGNI.ASM  (3)  27-Oct-87$'    ; Used for family versions....
  65.  
  66.  
  67.  
  68. ;
  69. ;       System-dependent initialization
  70. ;       Called once at program start.
  71. sysxin:
  72. ;
  73.             ;Set up 9600 bd, 8bit words, no parity 1stop bit
  74.  
  75.     mvi    a,83H        ;enable DLAB by setting bit 7
  76.     out    lctrl       ;and outputting to control port
  77.     mvi    a,14H        ;get word = 20 decimal
  78.     out    divlsb        ;and put it out
  79.     mvi    a,00H        ;as two separate
  80.     out    divmsb        ;bytes
  81.     lda    pstore        ;get parity etc
  82.     out    lctrl        ;do it resetting DLAB at same time
  83.  
  84.     ret            ; return from system-dependent routine
  85.  
  86.  
  87. ;
  88. ;       system-dependent termination processing
  89. ;       If we've changed anything, this is our last chance to put it back.
  90. sysexit:
  91.  
  92.         ret
  93.  
  94. ;
  95. ;       system-dependent processing for start of CONNECT command
  96. ;
  97. syscon:
  98.         ret
  99.  
  100. conmsg:         ; Messages printed when entering transparent (CONNECT) mode:
  101. ;
  102.  
  103.  
  104. ;
  105. ;       syscls - system-dependent close routine
  106. ;       called when exiting transparent session.
  107. ;
  108. syscls:
  109.        ret
  110. ;
  111.  
  112.  
  113. ;
  114. ;       sysinh - help for system-dependent special functions.
  115. ;       called in response to <escape>?, after listing all the
  116. ;       system-independent escape sequences.
  117. ;
  118. sysinh:
  119.         lxi     d,inhlps        ; we got options...
  120.         call    prtstr          ; print them.
  121.         ret
  122.  
  123.  
  124. ;additional, system-dependent help for transparent mode
  125. ; (two-character escape sequences)
  126. inhlps:
  127.  
  128.         db      cr,lf,'B  Transmit a BREAK'
  129.  
  130.         db      '$'                     ;[hh] table terminator
  131.  
  132. ;
  133. ;       sysint - system dependent special functions
  134. ;       called when transparent escape character has been typed;
  135. ;       the second character of the sequence is in A (and in B).
  136. ;       returns:
  137. ;       non-skip: sequence has been processed
  138. ;       skip:   sequence was not recognized
  139. sysint: ani     137O            ; convert lower case to upper, for testing...
  140.         cpi     'B'             ; send break?
  141.         jz      sendbr          ; yes, go do it.  return nonskip when through.
  142.  
  143.         jmp     rskp            ; take skip return - command not recognized.
  144.  
  145.  
  146. ;-------------------------------------------------------------------------------
  147. sendbr:
  148. ;
  149. ;       Ensure that the transmitter has finished sending buffered chars
  150. sndbr1: in      mnprts          ; get UART status
  151.         ani     output         ; everything sent?
  152.         jz      sndbr1          ; no, wait a bit more
  153. ;
  154. ;       Begin sending a break by setting bit in UART command register
  155.         mvi     a,brkval           ;  SBreak, 
  156.         out     lctrl
  157. ;
  158. ;       Wait for 250 milliseconds (using hundredths second delay routine)
  159.         mvi     a,25
  160.         call    delay
  161. ;
  162. ;       Resume normal operation by clearing the SendBreak command bit
  163.         lda pstore                  ;and restoring value from parity store
  164.         out mnprts
  165. ;
  166.         ret                     ;done
  167.  
  168. ;
  169. ;
  170.  
  171. ;
  172. ;       sysflt - system-dependent filter
  173. ;       called with character in E.
  174. ;       if this character should not be printed, return with A = zero.
  175. ;       preserves bc, de, hl.
  176. ;       note: <xon>,<xoff>,<del>, and <nul> are always discarded.
  177. sysflt:
  178.         mov     a,e             ; get character for testing
  179.         ret
  180.  
  181. ;       mdmflt - modem filter [30]
  182. ;       called with character to be sent to modem in E
  183. ;       with parity set as appropriate.
  184. ;       return with accumulator = 0 do do nothing,
  185. ;                               <> 0 to send char in E.
  186. mdmflt:    mov    a,e        ; get character to a
  187.         ret
  188.  
  189.  
  190.  
  191. ;       prtflt - printer filter [30]
  192. ;       called with character to be sent to printer in E
  193. ;       returns with a = 0 to do nothing
  194. ;                    a <> 0 to print it.
  195. ;
  196. ;       this routine for those printer that automatically insert
  197. ;       a lf on cr, or cr for lf.  Should this be shifted to 
  198. ;       the system indep. stuff, in say 4.06?
  199. prtflt:
  200.         mov     a,e             ; [30] get character to test
  201.         ret
  202.  
  203.  
  204. ;
  205.  
  206.  
  207. ;
  208. ; system-dependent processing for BYE command.
  209. ;  for apmmdm, heath, and lobo, hang up the phone.
  210. sysbye:
  211.         ret
  212. ;
  213.  
  214.  
  215. ;       This is the system-dependent command to change the baud rate.
  216. ;       DE contains the two-byte value from the baud rate table; this
  217. ;       value is also stored in 'speed'.
  218. sysspd:
  219.  
  220.             ;Set up baud rate 8bit words, no parity 1stop bit
  221.      mvi a,83H     ;enable DLAB by setting bit 7
  222.      out lctrl     ;and outputting to control port
  223.      mov a,d         ;get LSB
  224.      out divlsb     ;and put it out
  225.      mov a,e       ;get MSB
  226.      out divmsb     ;output it as well
  227.      lda pstore     ;get parity etc
  228.      out lctrl     ;do it resetting DLAB at same time
  229.      ret
  230.  
  231. pstore:     db 03H  ;Default value for parity word length and stop bits
  232.  
  233. spdtbl: db    11h               ;17 entries
  234.      db     03h,'110$',     06H,0D1H
  235.      db     04h,'1200$',     00H,0A0H
  236.      db     05h,'134.5$',     05H,94H
  237.      db     03h,'150$',     05H,00H
  238.      db     04h,'1800$',     00H,6BH
  239.      db     05h,'19200$',     00H,0AH
  240.      db     04h,'2000$',     00H,60H
  241.      db     04h,'2400$',     00H,50H
  242.      db     03h,'300$',     02H,80H
  243.      db     04h,'3600$',     00H,35H
  244.      db     05h,'38400$',    00H,05H
  245.      db     04h,'4800$',     00H,28H
  246.      db     02h,'50$',     0FH,00H
  247.      db     03h,'600$',     01H,40H
  248.      db     04h,'7200$',     00H,1BH
  249.      db     02h,'75$',     0AH,00H
  250.      db     04h,'9600$',     00H,14H
  251.  
  252. sphtbl: db     cr,lf,'   50      75    110    134.5  150    300    600   1200'
  253.      db     cr,lf,' 1800   2000   2400   3600   4800   7200   9600  19200  38400$'
  254.  
  255. ;       This is the system-dependent SET PORT command.
  256. ;       HL contains the argument from the command table.
  257. sysprt:
  258.  
  259.         ret
  260. ;
  261. prttbl  equ     0               ; SET PORT not supported
  262. prhtbl  equ     0
  263.  
  264. ;
  265.  
  266. ;
  267. ;       selmdm - select modem port
  268. ;       selcon - select console port
  269. ;       selmdm is called before using inpmdm or outmdm;
  270. ;       selcon is called before using inpcon or outcon.
  271. ;       For iobyt systems, diddle the I/O byte to select console or comm port;
  272. ;       For Decision I, switches Multi I/O board to console or modem serial
  273. ;       port.  [Toad Hall]
  274. ;       For the rest, does nothing.
  275. ;       preserves bc, de, hl.
  276. selmdm:
  277.         ret
  278.  
  279. selcon:
  280.         ret
  281. ;
  282.  
  283.  
  284. ;       Get character from console, or return zero.
  285. ;       result is returned in A.  destroys bc, de, hl.
  286. ;
  287. inpcon:
  288.         mvi     c,dconio        ;Direct console I/O BDOS call.
  289.         mvi     e,0FFH          ;Input.
  290.         call    BDOS
  291.  
  292.         ret
  293. ;
  294. ;       Output character in E to the console.
  295. ;       destroys bc, de, hl
  296. ;
  297. outcon:
  298.  
  299.         mvi     c,dconio        ;Console output bdos call.
  300.         call    bdos            ;Output the char to the console.
  301.  
  302.         ret
  303. ;
  304. ;
  305. ;       outmdm - output a char from E to the modem.
  306. ;               the parity bit has been set as necessary.
  307. ;       returns nonskip; bc, de, hl preserved.
  308. outmdm:
  309.  
  310.         in      mnprts          ;Get the output done flag.
  311.         ani     output          ;Is it set?
  312.         jz      outmdm          ;If not, loop until it is.
  313.         mov     a,e
  314.         out     mnport          ;Output it.
  315.         ret
  316.  
  317. ;--------------------------------------------------------------------------
  318. ;
  319. ;       get character from modem; return zero if none available.
  320. ;       for IOBYT systems, the modem port has already been selected.
  321. ;       destroys bc, de, hl.
  322. inpmdm:
  323. ;Note: modem port should already be selected for mdI.  [Toad Hall]
  324.         in      mnprts          ;Get the port status into A.
  325.         ani     input           ;See if the input ready bit is on.
  326.         rz                      ;If not then return.
  327.         in      mnport          ;If so, get the char.
  328.         ret                     ; return with character in A
  329.  
  330.  
  331. ;
  332. ;       flsmdm - flush comm line.
  333. ;       Modem is selected.
  334. ;       Currently, just gets characters until none are available.
  335.  
  336. flsmdm: call    inpmdm          ; Try to get a character
  337.         ora     a               ; Got one?
  338.         jnz     flsmdm          ; If so, try for another
  339.         ret                     ; Receiver is drained.  Return.
  340. ;-----------------------------------------------------------------------------
  341. ;
  342. ;       lptstat - get the printer status. Return a=0 if ok, or 0ffh if not.
  343. lptstat:
  344.         xra     a               ; assume it is ok.. this may not be necessary
  345.         ret
  346.  
  347. ;
  348. ;       outlpt - output character in E to printer
  349. ;       console is selected.
  350. ;       preserves de.
  351. outlpt:
  352.         push    d               ; save DE in either case
  353.         call    prtflt          ; go through printer filter [30]
  354.         ana     a               ; if A = 0 do nothing,
  355.         jz      outlp1          ; [30] if a=0 do nothing
  356.  
  357.         mvi     c,lstout
  358.         call    bdos            ;Char to printer
  359. outlp1: pop     d               ; restore saved register pair
  360.         ret
  361. ;------------------------------------------------------------------------------
  362. ;
  363. ;       Screen manipulation routines
  364. ;       csrpos - move to row B, column C
  365. ;
  366. ;       csrpos for terminals that use a leadin sequence followed
  367. ;        by (row + 31.) and (column + 31.)
  368. ;
  369. csrpos: push    b               ; save coordinates
  370.         lxi     d,curldn        ; get cursor leadin sequence
  371.         call    prtstr          ; print it
  372.         pop     h               ; restore coordinates
  373.         mov     a,h             ; get row
  374.         adi     (' '-1)         ; space is row one
  375.         mov     e,a
  376.         push    h
  377.         call    outcon          ; output row
  378.         pop     h
  379.         mov     a,l             ; get column
  380.         adi     (' '-1)         ; space is column one
  381.         mov     e,a
  382.         jmp     outcon          ; output it and return
  383.  
  384. ;
  385. ; delchr - make delete look like a backspace.  Unless delete is a printing
  386. ;       character, we just need to print a backspace. (we'll output clrspc
  387. ;       afterwards)
  388. ;       For Kaypro and Vector General, delete puts a blotch on the screen.
  389. ;       For Apple and Osborne 1, delete moves but doesn't print.
  390. delchr:
  391.  
  392.         mvi     e,bs            ;get a backspace
  393.         jmp     outcon
  394.  
  395. ; erase the character at the current cursor position
  396. clrspc: mvi     e,' '
  397.         call    outcon
  398.         mvi     e,bs            ;get a backspace
  399.         jmp     outcon
  400.  
  401. ; erase the current line
  402. clrlin: lxi     d,eralin
  403.         jmp     prtstr
  404.  
  405. ; erase the whole screen, and go home. preserves b (but not c)
  406. clrtop: lxi     d,erascr
  407.         jmp     prtstr
  408.  
  409. ;[2] I see no real saving in having all screens in separate file and
  410. ;therefore have included screen definition here and commented out
  411. ;the link to VDU file
  412. ;
  413. ;Specific definitions for the Genie III screen
  414. ;
  415. sysver: db 'Eaca Genie III$'
  416. outlin: db 1aH,cr,lf,'            $'
  417. erascr: db 1AH,'$'
  418. eralin: db cr,18H,'$'
  419. curldn: db esc,'=$'
  420. ttab:
  421. ta:     db 0BH,'$',0,0                    ;Cursor up
  422. tb:     db 0AH,'$',0,0                    ;Cursor down
  423. tc:     db 0CH,'$',0,0                    ;Cursor right
  424. td:     db 08H,'$',0,0                    ;Cursor left
  425. te:     db 1AH,'$',0,0                    ;Clear display
  426. tf:     db esc,'R$',0                    ;Reverse on
  427. tg:     db esc,'S$',0                    ;Reverse off
  428. th:     db 1EH,'$',0,0                    ;Cursor home
  429. ti:     db 0BH,'$',0,0                    ;Reverse linefeed
  430. tj:     db 19H,'$',0,0                    ;Clear to end of screen
  431. tk:     db 18H,'$',0,0                    ;Clear to end of line
  432.  
  433. ovlend equ $           ;End of overlay
  434.  
  435. END
  436. 
  437. 
  438. 
  439. 
  440.  
  441.