home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / mex / mxo-ne88.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-13  |  19.5 KB  |  740 lines

  1. ;    Title    'MEX overlay for the NEC PC-8801 version 1.0'
  2. ;
  3. ;
  4. ; (delete above title line if not assembling with MAC)
  5. ;
  6. ;
  7. REV    EQU    10        ;overlay revision level
  8. ;
  9. ; MEX NEC PC-8801 OVERLAY VERSION 1.0: written 06/24/84 by Bob Schultz
  10. ;
  11. ;   based on MXO-PM10.ASM  by Ron Fowler
  12. ;
  13. ;------------------------------------------------------------
  14. ;
  15. ; Misc equates
  16. ;
  17. NO    EQU    0
  18. YES    EQU    0FFH
  19. TPA    EQU    100H
  20. CR    EQU    13
  21. LF    EQU    10
  22. TAB    EQU    9
  23. BS    EQU    8
  24. ESC    EQU    1BH
  25. CLRSCR    EQU    1AH
  26. ;
  27. ; Equates for the 8251 mode register
  28. ;
  29. BAUDMSK    EQU    3        ;mask to get baud rate bits
  30. BIT5    EQU    00H        ;5 bits
  31. BIT6    EQU    04H        ;6 bits
  32. BIT7    EQU    08H        ;7 bits
  33. BIT8    EQU    0CH        ;8 bits
  34. BITMSK    EQU    0CH        ;mask to get character length
  35. PARE    EQU    30H        ;even parity
  36. PARO    EQU    10H        ;odd parity
  37. PARN1    EQU    00H        ;no parity
  38. PARN2    EQU    20H        ;another code for no parity
  39. PARMSK    EQU    30H        ;mask to get parity bits
  40. STP1    EQU    40H        ;1 stop bit
  41. STP15    EQU    80H        ;1.5 stop bits
  42. STP2    EQU    0C0H        ;2 stop bits
  43. STPMSK    EQU    0C0H        ;mask to get stop bits
  44. ;
  45. ; Equates for the 8251 command register
  46. ;
  47. RTSBIT    EQU    20H        ;bit to turn RTS ON
  48. BRKBIT    EQU    08H        ;bit to send break
  49. DTRBIT    EQU    02H        ;bit to turn on DTR
  50. CMND    EQU    37H        ;RTS, error reset, Rx enable, DTR, Tx enable
  51. MODRST    EQU    40H        ;reset the 8251
  52. ;
  53. ; 8251 port and bit definitions
  54. ;
  55. PORT    EQU    20H
  56. èMODCTL    EQU    PORT+1        ;status register for RS232
  57. MODDAT    EQU    PORT        ;data resister for RS232
  58. MDSNDB    EQU    01H        ;bit to test for ready to send
  59. MDSNDR    EQU    01H        ;modem send ready when high
  60. MDRCVB    EQU    02H        ;bit to test for received data
  61. MDRCVR    EQU    02H        ;modem receive ready when high
  62. ;
  63. ; MEX service processor
  64. ;
  65. MEX    EQU    0D00H        ;address of the service processor
  66. INMDM    EQU    255        ;get char from port to A, CY=no more in 100 ms
  67. TIMER    EQU    254        ;delay 100ms * reg B
  68. TMDINP    EQU    253        ;B=# secs to wait for char, cy=no char
  69. CHEKCC    EQU    252        ;check for ^C from KBD, Z=present
  70. SNDRDY    EQU    251        ;test for modem-send ready
  71. RCVRDY    EQU    250        ;test for modem-receive ready
  72. SNDCHR    EQU    249        ;send a character to the modem (after sndrdy)
  73. RCVCHR    EQU    248        ;recv a char from modem (after rcvrdy)
  74. LOOKUP    EQU    247        ;table search: see CMDTBL comments for info
  75. PARSFN    EQU    246        ;parse filename from input stream
  76. BDPARS    EQU    245        ;parse baud-rate from input stream
  77. SBLANK    EQU    244        ;scan input stream to next non-blank
  78. EVALA    EQU    243        ;evaluate numeric from input stream
  79. LKAHED    EQU    242        ;get nxt char w/o removing from input
  80. GNC    EQU    241        ;get char from input, cy=1 if none
  81. ILP    EQU    240        ;inline print
  82. DECOUT    EQU    239        ;decimal output
  83. PRBAUD    EQU    238        ;print baud rate
  84. ;
  85. ;
  86. CONOUT    EQU    2        ;simulated BDOS function 2: console char out
  87. PRINT    EQU    9        ;simulated BDOS function 9: print string
  88. INBUF    EQU    10        ;input buffer, same structure as BDOS 10
  89. ;
  90.     ORG    TPA        ;we begin
  91. ;
  92. ;
  93.     DS    3        ;MEX has a JMP START here
  94. ;
  95. ; The following variables are located at the beginning of the program
  96. ; to facilitate modification without the need of re-assembly. They will
  97. ; be moved in MEX 2.0.
  98. ;
  99. PMODEM:    DB    NO        ;yes=PMMI modem \ / These 2 locations are not
  100. SMODEM:    DB    YES        ;yes=Smartmodem / \ referenced by MEX
  101. TPULSE:    DB    'T'        ;T=touch, P=pulse (not referenced by MEX)
  102. CLOCK:    DB    40        ;clock speed x .1, up to 25.5 mhz.
  103. MSPEED:    DB    1        ;sets display time for sending a file
  104.                 ;0=110    1=300  2=450  3=600  4=710
  105.                 ;5=1200 6=2400 7=4800 8=9600 9=19200
  106. BYTDLY:    DB    5        ;default time to send character in
  107.                 ;terminal mode file transfer (0-9)
  108.                 ;0=0 delay, 1=10 ms, 5=50 ms, 9=90 ms
  109. CRDLY:    DB    5        ;end-of-line delay after CRLF in terminal
  110.                 ;mode file transfer for slow BBS systems
  111. è                ;0=0 delay, 1=100 ms, 5=500 ms, 9=900 ms
  112. COLUMS:    DB    3        ;number of directory columns
  113. SETFL:    DB    YES        ;yes=user-defined SET command
  114. SCRTST:    DB    YES        ;yes=if home cursor and clear screen
  115.                 ;routine at CLRSCRN
  116.     DB    0        ;was once ACKNAK, now spare
  117. BAKFLG:    DB    NO        ;yes=make .BAK file
  118. CRCDFL:    DB    YES        ;yes=default to CRC checking
  119.                 ;no=default to Checksum checking
  120. TOGCRC:    DB    YES        ;yes=allow toggling of Checksum to CRC
  121. CVTBS:    DB    NO        ;yes=convert backspace to rub
  122. TOGLBK:    DB    YES        ;yes=allow toggling of bksp to rub
  123. ADDLF:    DB    NO        ;no=no LF after CR to send file in
  124.                 ;terminal mode (added by remote echo)
  125. TOGLF:    DB    YES        ;yes=allow toggling of LF after CR
  126. TRNLOG:    DB    NO        ;yes=allow transmission of logon
  127.                 ;write logon sequence at location LOGON
  128. SAVCCP:    DB    YES        ;yes=do not overwrite CCP
  129. LOCNXT:    DB    NO        ;yes=local cmd if EXTCHR precedes
  130.                 ;no=not local cmd if EXTCHR precedes
  131. TOGLOC:    DB    YES        ;yes=allow toggling of LOCNXTCHR
  132. LSTTST:    DB    YES        ;yes=allow toggling of printer on/off
  133.                 ;in terminal mode. Set to no if using
  134.                 ;the printer port for the modem
  135. XOFTST:    DB    NO        ;yes=allow testing of XOFF from remote
  136.                 ;while sending a file in terminal mode
  137. XONWT:    DB    NO        ;yes=wait for XON after sending CR while
  138.                 ;transmitting a file in terminal mode    
  139. TOGXOF:    DB    YES        ;yes=allow toggling of XOFF testing
  140. IGNCTL:    DB    YES        ;yes=do not send control characters
  141.                 ;above CTL-M to CRT in terminal mode
  142.                 ;no=send any incoming CTL-char to CRT
  143. EXTRA1:    DB    0        ;for future expansion
  144. EXTRA2:    DB    0        ;for future expansion
  145. BRKCHR:    DB    '@'-40H        ;^@ = Send a 300 ms. break tone
  146. NOCONN:    DB    'N'-40H        ;^N = Disconnect from phone line
  147. LOGCHR:    DB    'L'-40H        ;^L = Send logon
  148. LSTCHR:    DB    'P'-40H        ;^P = Toggle printer
  149. UNSVCH:    DB    'R'-40H        ;^R = Close input text buffer
  150. TRNCHR:    DB    'T'-40H        ;^T = Transmit file to remote
  151. SAVCHR:    DB    'Y'-40H        ;^Y = Open input text buffer
  152. EXTCHR:    DB    '^'-40H        ;^^ = Send next character
  153. ;
  154. ; Equates used only by PMMI routines grouped together here.
  155. ;
  156. PRATE:    DB    250        ;125=20pps dialing, 250=10pps
  157.     DB    0        ;not used
  158. ;
  159. ; Low-level modem I/O routines: this will be replaced with
  160. ; a jump table in MEX 2.0 (you can insert jumps here to longer
  161. ; routines if you'd like ... I'd recommend NOT putting part of
  162. ; a routine in this area, then jumping to the rest of the routine
  163. ; in the non-fixed area; that will complicate the 2.0 conversion)
  164. ;
  165. INCTL1:    JMP    INSTAT        ;in modem control port
  166. è    DB    0,0,0,0,0,0,0    ;spares if needed for non-PMMI
  167. ;
  168. OTDATA:    JMP    OUTDAT        ;out modem data port
  169.     DB    0,0,0,0,0,0,0    ;spares if needed for non=PMMI
  170. ;
  171. INPORT:    JMP    INDAT        ;in modem data port
  172.     DB    0,0,0,0,0,0,0    ;spares if needed for non-PMMI
  173. ;
  174. ; Bit-test routines.  These will be merged with the above
  175. ; routines in MEX 2.0 to provide a more reasonable format
  176. ;
  177. MASKR:    ANI MDRCVB ! RET    ;bit to test for receive ready
  178. TESTR:    CPI MDRCVR ! RET    ;value of receive bit when ready
  179. MASKS:    ANI MDSNDB ! RET    ;bit to test for send ready
  180. TESTS:    CPI MDSNDR ! RET    ;value of send bit when ready
  181. ;
  182. ;
  183. ; Unused area: was once used for special PMMI functions,
  184. ; Now used only to retain compatibility with MDM overlays.
  185. ; You may use this area for any miscellaneous storage you'd
  186. ; like but the length of the area *must* be 12 bytes.
  187. ;
  188.     DS    12
  189. ;
  190. ; Special modem function jump table: if your overlay cannot handle
  191. ; some of these, change the jump to "DS 3", so the code present in
  192. ; MEX will be retained.  Thus, if your modem can't dial, change the
  193. ; JMP PDIAL at DIALV to DS 3, and MEX will print a "not-implemented"
  194. ; diagnostic for any commands that require dialing.
  195. ;
  196. ;
  197. LOGON:    DS    2        ;needed for MDM compat, not ref'd by MEX
  198. DIALV:    DS    3        ;dial digit in A (see info at PDIAL)
  199. DISCV:    JMP    PDISC        ;disconnect the modem
  200. GOODBV:    JMP    DUMMY        ;called before exit to CP/M
  201. INMODV:    JMP    NITMOD        ;initialization. Called at cold-start
  202. NEWBDV:    JMP    PBAUD        ;set baud rate
  203. NOPARV:    DS    3        ;set modem for no-parity
  204. PARITV:    DS    3        ;set modem parity
  205. SETUPV:    JMP    SETCMD        ;SET cmd: jump to a RET if you don't write SET
  206. SPMENV:    DS    3        ;not used with MEX
  207. VERSNV:    JMP    SYSVER        ;Overlay's voice in the sign-on message
  208. BREAKV:    JMP    PBREAK        ;send a break
  209. ;
  210. ; The following jump vector provides the overlay with access to special
  211. ; routines in the main program (retained and supported in the main pro-
  212. ; gram for MDM overlay compatibility). These should not be modified by
  213. ; the overlay.
  214. ;
  215. ; Note that for MEX 2.0 compatibility, you should not try to use these
  216. ; routines, since this table will go away with MEX 2.0 (use the MEX
  217. ; service call processor instead).
  218. ;
  219. ILPRTV:    DS    3        ;replace with MEX function 9
  220. INBUFV:    DS    3        ;replace with MEX function 10
  221. èILCMPV:    DS    3        ;replace with table lookup funct. 247
  222. INMDMV:    DS    3        ;replace with MEX function 255
  223. NXSCRV:    DS    3        ;not supported by MEX (returns w/no action)
  224. TIMERV:    DS    3        ;replace with MEX function 254
  225. ;
  226. ;
  227. ; Clear/screen and clear/end-of-screen. Each routine must use the
  228. ; full 9 bytes alloted (may be padded with nulls).
  229. ;
  230. ; These routines (and other screen routines that MEX 2.0 will sup-
  231. ; port) will be accessed through a jump table in 2.0, and will be
  232. ; located in an area that won't tie the screen functions to the
  233. ; modem overlay (as the MDM format does).
  234. ;
  235. CLREOS:    LXI    D,EOSMSG
  236.     MVI    C,PRINT
  237.     CALL    MEX
  238.     RET
  239. ;
  240. ;
  241. CLS:    LXI    D,CLSMSG        ;null unless patched
  242.     MVI    C,PRINT
  243.     JMP    MEX
  244. ;
  245. ;------------------------------------------------------------
  246. ;
  247. ;    *** END OF FIXED FORMAT AREA ***
  248. ;
  249. ;------------------------------------------------------------
  250. ;
  251. ; If the dip switches are set externally to NNNN baud then you get
  252. ; NNNN or NNNN/4 baud with the SET command.  The switches should
  253. ; normally be set to 1200 baud.
  254. ;
  255. NITMOD:    XRA    A        ;insure that the 8251 is in the command mode
  256.     OUT    MODCTL
  257.     OUT    MODCTL
  258.     OUT    MODCTL
  259.     LDA    MSPEED        ;get the baud rate code
  260.     JMP    PBAUD        ;  and go set it
  261. ;
  262. ; Sends a 300 msec break tone.
  263. ;
  264. PBREAK:    MVI    A,CMND        ;default command byte
  265.     ORI    BRKBIT        ;turn on the break bit
  266.     OUT    MODCTL
  267.     PUSH    B
  268.     MVI    B,3        ;wait for 300 ms
  269.     MVI    C,TIMER
  270.     CALL    MEX
  271.     POP    B
  272.     MVI    A,CMND        ;restore the command byte
  273.     OUT    MODCTL
  274.     RET
  275. ;
  276. è; Drops DTR for 300 msec to disconnect the modem.
  277. ;
  278. PDISC:    MVI    A,CMND
  279.     ANI    0FFH AND NOT DTRBIT    ;mask out the DTR bit
  280.     OUT    MODCTL
  281.     PUSH    B
  282.     MVI    B,3        ;wait for 300 ms
  283.     MVI    C,TIMER
  284.     CALL    MEX
  285.     POP    B
  286.     MVI    A,CMND        ;restore command byte
  287.     OUT    MODCTL
  288.     RET
  289. ;
  290. ; exit routine
  291. ;
  292. DUMMY:    RET
  293. ;
  294. ;
  295. ;------------------------------------------------------------
  296. ;
  297. ; Set baud-rate code in A (if supported by your modem overlay).  PMMI
  298. ; supports only five rates, which are validated here. NOTE: this routine
  299. ; (ie, the one vectored through NEWBDV) should update MSPEED with the
  300. ; passed code, but ONLY if that rate is supported by the hardware.
  301. ;
  302. PBAUD:    PUSH    H        ;don't alter anybody
  303.     PUSH    D
  304.     PUSH    B
  305.     MOV    E,A        ;code to DE
  306.     MVI    D,0
  307.     LXI    H,BAUDTB    ;offset into table
  308.     DAD    D
  309.     MOV    A,M        ;fetch code
  310.     ORA    A        ;0? (means unsupported code)
  311.     STC            ;return error for STBAUD caller
  312.     JZ    PBEXIT        ;exit if so
  313.     LDA    MODCTB        ;last 8251 mode byte
  314.     ANI    0FFH AND NOT BAUDMSK    ;clear out baud bits
  315.     ORA    M        ;put new baud bits in
  316.     CALL    STMODE        ;send it to the mode register
  317.     MOV    A,E        ;get speed code back
  318.     STA    MSPEED        ;make it current
  319. PBEXIT:    POP    B        ;all done
  320.     POP    D
  321.     POP    H
  322.     RET
  323. ;
  324. ; table of baud rate bits for supported rates
  325. ;
  326. BAUDTB:    DB    0,3,0,0,0    ;110,300,450,600,710
  327.     DB    2,0,0,0,0    ;1200,2400,4800,9600,19200
  328. ;
  329. ; send the byte in reg A to the 8251 mode register
  330. ;
  331. èSTMODE:    STA    MODCTB        ;save it so we know what it was
  332.     MVI    A,MODRST    ;reset the 8251
  333.     OUT    MODCTL
  334.     LDA    MODCTB        ;send the baud rate, etc
  335.     OUT    MODCTL        ;  as the mode byte
  336.     MVI    A,CMND        ;rx enable, tx enable, etc
  337.     OUT    MODCTL        ;  as a command byte
  338.     RET
  339. ;
  340. ; Sign-on message
  341. ;
  342. SYSVER:    LXI    D,SOMESG
  343.     MVI    C,PRINT
  344.     JMP    MEX
  345. ;
  346. SOMESG:    DB    CR,LF,ESC,')'        ;into half intensity
  347.     DB    '    Overlay Version  '
  348.     DB    REV/10+'0'
  349.     DB    '.'
  350.     DB    REV MOD 10+'0'
  351.     DB    '      ',CR,LF
  352.     DB    '     Configured for the       ',CR,LF
  353.     DB    '        NEC  PC-8801          ',CR,LF
  354.     DB    '       by Bob Schultz         ',CR,LF
  355.     DB    '                              ',CR,LF
  356.     DB    '                              '
  357.     DB    ESC,'(',CR,LF        ;out of half intensity
  358.     DB    LF,'$'
  359.     RET
  360. ;
  361. ; Newline on console
  362. ;
  363. CRLF:    MVI    A,CR
  364.     CALL    TYPE
  365.     MVI    A,LF        ;fall into TYPE
  366. ;
  367. ; type char in A on console
  368. ;
  369. TYPE:    PUSH    H        ;save 'em
  370.     PUSH    D
  371.     PUSH    B
  372.     MOV    E,A        ;align output character
  373.     MVI    C,CONOUT    ;print via MEX
  374.     CALL    MEX
  375.     POP    B
  376.     POP    D
  377.     POP    H
  378.     RET
  379. ;
  380. ; strings to clear-to-end-of-screen, and clear-screen
  381. ;
  382. EOSMSG:    DB    CR,LF,'$'        ;clear to end of screen
  383. CLSMSG:    DB    CLRSCR,'$'        ;clear whole screen
  384. ;
  385. ; Data area
  386. è;
  387. MODCTB:    DB    BIT8 OR PARN1 OR STP1    ;modem control byte
  388. ;                       default  8N1
  389. ;
  390. ;------------------------------------------------------------
  391. ;
  392. ;
  393. ;
  394. ; Control is passed here after MEX parses a SET command.
  395. ;
  396. SETCMD:    MVI    C,SBLANK    ;any arguments?
  397.     CALL    MEX
  398.     JC    SETSHO        ;if not, go print out values
  399.     LXI    D,CMDTBL    ;parse command
  400.     CALL    TSRCH        ;from table
  401.     PUSH    H        ;any address on stack
  402.     RNC            ;if we have one, execute it
  403.     POP    H        ;nope, fix stack
  404. SETERR:    LXI    D,SETEMS    ;print error
  405.     MVI    C,PRINT
  406.     JMP    MEX
  407. ;
  408. SETEMS:    DB    CR,LF,'SET command error',CR,LF
  409.     DB    'Type ',ESC,')SET ?',ESC,'( for help',CR,LF,LF,'$'
  410. ;
  411. ; SET command table ... note that tables are constructed of command-
  412. ; name (terminated by high bit=1) followed by word-data-value returned
  413. ; in HL by MEX service processor LOOKUP.  Table must be terminated by
  414. ; a binary zero.
  415. ;
  416. ; Note that LOOKUP attempts to find the next item in the input stream
  417. ; in the table passed to it in HL ... if found, the table data item is
  418. ; returned in HL; if not found, LOOKUP returns carry set.
  419. ;
  420. CMDTBL:    DB    '?'+80H            ;"set ?"
  421.     DW    STHELP
  422.     DB    'BAU','D'+80H        ;"set baud"
  423.     DW    STBAUD
  424.     DB    'BIT','S'+80H        ;"set bits"
  425.     DW    STBITS
  426.     DB    'PA','R'+80H        ;"set par"
  427.     DW    STPAR
  428.     DB    'STO','P'+80H        ;"set stop"
  429.     DW    STSTOP
  430.     DB    'H'+80H            ;"set h"
  431.     DW    STH
  432.     DB    'L'+80H            ;"set l"
  433.     DW    STL
  434.     DB    'PEE','K'+80H
  435.     DW    STPEEK
  436.     DB    'BEL','L'+80H
  437.     DW    STBELL
  438. ;
  439.     DB    0        ;<<=== table terminator
  440. ;
  441. è; SET <no-args>: print current statistics
  442. ;
  443. SETSHO:    LXI    H,SHOTBL    ;get table of SHOW subroutines
  444. SETSLP:    MOV    E,M        ;get table address
  445.     INX    H
  446.     MOV    D,M
  447.     INX    H
  448.     MOV    A,D        ;end of table?
  449.     ORA    E
  450.     RZ            ;exit if so
  451.     PUSH    H        ;save table pointer
  452.     XCHG            ;adrs to HL
  453.     CALL    GOHL        ;do it
  454.     CALL    CRLF        ;print newline
  455.     MVI    C,CHEKCC    ;check for console abort
  456.     CALL    MEX
  457.     POP    H        ;it's done
  458.     JNZ    SETSLP        ;continue if no abort
  459.     RET
  460. ;
  461. GOHL:    PCHL
  462. ;
  463. ; table of SHOW subroutines
  464. ;
  465. SHOTBL:    DW    CLS
  466.     DW    CRLF
  467.     DW    BDSHOW
  468.     DW    BTSHOW
  469.     DW    0        ;<<== table terminator
  470. ;
  471. ; SET ?  processor
  472. ;
  473. STHELP:    LXI    D,HLPMSG
  474.     MVI    C,PRINT
  475.     JMP    MEX
  476. ;
  477. ; The help message
  478. ;
  479. HLPMSG:    DB    CLRSCR,'SET command, NEC PC-8801 version',CR,LF,LF
  480.     DB    ESC,')SET BAUD',ESC,'(  <',ESC,')300',ESC,'(>  <'
  481.     DB    ESC,')1200',ESC,'(>',CR,LF,LF
  482.  
  483.     DB    ESC,')SET BITS',ESC,'(  <',ESC,')5',ESC,'(> <',ESC,')6'
  484.     DB    ESC,'(> <',ESC,')7',ESC,'(> <',ESC,')8',ESC,'(>',CR,LF,LF
  485.  
  486.     DB    ESC,')SET PAR',ESC,'(   <',ESC,')E',ESC,'(>  <',ESC,')O'
  487.     DB    ESC,'(>  <',ESC,')N',ESC,'(>',CR,LF,LF
  488.  
  489.     DB    ESC,')SET STOP',ESC,'(  <',ESC,')1',ESC,'(>  <',ESC,')1.5'
  490.     DB    ESC,'(>  <',ESC,')2',ESC,'(>',CR,LF,LF
  491.  
  492.     DB    '$'
  493. ;
  494. ; SET BAUD processor
  495. ;
  496. èSTBAUD:    MVI    C,BDPARS    ;function code
  497.     CALL    MEX        ;let MEX look up code
  498.     JC    SETERR        ;invalid code
  499. STBD:    CALL    PBAUD        ;no, try to set it
  500.     JC    SETERR        ;not-supported code
  501.     CALL    CRLF
  502.     CALL    BDSHOW
  503.     JMP    CRLF
  504. ;
  505. BDSHOW:    CALL ILPRT
  506.     DB    ESC,')',0
  507.     LDA    MSPEED
  508.     MVI    C,PRBAUD    ;use MEX routine
  509.     CALL    MEX
  510.     CALL    ILPRT
  511.     DB    BS,BS,BS,BS,ESC,'( Baud',CR,LF,0
  512.     RET
  513. ;
  514. ; SET H        1200 baud for lazy typists
  515. ;
  516. STH:    MVI    A,5
  517.     JMP    STBD
  518. ;
  519. ; SET L        300 baud for lazy typists
  520. ;
  521. STL:    MVI    A,1
  522.     JMP    STBD
  523. ;
  524. ; SET BITS    character length
  525. ;
  526. STBITS:    LXI    D,BITTBL    ;point to table
  527.     CALL    TSRCH        ;  and search for command
  528.     JC    SETERR
  529.     LDA    MODCTB        ;get the last 8251 mode byte
  530.     ANI    0FFH AND NOT BITMSK    ;zero the character length
  531.     ORA    L            ;  and put in the new value
  532.     CALL    STMODE        ;send to the 8251 mode register
  533.     CALL    CRLF
  534.     CALL    BTSHOW
  535.     JMP    CRLF
  536. ;
  537. ; BITS table
  538. ;
  539. BITTBL:    DB    '8'+80H
  540.     DW    BIT8
  541.     DB    '7'+80H
  542.     DW    BIT7
  543.     DB    '6'+80H
  544.     DW    BIT6
  545.     DB    '5'+80H
  546.     DW    BIT5
  547. ;
  548.     DB    0        ;<== table terminator
  549. ;
  550. ; display the character length, parity and number of stop bits
  551. è;
  552. BTSHOW:    CALL    ILPRT        ;into inverse video
  553.     DB    ESC,')',0
  554.     LDA    MODCTB        ;8251 mode register image
  555.     ANI    BITMSK        ;keep only the character length
  556.     RAR
  557.     RAR            ;shift bits down to bit 0
  558.     ADI    '5'        ;0 is 5 bits, 1 is 6...
  559.     CALL    TYPE
  560.     CALL    ILPRT
  561.     DB    ESC,'( Bits  ',ESC,')',0
  562.     LDA    MODCTB
  563.     ANI    PARMSK        ;get the parity bits
  564.     LXI    D,EVNMSG
  565.     MVI    C,PRINT
  566.     CPI    PARE
  567.     CZ    MEX        ;for EVEN parity
  568.     LXI    D,ODDMSG
  569.     CPI    PARO
  570.     CZ    MEX        ;for ODD parity
  571.     LXI    D,NOMSG
  572.     CPI    PARN1
  573.     CZ    MEX        ;for NO parity-first code
  574.     CPI    PARN2
  575.     CZ    MEX        ;for NO parity-second code
  576.     CALL    ILPRT
  577.     DB    ESC,'( Parity  ',ESC,')',0
  578.     LDA    MODCTB
  579.     ANI    STPMSK        ;get the stop bits
  580.     PUSH    PSW
  581.     LXI    D,S1MSG
  582.     MVI    C,PRINT
  583.     CPI    STP1
  584.     CZ    MEX        ;for 1 stop bit
  585.     LXI    D,S15MSG
  586.     CPI    STP15
  587.     CZ    MEX        ;for 1.5 stop bits
  588.     LXI    D,S2MSG
  589.     CPI    STP2
  590.     CZ    MEX        ;for 2 stop bits
  591.     CALL    ILPRT
  592.     DB    ESC,'( Stop bit',0
  593.     POP    PSW
  594.     CPI    STP1
  595.     MVI    A,'s'
  596.     CNZ    TYPE        ;if 1 don't put out 's'
  597.     JMP    CRLF
  598. ;
  599. EVNMSG:    DB    'EVEN$'
  600. ODDMSG:    DB    'ODD$'
  601. NOMSG:    DB    'NO$'
  602. ;
  603. S1MSG:    DB    '1$'
  604. S2MSG:    DB    '2$'
  605. S15MSG:    DB    '1.5$'
  606. è;
  607. ; SET PAR    set the parity
  608. ;
  609. STPAR:    LXI    D,PARTBL    ;point to the table of commands
  610.     CALL    TSRCH        ;  and search it
  611.     JC    SETERR
  612.     LDA    MODCTB
  613.     ANI    0FFH AND NOT PARMSK    ;zero the parity bits
  614.     ORA    L            ;  and put in the new parity
  615.     CALL    STMODE        ;send it to the 8251 mode register
  616.     CALL    CRLF
  617.     CALL    BTSHOW
  618.     JMP    CRLF
  619. ;
  620. ; table for PAR
  621. ;
  622. PARTBL:    DB    'E'+80H
  623.     DW    PARE
  624.     DB    'O'+80H
  625.     DW    PARO
  626.     DB    'N'+80H
  627.     DW    PARN1
  628. ;
  629.     DB    0        ;<== table terminator
  630. ;
  631. ; SET STOP    set the stop bits
  632. ;
  633. STSTOP:    LXI    D,STPTBL    ;point to the command table
  634.     CALL    TSRCH        ;  and search it
  635.     JC    SETERR
  636.     LDA    MODCTB
  637.     ANI    0FFH AND NOT STPMSK    ;zero the stop bits
  638.     ORA    L            ;  and put in the new ones
  639.     CALL    STMODE        ;send to the 8251 mode register
  640.     CALL    CRLF
  641.     CALL    BTSHOW
  642.     JMP    CRLF
  643. ;
  644. ; table for STOP
  645. ;
  646. STPTBL:    DB    '1'+80H
  647.     DW    STP1
  648.     DB    '1.','5'+80H
  649.     DW    STP15
  650.     DB    '2'+80H
  651.     DW    STP2
  652. ;
  653.     DB    0        ;<== table terminator
  654. ;
  655. ; SET PEEK    display memory location in hex and ascii
  656. ;
  657. STPEEK:    CALL    CRLF
  658.     MVI    C,EVALA
  659.     CALL    MEX        ;get numeric
  660.     PUSH    H
  661. è    MVI    B,16        ;will do 16 bytes
  662. PKLP1:    MOV    A,M        ;get byte
  663.     MOV    C,A
  664.     RAR            ;swap nibbles
  665.     RAR
  666.     RAR
  667.     RAR
  668.     CALL    HEX1        ;put out first nibble
  669.     MOV    A,C
  670.     CALL    HEX1        ;put out second nibble
  671.     MVI    A,' '
  672.     CALL    TYPE
  673.     INX    H
  674.     DCR    B
  675.     JNZ    PKLP1        ;keep doing it
  676.     CALL    CRLF
  677.     POP    H        ;point to starting byte again
  678.     MVI    B,16
  679. PKLP2:    MVI    A,' '
  680.     CALL    TYPE
  681.     MOV    A,M
  682.     CPI    20H
  683.     JC    NOTASC        ;must be control
  684.     CPI    7FH
  685.     JNC    NOTASC        ;del and above
  686.     CALL    TYPE        ;put out printable
  687.     JMP    ASC
  688. NOTASC:    MVI    A,'.'        ;put out a '.' for non-printable
  689.     CALL    TYPE
  690. ASC:    MVI    A,' '
  691.     CALL    TYPE
  692.     INX    H
  693.     DCR    B
  694.     JNZ    PKLP2        ;keep doing it
  695.     CALL    CRLF
  696.     JMP    CRLF
  697. ;
  698. HEX1:    ANI    0FH        ;zero top nibble
  699.     ADI    90H        ;thanks to
  700.     DAA            ;  Kelly Smith
  701.     ACI    40H        ;    for this strange
  702.     DAA            ;      looking code
  703.     CALL    TYPE
  704.     RET
  705. ;
  706. ; It's easy to get carried away adding new commands for SET
  707. ;
  708. STBELL:    CALL    ILPRT
  709.     DB    7,CR,LF,ESC,')Ding!!  Dong!!',ESC,'(',CR,LF,LF,7,0
  710. ;
  711. ; Compare next input-stream item in table @DE; CY=1
  712. ; if not found, else HL=matched data item
  713. ;
  714. TSRCH:    MVI    C,LOOKUP    ;get function code
  715.     JMP    MEX        ;pass to MEX processor
  716. è;
  717. ; Print in-line message ... blows away C register
  718. ;
  719. ILPRT:    MVI    C,ILP        ;get function code
  720.     JMP    MEX        ;go do it
  721. ;
  722. ; end of SET command
  723. ;
  724. ;---------------------------------------------------------------
  725. ;
  726. ; These routines are down here to make it easy to hang things
  727. ; on them.  For example you might add code to check for framing
  728. ; errors and then throw the charater away or zero it or...
  729. ;
  730. ; Modem status in
  731. ;
  732. INSTAT:    IN    MODCTL
  733.     RET
  734. ;
  735. ; Modem data in
  736. ;
  737. INDAT:    IN    MODDAT
  738.     RET
  739. ;
  740. ; Modem data out
  741. ;
  742. OUTDAT:    OUT    MODDAT
  743.     RET
  744. ;
  745. ;---------------------------------------------------------------
  746. ;
  747. ; End of NEC PC8801 MEX modem overlay
  748. ;
  749. ;------------------------------------------------------------
  750. ;
  751.     END
  752.  
  753.