home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols200 / vol220 / mxo-ox11.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-13  |  13.5 KB  |  454 lines

  1.        Title    'MEX overlay for Osborne Executive, version 1.1'
  2. ;
  3. ;
  4. ; (delete above title line if not assembling with MAC)
  5. ;
  6. ;
  7. REV    EQU    11        ;overlay revision level
  8. ;  
  9. ;  MEX Overlay for Osborne EXECUTIVE with external
  10. ;  modem connected to the MODEM port (port 0CH).
  11. ;
  12. ;  Incorporates a fully implemented SET BAUD function
  13. ;  using the MEX processor.  The initialization routine
  14. ;  has been modified to allow sending an initialization
  15. ;  string to the modem.  (The string is defined at the
  16. ;  end of this overlay.)  This is for the US Robotics 
  17. ;  Password modem.  (It sets dialing to tone mode,
  18. ;  turns on the echo mode, turns on the extended response
  19. ;  codes, and defeats the auto-answer function.)  It can
  20. ;  be eliminated or modified for appropriate use.  
  21. ;
  22. ;  If you exit to CPM without disconnecting, when you 
  23. ;  re-enter MEX, the program will skip the initialization
  24. ;  procedure (both port initialization and modem
  25. ;  initialization) and remind you to do a SET BAUD to the
  26. ;  rate in effect.  Although the rate has not been changed,
  27. ;  later functions may not operate properly.  You may cover
  28. ;  this in advance by entering the command on the command
  29. ;  line when re-calling MEX.  For example:
  30. ;       MEX SET BAUD 300; T 
  31. ;
  32. ;  Assembly notes:
  33. ;    This overlay incorporates a disconnect routine which
  34. ;    lowers DTR for 300 ms.  Accordingly, if you use the
  35. ;    Smartmodem overlay, set DISC to FALSE in MXO-SMxx.ASM.
  36. ;
  37. ;    If your modem does not require an initialization string,
  38. ;    you may replace the string at SMINIT by a single DB 0.  
  39. ;
  40. ;
  41. ;  Calling conventions for the various overlay entry points
  42. ;  are detailed more fully in the PMMI overlay (MXO-PMxx.ASM,
  43. ;  where xx=revision number).
  44. ;
  45. ;  History as a MEX overlay:
  46. ;
  47. ;  07/01/84    v1.1: Provided support for all MEX baud rates.
  48. ;        Made overlay clonable at any baud rate.
  49. ;        Included additional SET routines.
  50. ;
  51. ;  06/24/84    MEXified the overlay    - Bob Abrahams, Los Angeles, CA
  52. ;               Named MXO-OX10.ASM        CIS 72406,1355
  53. ;
  54. ;  History as a MDM overlay:
  55. ;
  56. ;  11/11/83    Renamed to M7OX-1.ASM        - Irv Hoff
  57. ;  07/27/83     Renamed to work with MDM712    - Irv Hoff
  58. ;     :            :                 :
  59. ;     :            :                 :
  60. ;  07/17/83     Combined George Peace Osborne version
  61. ;        with Roy Robinson Osborne version
  62. ;        then renamed MDM711OX.ASM    - Irv Hoff         
  63. ;
  64. ;------------------------------------------------------------
  65. ;
  66. ; Misc equates:
  67. ;
  68. NO    EQU    0
  69. YES    EQU    NOT NO
  70. TPA    EQU    100H
  71. CR    EQU    13
  72. LF    EQU    10
  73. TAB    EQU    9
  74. ESC    EQU    27
  75. BELL    EQU    7
  76. ;
  77. ; Osborne EXECUTIVE port definitions:
  78. ;
  79. PORT    EQU    0Ch        ;base port (data or status)
  80. MODCT1    EQU    PORT+1        ;modem control port
  81. MODDAT    EQU    PORT        ;modem data port
  82. BAUDRP    EQU    04h        ;modem baud rate port
  83. ;
  84. ; Osborne EXECUTIVE bit definitions:
  85. ;
  86. MDRCVB    EQU    01H        ;modem receive bit (DAV)
  87. MDRCVR    EQU    01H        ;modem receive ready
  88. MDSNDB    EQU    04H        ;modem send bit
  89. MDSNDR    EQU    04H        ;modem send ready bit
  90. ;
  91. ; MEX Service Processor codes:
  92. ;
  93. MEX    EQU    0D00H        ;address of the service processor
  94. INMDM    EQU    255        ;get char from port to A, CY=no more in 100 ms
  95. TIMER    EQU    254        ;delay 100ms * reg B
  96. TMDINP    EQU    253        ;B=# secs to wait for char, cy=no char
  97. CHEKCC    EQU    252        ;check for ^C from KBD, Z=present
  98. SNDRDY    EQU    251        ;test for modem-send ready
  99. RCVRDY    EQU    250        ;test for modem-receive ready
  100. SNDCHR    EQU    249        ;send a character to the modem (after sndrdy)
  101. RCVCHR    EQU    248        ;recv a char from modem (after rcvrdy)
  102. LOOKUP    EQU    247        ;table search: see CMDTBL comments for info
  103. PARSFN    EQU    246        ;parse filename from input stream
  104. BDPARS    EQU    245        ;parse baud-rate from input stream
  105. SBLANK    EQU    244        ;scan input stream to next non-blank
  106. EVALA    EQU    243        ;evaluate numeric from input stream
  107. LKAHED    EQU    242        ;get nxt char w/o removing from input
  108. GNC    EQU    241        ;get char from input, cy=1 if none
  109. ILP    EQU    240        ;inline print
  110. DECOUT    EQU    239        ;decimal output
  111. PRBAUD    EQU    238        ;print baud rate
  112. ;
  113. CONOUT    EQU    2        ;simulated BDOS function 2: console char out
  114. PRINT    EQU    9        ;simulated BDOS function 9: print string
  115. INBUF    EQU    10        ;input buffer, same structure as BDOS 10
  116. ;
  117. ;        -------------------------------------
  118. ;
  119. ;  From MEXPAT10 -- to establish <ESC> as terminal escape character
  120.       ORG    0D1Fh
  121. ESCCHR:      DB    ESC    ;Terminal mode escape character = <ESC>    
  122. ;
  123. ;        ------------------------------------
  124. ;
  125.     ORG    TPA        ;we begin
  126. ;
  127.     DS    3        ;MEX has a JMP START here
  128. ;
  129. ;
  130. PMODEM:    DB    NO        ;yes=PMMI modem \ / These 2 locations are not
  131. SMODEM:    DB    YES        ;yes=Smartmodem / \ referenced by MEX
  132. TPULSE:    DB    'T'        ;T=touch, P=pulse (not referenced by MEX)
  133. CLOCK:    DB    40        ;clock speed x .1, up to 25.5 mhz.
  134.                 ;4 MHz for Osborne Executive
  135. MSPEED:    DB    5        ;sets display time for sending a file
  136.                 ;0=110    1=300  2=450  3=600  4=710
  137.                 ;5=1200 6=2400 7=4800 8=9600 9=19200
  138. BYTDLY:    DB    3        ;default time to send character in
  139.                 ;terminal mode file transfer (0-9)
  140.                 ;0=0 delay, 1=10 ms, 5=50 ms, 9=90 ms
  141. CRDLY:    DB    8        ;end-of-line delay after CRLF in terminal
  142.                 ;mode file transfer for slow BBS systems
  143.                 ;0=0 delay, 1=100 ms, 5=500 ms, 9=900 ms
  144. COLUMS:    DB    5        ;number of directory columns
  145. SETFL:    DB    YES        ;yes=user-defined SET command
  146. SCRTST:    DB    YES        ;yes=if home cursor and clear screen
  147.                 ;routine at CLRSCRN
  148. ACKNAK:    DB    0        ;was once ACKNAK, now spare
  149. BAKFLG:    DB    NO        ;yes=make .BAK file
  150. CRCDFL:    DB    YES        ;yes=default to CRC checking
  151.                 ;no=default to Checksum checking
  152. TOGCRC:    DB    YES        ;yes=allow toggling of Checksum to CRC
  153. CVTBS:    DB    NO        ;yes=convert backspace to rub
  154. TOGLBK:    DB    YES        ;yes=allow toggling of bksp to rub
  155. ADDLF:    DB    NO        ;no=no LF after CR to send file in
  156.                 ;terminal mode (added by remote echo)
  157. TOGLF:    DB    YES        ;yes=allow toggling of LF after CR
  158. TRNLOG:    DB    NO        ;yes=allow transmission of logon
  159.                 ;write logon sequence at location LOGON
  160. SAVCCP:    DB    YES        ;yes=do not overwrite CCP
  161. LOCNXT:    DB    YES        ;yes=local cmd if EXTCHR precedes
  162.                 ;no=not local cmd if EXTCHR precedes
  163. TOGLOC:    DB    YES        ;yes=allow toggling of LOCNXTCHR
  164. LSTTST:    DB    YES        ;yes=allow toggling of printer on/off
  165.                 ;in terminal mode. Set to no if using
  166.                 ;the printer port for the modem
  167. XOFTST:    DB    NO        ;yes=allow testing of XOFF from remote
  168.                 ;while sending a file in terminal mode
  169. XONWT:    DB    NO        ;yes=wait for XON after sending CR while
  170.                 ;transmitting a file in terminal mode    
  171. TOGXOF:    DB    YES        ;yes=allow toggling of XOFF testing
  172. IGNCTL:    DB    YES        ;yes=do not send control characters
  173.                 ;above CTL-M to CRT in terminal mode
  174.                 ;no=send any incoming CTL-char to CRT
  175. EXTRA1:    DB    0        ;for future expansion
  176. EXTRA2:    DB    0        ;for future expansion
  177. BRKCHR:    DB    'B'-40H        ;^@ = Send a 300 ms. break tone
  178. NOCONN:    DB    'N'-40H        ;^N = Disconnect from phone line
  179. LOGCHR:    DB    'I'-40H        ;^L = Send logon
  180. LSTCHR:    DB    'P'-40H        ;^P = Toggle printer
  181. UNSVCH:    DB    'R'-40H        ;^R = Close input text buffer
  182. TRNCHR:    DB    'T'-40H        ;^T = Transmit file to remote
  183. SAVCHR:    DB    'Y'-40H        ;^Y = Open input text buffer
  184. EXTCHR:    DB    '\'-40H        ;^\ = Send next character
  185. ;
  186.     DS    2        ;not used
  187. ;
  188. ; Low-level modem I/O routines.
  189. ;
  190. INCTL1:    MVI    A,10H
  191.     OUT    MODCT1
  192.     IN    MODCT1        ;in modem control port
  193.     RET
  194.     DB    0,0,0        ;spares, if needed (10 bytes total)
  195. ;
  196. OTDATA:    OUT    MODDAT        ;out modem data port
  197.     RET
  198.     DB    0,0,0,0,0,0,0    ;spares, if needed (10 bytes total)
  199. ;
  200. INPORT:    IN    MODDAT        ;in modem data port
  201.     RET
  202.     DB    0,0,0,0,0,0,0    ;spares, if needed (10 bytes total)
  203. ;
  204. ; Bit-test routines. 
  205. ;
  206. MASKR:    ANI MDRCVB ! RET    ;bit to test for receive ready
  207. TESTR:    CPI MDRCVR ! RET    ;value of receive bit when ready
  208. MASKS:    ANI MDSNDB ! RET    ;bit to test for send ready
  209. TESTS:    CPI MDSNDR ! RET    ;value of send bit when ready
  210. ;
  211.     DS    12
  212. ;
  213. ;
  214. LOGON:    DS    2        ;needed for MDM compat, not ref'd by MEX
  215. DIALV:    DS    3
  216. DISCV:    JMP    DISCON
  217. GOODBV:    JMP    GOODBYE        ;called before exit to CP/M
  218. INMODV:    JMP    NITMOD        ;initialization. Called at cold-start
  219. NEWBDV:    JMP    PBAUD        ;set baud rate
  220. NOPARV:    DS    3        ;set modem for no-parity
  221. PARITV:    DS    3        ;set modem parity
  222. SETUPV:    JMP    SETCMD        ;SET cmd: jump to a RET if you don't write SET
  223. SPMENV:    DS    3        ;not used with MEX
  224. VERSNV:    JMP    SYSVER        ;Overlay's voice in the sign-on message
  225. BREAKV:    JMP    SBREAK        ;send a break
  226. ;
  227. ; The following jump vector provides the overlay with access to special
  228. ; routines in the main program (retained and supported in the main pro-
  229. ; gram for MDM overlay compatibility). These should not be modified by
  230. ; the overlay.
  231. ;
  232. ; Note that for MEX 2.0 compatibility, you should not try to use these
  233. ; routines, since this table will go away with MEX 2.0 (use the MEX
  234. ; service call processor instead).
  235. ;
  236. ILPRTV:    DS    3        ;replace with MEX function 240
  237. INBUFV:    DS    3        ;replace with MEX function 10
  238. ILCMPV:    DS    3        ;replace with table lookup funct. 247
  239. INMDMV:    DS    3        ;replace with MEX function 255
  240. NXSCRV:    DS    3        ;not supported by MEX (returns w/no action)
  241. TIMERV:    DS    3        ;replace with MEX function 254
  242. ;
  243. CLREOS:    CALL    ILPRT
  244.     DB    ESC,'Y',0
  245.     RET
  246.     DB    0,0
  247. ;
  248. CLS:    CALL    ILPRT
  249.     DB    ESC,'Z',0
  250.     RET
  251.     DB    0,0
  252. ;
  253. ;
  254. ; end of fixed area
  255. ;
  256. ILPRT:      MVI    C,ILP        ;MEX In-line print
  257.       JMP    MEX
  258. ;
  259. SYSVER:      CALL    ILPRT
  260.       DB    'For Osborne Executive MODEM port, ver. '
  261.       DB    REV/10+'0'
  262.       DB    '.'
  263.       DB    REV MOD 10+'0'
  264.       DB    CR,LF,0
  265.       RET
  266. ;
  267. ; This routine allows a 300 ms. break tone to be sent to reset some
  268. ; time-share computers.
  269. ;
  270. SBREAK:   MVI    A,5
  271.       OUT    MODCT1
  272.       MVI    A,0F8H        ;SEND A BREAK TONE        
  273.       JMP    GOODBYE1
  274. ;.....
  275. ;
  276. ;
  277. ; This routine sends a 300 ms. break tone and sets DTR low for the same
  278. ; length of time to disconnect some modems such as the Bell 212A, etc.
  279. ;
  280. DISCON:   MVI    A,5
  281.       OUT    MODCT1        ;SEND TO THE STATUS PORT
  282.       MVI    A,68H        ;TURN OFF DTR
  283. ;
  284. GOODBYE1: OUT    MODCT1
  285.       MVI    B,3        ;DELAY 300 MS.
  286.       MVI    C,TIMER
  287.       CALL    MEX
  288. GOODBYE:  MVI    A,5
  289.       OUT    MODCT1
  290.       MVI    A,0E8H        ;RESTORE TO NORMAL, 8 BITS, DTR ON, ETC.
  291.       OUT    MODCT1
  292.       RET
  293. ;.....
  294. ;
  295. ;
  296. ; Osborne EXECUTIVE RS232 initialization -- 
  297. ;  Checks to see if a call is in progress (carrier on).  If so,
  298. ;  it sends a warning message.  Otherwise it sets the CTC timer
  299. ;  04h for send and receive baudrate and sends the modem
  300. ;  initialization string.
  301. ;
  302. ;
  303. NITMOD:
  304. ;
  305.     CALL    INCTL1        ;GET SIO STATUS
  306.     ANI    08H        ;SEE IF CARRIER IS PRESENT
  307.     JZ    NODCD        ;IF NOT, DO NORMAL INITIALIZE
  308.     CALL    ILPRT        ;IF SO, ISSUE SPECIAL MESSAGE INSTEAD
  309.     DB    CR,LF
  310.     DB    '++ Call in progress --',CR,LF
  311.     DB    '   SET BAUD to rate in effect for this call. ++'
  312.     DB    BELL,CR,LF,LF,0
  313.     RET
  314. ;
  315. NODCD:
  316.       MVI    A,00H        ;SELECT REG.
  317.       OUT    MODCT1
  318.       MVI    A,18H        ;THROW OUT OF MODE
  319.       OUT    MODCT1
  320.       MVI    A,04H        ;SELECT REG.
  321.       OUT    MODCT1
  322.       MVI    A,44H        ;SET ASCII PARAMETERS
  323.       OUT    MODCT1
  324.       MVI    A,03H        ;SELECT REG.
  325.       OUT    MODCT1
  326.       MVI    A,0C1H        ;ENABLE RECEIVE
  327.       OUT    MODCT1
  328.       MVI    A,05H        ;SELECT REG.
  329.       OUT    MODCT1
  330.       MVI    A,0EAH        ;ENABLE SEND, DTR, RTS
  331.       OUT    MODCT1
  332.       LDA    MSPEED        ;GET INITIAL BAUD RATE
  333.       CALL  PBAUD        ;SET UP INITIAL RATE
  334. ;
  335.       LXI    H,SMINIT    ;MODEM INITIALIZATION STRING
  336.       CALL    SMSEND        ;SEND TO MODEM
  337. SMTLP:      MVI    B,1
  338.       MVI    C,TMDINP    ;EAT ANY RESPONSE CHARACTERS
  339.       CALL  MEX
  340.       JNC    SMTLP        ;UNTIL 100 MS OF QUIET TIME
  341.       RET
  342. ;
  343. SMSEND:      MVI    C,SNDRDY    ;WAIT FOR MODEM READY
  344.       CALL    MEX
  345.       JNZ    SMSEND
  346.       MOV    A,M        ;FETCH NEXT CHARACTER
  347.       INX    H
  348.       ORA    A        ;END?
  349.       RZ            ;DONE IF SO
  350.       MOV    B,A        ;NO, POSITION FOR SENDING
  351.       MVI    C,SNDCHR    ;NOPE, SEND THE CHARACTER
  352.       CALL    MEX
  353.       JMP    SMSEND
  354. ;
  355. ; Sets the modem speed via the SET command.
  356. ;
  357. SETCMD:      MVI    C,SBLANK    ;ANY ARGUMENTS?
  358.       CALL  MEX
  359.       JC    BDSHOW        ;IF NOT, DISPLAY BAUD RATE
  360.       MVI    C,LKAHED    ;LOOK AT NEXT CHARACTER
  361.       CALL    MEX        ;TO SEE IF DIGIT 1-9
  362.       CPI    '1'        ;IS IT TOO SMALL?
  363.       JC    NOTNUM
  364.       CPI    '9'+1        ;IS IT TOO BIG?
  365.       JC    STBAUD
  366. NOTNUM:      LXI    D,CMDTBL
  367.       MVI    C,LOOKUP
  368.       CALL  MEX        ;PARSE THE ARGUMENT
  369.       PUSH    H        ;SAVE ANY PARSED ARGUMENTS ON STACK
  370.       RNC            ;IF WE HAVE ONE, RETURN TO IT
  371.       POP    H        ;OOPS, INPUT NOT FOUND IN TABLE
  372. SETERR:      CALL    ILPRT    
  373.       DB    CR,LF,'++ SET command error ++',BELL,CR,LF,LF,0
  374.       RET
  375. ;
  376. ; Argument table
  377. ;
  378. CMDTBL:      DB    '?'+80H        ;HELP
  379.       DW    STHELP
  380.       DB    'BAU','D'+80H    ;"SET BAUD"
  381.       DW    STBAUD
  382.       DB    'INI','T'+80H    ;"SET INIT"
  383.       DW    NITMOD
  384.       DB    0        ;TABLE TERMINATOR
  385. ;
  386. ; "SET ?" processor
  387. ;
  388. STHELP:      CALL  ILPRT
  389.       DB    CR,LF,'SET <rate> or SET BAUD <rate>'
  390.       DB    CR,LF,'  <rate> is one of:'
  391.       DB    '  110 300 450 600 710 1200 2400 4800 9600 19200'
  392.       DB    CR,LF,LF,0
  393.       RET
  394. ;
  395. ; "SET BAUD" processor
  396. ;
  397. STBAUD:      MVI    C,BDPARS    ;FUNCTION CODE: PARSE A BAUDRATE
  398.       CALL    MEX        ;LET MEX LOOK UP CODE
  399.       JC    SETERR        ;JUMP IF INVALID CODE
  400.       CALL    PBAUD        ;NO, TRY TO SET IT
  401.       JC    SETERR        ;IF NOT ONE OF OURS, BOMB OUT
  402. BDSHOW:      CALL    ILPRT        ;DISPLAY BAUD
  403.       DB    'Baud: ',0
  404.       LDA    MSPEED        ;GET CURRENT BAUD RATE
  405.       MVI    C,PRBAUD    ;LET MEX PRINT IT
  406.       CALL    MEX
  407.       CALL    ILPRT        ;CR,LF
  408.       DB    CR,LF,0
  409.       RET 
  410. ;
  411. ; This routine sets baud rate passed as MSPEED code in A.
  412. ; Returns CY=1 if baud rate not supported (if supported,
  413. ; this routine must set the new MSPEED code).
  414. ;
  415. PBAUD:      PUSH    H        ;DON'T ALTER ANYBODY
  416.       PUSH    D
  417.       PUSH     B
  418.       STA    MSPEED        ;ALL RATES SUPPORTED
  419.       ADD    A        ;DOUBLE IT
  420.       MOV    E,A        ;MSPEED CODE TO DE
  421.       MVI    D,0
  422.       LXI    H,BAUDTB    ;OFFSET INTO TABLE
  423.       DAD    D
  424.       MOV    A,M        ;FETCH LSB CODE
  425.       OUT    BAUDRP        ;SEND IT
  426.       INX    H        ;SECOND BYTE
  427.       MOV    A,M        ;FETCH MSB CODE
  428.       OUT    BAUDRP        ;SEND IT
  429.  
  430.       ORA    A        ;RETURN NO ERRORS
  431. PBEXIT:      POP    B
  432.       POP    D
  433.       POP    H
  434.       RET
  435. ;
  436. BAUDTB:            ;TABLE OF VALUES TO SEND TO 8253 TIMER
  437.             ;SEND LSB, THEN MSB (NOTE:  PSEUDO-OP DW
  438.             ;STORES LSB THEN MSB, SO SEQUENCE IS CORRECT.)
  439.       DW    0417H        ;110
  440.       DW    0180H        ;300
  441.       DW    0100H        ;450
  442.       DW    00C0H        ;600    
  443.       DW    00A2H        ;710
  444.       DW    0060H        ;1200
  445.       DW    0030H        ;2400
  446.       DW    0018H        ;4800
  447.       DW    000CH        ;9600
  448.       DW    0006H        ;19200
  449. ;
  450. ;
  451. SMINIT:   DB    'ATTE1X1S0=0',CR,0    ;MODEM INITIALIZE STRING
  452. ;
  453.       END
  454.