home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / MEX / MXO-DM20.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  20KB  |  704 lines

  1. ; TITLE 'MEX overlay for the NCR DMV using the K801 adapter'
  2. ; Comment out above line if assembling with asm.com
  3. ; MXO-DM20.ASM - NCR DecisionMate V overlay file for MEX1.14.  02/10/87
  4. ;
  5. ; You will want to look this file over carefully. There are a number of
  6. ; options that you can use to configure the program to suit your taste.
  7. ;
  8. ; This file adapts the NCR DMV to Mex1.14. It assumes that you have the 
  9. ; K801 (switchable) adapter, with the ifsel set to 1A (as recommended by 
  10. ; NCR for the communication port). If you are using a different ifsel,
  11. ; change the value of the PORT equate.
  12. ;
  13. ;    MEX NOTES: Several of the data locations below (from 0103h to
  14. ;    0194h are not referenced by MEX, and are retained only for MDM740
  15. ;    compatability. These locations are marked with an "*1".
  16. ;
  17. ; Edit this file for your preferences. Pay particular attention to 
  18. ; the DFLTBD, DFLTPR, DFLTPA, AFLTPA, DFLTDT, AFLTDT, DFLTST, AFLTST,
  19. ; NOTASC, and FNBUF
  20. ;
  21. ; Use the "SET" command to change the baudrate when desired.  It starts
  22. ; out at the value specified by DFLTBD when the program is first called up.
  23. ; If DFLTBD is changed, DFLTPR must also be changed (get the value from
  24. ; the table of baud rate parameters). You may also use the set command to 
  25. ; change the parity, data bits, and stop bits. Similarly, DFLTPA and AFLTPA
  26. ; (for parity), DFLTST and AFLTST (for stop bits), and DFLTDT and AFLTDT
  27. ; (for data bits) must be changed for your preferences. Most likely the
  28. ; settings you want will be NONE, 'N', STOP1, '1', DATA8, and '8'
  29. ; respectively.
  30. ;
  31. ; You may also use the "SET" command to temporarily change the definition
  32. ; of the DMV's function keys. Any redefinition will remain until a cold 
  33. ; boot is performed or the key is redefined. The maximum length for any
  34. ; function key string is defined by FNBUF, although the total may not
  35. ; exceed 236 characters. The strings follow Mex conventions (i.e. between 
  36. ; double quotes, Control characters entered as, for instance, ^M),  
  37. ; additionally, a '^' may be entered by typing '^~'. Note that a '\' is 
  38. ; entered as just that, not as '\\'.
  39. ;
  40. ; Finally, you may use the SET DUMP command to view memory. The format is
  41. ; "SET DUMP xxxxx yyyyy", where xxxxx is the start address, and yyyyy is 
  42. ; the end address of the memory to display. The two numbers are entered
  43. ; in either hex or decimal, depending on the current values of the hex and
  44. ; dec STAT switches.
  45. ;
  46. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  47. ;
  48. ; 06/06/87 - Added SET commands for data bits, stop bits, and parity, 
  49. ;         and added second parameter to dump command. Version 2.0
  50. ;                            - Brent B. Powers
  51. ;
  52. ; 02/20/87 - Fixed a bug with setting a function key to a zero
  53. ;         length string ("")                - Brent B. Powers
  54. ;
  55. ; 02/10/87 - Adapted from MXO-OS14 and M7NC-1        - Brent B. Powers
  56. ;         written by, respectively, Bob Schultz and Robert Flagg
  57. ;
  58. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  59. ;
  60. BELL    EQU    07H        ; Bell
  61. CR    EQU    0DH        ; Carriage return
  62. ESC    EQU    1BH        ; Escape
  63. LF    EQU    0AH        ; Linefeed
  64. TAB    EQU    09H        ; Tab
  65. TPA    EQU    0100H        ; Standard start of TPA
  66. DIM    EQU    ')'        ; Highlighting off
  67. UNDIM    EQU    '('        ; Highlighting on
  68. CLS    EQU    01AH        ; Clear Screen
  69. PRINV    EQU    'G'        ; Prefix for invert/uninvert
  70. INVERT    EQU    '4'        ; Invert on
  71. UNINV    EQU    '0'        ; Invert off
  72. ;
  73. NOTASC    EQU    '.'        ; Char. to print for unprintable ascii codes
  74. FNBUF    EQU    020h        ; Maximum length of a function key string
  75. ;
  76. VERSN    EQU    20
  77. ;
  78. YES    EQU    0FFH
  79. NO    EQU    0
  80. ;
  81. DFLTBD    EQU    05        ; Default Baud rate: use 0 for 110 baud,
  82.                 ; 1 for 300, 5 for 1200, 6 for 2400,
  83.                 ; 8 for 9600, and 9 for 19200.
  84. DFLTPR    EQU    00F7H        ; Default rate parameter for the IO chip.
  85.                 ; use F4h for 110 baud, F5h for 300,
  86.                 ; F7h for 1200, FBh for 2400, FCh for 9600,
  87.                 ; and FEh for 19200
  88. ;
  89. ; DATA BITS EQUATES
  90. DATA8    EQU    0CH
  91. DATA7    EQU    08H
  92. DATA6    EQU    04H
  93. DATA5    EQU    00H
  94. ;
  95. ;    fill this in with your default data bits
  96. DFLTDT    EQU    DATA8
  97. ;    fill this in with the ascii representation '5', '6', '7', or '8'
  98. AFLTDT    EQU    '8'
  99. ;
  100. ;
  101. ; PARITY EQUATES
  102. NONE    EQU    000H
  103. ODD    EQU    010H
  104. EVEN    EQU    030H
  105. ;
  106. ;    fill this in with your default parity
  107. DFLTPA    EQU    NONE
  108. ;    fill this in with the ascii representation  'N', 'E', or 'O'
  109. AFLTPA    EQU    'N'
  110. ;
  111. ;
  112. ; STOP BITS EQUATES
  113. STOP1    EQU    040H
  114. STOP2    EQU    0C0H
  115. ;
  116. ;    fill this in with your default stop bits
  117. DFLTST    EQU    STOP1
  118. ;    fill this in with the ascii representation '1' or '2'
  119. AFLTST    EQU    '1'
  120. ;
  121. ;
  122. DFLTPM    EQU    DFLTST+DFLTDT+DFLTPA+1
  123. ;
  124. PORT    EQU    070H        ; NCR modem base
  125. MODDAT    EQU    PORT        ; Data port
  126. MODSTAT EQU    PORT+1        ; Status port
  127. MODMODE EQU    PORT+2        ; Mode port
  128. MODCMD    EQU    PORT+3        ; Command port
  129. WRITE    EQU    4        ; Offset to the above for write ops
  130. ;
  131. RCVB    EQU    02H        ; Modem receive bit
  132. RCVR    EQU    02H        ; Modem receive ready
  133. SNDB    EQU    01H        ; Modem send bit
  134. SNDR    EQU    01H        ; Modem send ready bit
  135. ;
  136. ; MEX service processor stuff
  137. ;
  138. MEX    EQU    0D00H        ; Address of Mex service processor
  139. INMDM    EQU    255        ; Get char from port to A, CY=no more in 100 ms
  140. TIMER    EQU    254        ; Delay 100ms * reg B
  141. TMDINP    EQU    253        ; B=# secs to wait for char, cy=no char
  142. CHEKCC    EQU    252        ; Check for ^C from KBD, Z=present
  143. SNDRDY    EQU    251        ; Test for modem-send ready
  144. RCVRDY    EQU    250        ; Test for modem-receive ready
  145. SNDCHR    EQU    249        ; Send a character to the modem (after sndrdy)
  146. RCVCHR    EQU    248        ; Recv a char from modem (after rcvrdy)
  147. LOOKUP    EQU    247        ; Table search: see CMDTBL comments for info
  148. PARSFN    EQU    246        ; Parse filename from input stream
  149. BDPARS    EQU    245        ; Parse baud-rate from input stream
  150. SBLANK    EQU    244        ; Scan input stream to next non-blank
  151. EVALA    EQU    243        ; Evaluate numeric from input stream
  152. LKAHED    EQU    242        ; Get nxt char w/o removing from input
  153. GNC    EQU    241        ; Get char from input, cy=1 if none
  154. ILP    EQU    240        ; Inline print
  155. DECOUT    EQU    239        ; Decimal output
  156. PRBAUD    EQU    238        ; Print baud rate
  157. PRINT    EQU    09        ; As BDOS 9
  158. CONOUT    EQU    02        ; As BDOS 2
  159. ;
  160. ;
  161.     ORG    100H
  162. ;
  163.     DS    3        ; (for  "JMP   START" instruction)
  164. ;
  165. PMMI:    DB    NO        ; Yes=PMMI S-100 Modem, *1        103H
  166. SMART:    DB    YES        ; Yes=HAYES Smartmodem, no=non-PMMI, *1    104H
  167. TOUCH:    DB    'T'        ; T=Touch, P=Pulse (Smartmodem-only), *1    105H
  168. CLOCK:    DB    40        ; Clock speed in MHz x10, 25.5 MHz max.    106H
  169.                 ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  170. MSPEED:    DB    DFLTBD        ; Change the DFLTBD equate above rather    107H
  171.                 ; than this byte
  172. BYTDLY:    DB    3        ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  173.                 ; Default time to send character in ter-
  174.                 ; Minal mode file transfer for slow BBS.
  175. CRDLY:    DB    5        ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  176.                 ; Default time for extra wait after CRLF
  177.                 ; In terminal mode file transfer
  178. NOCOL:    DB    5        ; Number of DIR columns shown        10AH
  179. SETTST:    DB    YES        ; Yes=user-added Setup routine        10BH
  180. SCRTST:    DB    YES        ; Cursor control routine         10CH
  181.     DB    0        ; This was once NAK/ACK, not used, *1    10DH
  182. BAKFL:    DB    NO        ; Yes=change any file same name to .BAK    10EH
  183. CRCDFT:    DB    YES        ; Yes=default to CRC checking        10FH
  184. TOGCRC:    DB    YES        ; Yes=allow toggling of CRC to Checksum    110H
  185. CONVBS:    DB    NO        ; Yes=convert rub to backspace        111H
  186. TOGBS:    DB    YES        ; Yes=allow toggling of rub to bksp    112H
  187. ADDLF:    DB    NO        ; No=no LF after CR to send file in    113H
  188.                 ; Terminal mode (added by remote echo)
  189. TOGLF:    DB    YES        ; Yes=allow toggling of LF after CR    114H
  190. TRNLOG:    DB    YES        ; Yes=allow transmission of logon    115H
  191.                 ; Write logon sequence at location LOGON
  192. SAVCCP:    DB    YES        ; Yes=do not overwrite CCP        116H
  193. LOCNXT:    DB    NO        ; Yes=local command if EXTCHR precedes    117H
  194.                 ; No=external command if EXTCHR precedes
  195. TOGLOC:    DB    YES        ; Yes=allow toggling of LOCONEXTCHR    118H
  196. LSTTST:    DB    YES        ; No=using modem on printer port        119H
  197. XOFTST:    DB    NO        ; Yes=checks for XOFF from remote while    11AH
  198.                 ; Sending a file in terminal mode
  199. XONWT:    DB    NO        ; Yes=wait for XON after CR while    11BH
  200.                 ; Sending a file in terminal mode
  201. TOGXOF:    DB    YES        ; Yes=allow toggling of XOFF checking    11CH
  202. FILTER:    DB    YES        ; Yes=CTL-chars above ^M not displayed    11DH
  203. EXTRA1:    DB    0        ; For future expansion, *1        11EH
  204. EXTRA2:    DB    0        ; For future expansion, *1        11FH
  205. BRKCHR:    DB    '@'-40H        ; ^@ = Send 50 ms. break tone        120H
  206. NOCONT:    DB    'N'-40H        ; ^N = Disconnect from phone line    121H
  207. LOGCHR:    DB    'L'-40H        ; ^L = Send logon            122H
  208. LSTCHR:    DB    'P'-40H        ; ^P = Toggle printer            123H
  209. UNSAVE:    DB    'R'-40H        ; ^R = Close input text buffer        124H
  210. TRANCHR:DB    'T'-40H        ; ^T = Transmit file to remote        125H
  211. SAVECHR:DB    'Y'-40H        ; ^Y = Open input text buffer        126H
  212. EXTCHR:    DB    ']'-40H        ; ^] = Send next character        127H
  213. ;
  214. ;
  215.     DS    2        ; PMMI specific, *1            128H
  216. ;
  217. INCTL1:    IN    MODSTAT        ; In modem control port            12AH
  218.     RET
  219.     DS    7
  220. OUTDAT:    OUT    MODDAT+WRITE    ; Out modem data port            134H
  221.     RET
  222.     DS    7
  223. INDAT:    IN    MODDAT        ; In modem data port            13EH
  224.     RET
  225.     DS    7
  226. MSKRCV:    ANI    RCVB        ; Bit to test for receive ready
  227.     RET
  228. TSTRCV:    CPI    RCVR        ; Value of receive bit when ready
  229.     RET
  230. MSKSND:    ANI    SNDB        ; Bit to test for send ready
  231.     RET
  232. TSTSND:    CPI    SNDR        ; Value of send bit when ready
  233.     RET
  234.     DS    12
  235. ;
  236. LOGON:    DS    2        ; For user message, *1        160H
  237.     DS    3        ;                 162H
  238. DISCV:    DS    3        ; Use Mex's routine        165H
  239. GDBYEV:    JMP    GDBYE        ;                 168H
  240. MINITV:    JMP    INITMOD        ; Go to user written routine    16BH
  241. NEWBDV:    JMP    SETBD        ; Sets baud rate associated with#16EH
  242.     RET            ; (by-passes PMMI routine), *1    171H
  243.     NOP
  244.     NOP
  245.     RET            ; (by-passes PMMI routine), *1    174H
  246.     NOP
  247.     NOP
  248. SETUPV:    JMP    SETUPR        ;                 177H
  249.     DS    3        ; Old call to special menu, *1    17AH
  250. VRMSGV:    JMP    SYSVER        ;                 17DH
  251. BRKV:    JMP    SENDBRK        ;                 180H
  252. ;
  253. ; Do not change the following six lines. None should be used, and are
  254. ; retained for overlay compatibility. Rumor says they're gone in MexPlus.
  255. ILPRTV:    DS    3        ; Use Mex Fn 240        183H
  256. INBUFV:    DS    3        ; Use Mex Fn 10            186H
  257. ILCMPV:    DS    3        ; Use Table lookup Fn 247    189H
  258. INMDMV:    DS    3        ; Use Mex Fn 255        18CH
  259.     DS    3        ; Once NextScnv, not supported, *1
  260.                 ;                 18FH
  261. TIMERV:    DS    3        ; Use Mex Fn 254        192H
  262. ;
  263. ; Clear sequences -- CLREOS is clear to end of screen, CLRSCR is clear
  264. ; entire screen.  Must use 9 bytes each, (pad with NOPs if necessary),
  265. ; and SCRTST must be yes
  266. ;
  267. CLREOS:    LXI    D, CLEOS
  268.     MVI    C, PRINT
  269.     CALL    MEX
  270.     RET
  271. ;
  272. CLRSCR:    MVI    C, PRINT
  273.     LXI    D, CLSC
  274.     JMP    MEX
  275. ;
  276. ;    End of fixed format area
  277. ;
  278. CLSC:    DB    CLS, '$'
  279. CLEOS:    DB    ESC, 'Y$'
  280. ;
  281. SYSVER:    CALL    ILPRT
  282.     DB    'NCR Decision Mate V overlay ',ESC,DIM
  283.     DB    'V',VERSN/10+'0','.',VERSN MOD 10+'0'
  284.     DB    ' for the K801 adapter',ESC,UNDIM
  285.     DB    ' by Brent B. Powers.',CR,LF,0
  286.     RET
  287. ;
  288. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  289. ;     end of your last routine should terminate by 0B00H if using the
  290. ;    Hayes Smartmodem or by address 0D00H otherwise.
  291. ;=======================================================================
  292. ;
  293. ; This routine allows a 300 ms. break tone to be sent to reset some
  294. ; time-share computers.
  295. ;
  296. SENDBRK:MVI    A, 1DH        ; SEND BREAK TONE
  297.     JMP    GDBYE1
  298. ;
  299. ; This routine sends a 300 ms. break tone and sets DTR low for the same
  300. ; length of time to disconnect some modems such as the Bell 212A, etc.
  301. ;
  302. GDBYE:    MVI    A, 05H        ; SEND BREAK, TURN OFF DTR
  303. ;
  304. GDBYE1:    OUT    MODCMD+WRITE    ; TAKE COMMAND REGISTER OUT
  305.     IN    MODCMD
  306.     IN    MODCMD        ; WAIT TO CLEAR
  307.     MVI    B, 3        ; WAIT 300 MS.
  308.     MVI    C, TIMER
  309.     CALL    MEX
  310.     MVI    A, 37H        ; NORMAL SEND/RECEIVE WITH DTR LOW
  311.     OUT    MODCMD+WRITE    ; SEND TO COMMAND REGISTER
  312.     IN    MODCMD
  313.     IN    MODCMD        ; WAIT TO SET
  314.     XRA    A        ; CLEAR AND LEAVE
  315.     RET
  316. ;
  317. ;
  318. ; Set up the 2651 ports
  319. INITMOD:MVI    A, DFLTBD    ; DEFAULT TRANSFER TIME TO 300 BAUD
  320.     STA    MSPEED
  321.     XRA    A        ; SET RTS, FLAGS, DTR, DISABLE R/T
  322.     OUT    MODCMD+WRITE    ; PUT COMMAND REGISTER OUT OF MODE
  323.     IN    MODCMD        ; MAKE SURE IT IS NOW CLEAR
  324.     IN    MODCMD        ; TRY ONCE MORE
  325. INITPM:    MVI    A, DFLTPM    ; N81
  326.     OUT    MODMODE+WRITE    ; SEND TO MODE REGISTER 1
  327. ;
  328. INITMOD1:
  329.     MVI    A, DFLTPR    ; START WITH DEFAULT BAUD, INTERNAL 5.0 CLOCK
  330.                 ; AND DEFAULT SERIAL PORT PARAMETERS
  331.     OUT    MODMODE+WRITE    ; SEND TO MODE REGISTER 2
  332.     MVI    A, 37H        ; RESET RTS, FLAGS, DTR LOW, ENABLE R/T
  333.     OUT    MODCMD+WRITE    ; SEND TO COMMAND REGISTER
  334.     IN    MODCMD        ; CLEAR ANY INCOMING CHARS.
  335.     IN    MODCMD        ; TRY ONCE MORE
  336.     XRA    A        ; CLEAR THE 'A' REG.
  337.     RET
  338. ;
  339. SETUPR:    MVI    C, SBLANK    ; ANY ARGUMENTS?
  340.     CALL    MEX
  341.     JC    TELL        ; NO, GO DISPLAY OPTIONS
  342.     
  343.     LXI    D, CMDTBL    ; YES
  344.     MVI    C, LOOKUP
  345.     CALL    MEX        ; PARSE ARGUMENT
  346.     PUSH    H        ; SAVE ANY PARSED ARGUMENT ADRS ON STACK
  347.     RNC            ; IF WE HAVE ONE, RETURN TO IT
  348.     POP    H        ; OOPS, INPUT NOT FOUND IN TABLE
  349. SETERR:    CALL    ILPRT        ; TELL USER INPUT NOT VALID
  350.     DB    CLS,CR,LF,LF,'++ Invalid SET command ++',CR,LF,0
  351.     JMP    TELL1
  352. ;
  353. CMDTBL:    DB    'BAU','D'+80H    ; Set Baud rate
  354.     DW    STBAUD
  355.     DB    'PARIT','Y'+80H    ; Set Parity
  356.     DW    SETPAR
  357.     DB    'BIT','S'+80H    ; Set Data Bits
  358.     DW    SETBIT
  359.     DB    'STO','P'+80H    ; Set Stop Bits
  360.     DW    SETSTP
  361.     DB    'KE','Y'+80H    ; Set function key
  362.     DW    SETKEY
  363.     DB    'DUM','P'+80H    ; Peek at memory
  364.     DW    DUMP
  365.     DB    '?'+80H        ; Help
  366.     DW    TELL
  367.     DB    0
  368. ;
  369. TELL:    CALL    ILPRT
  370.     DB    CLS,LF,LF,LF,0
  371. TELL1:    CALL    ILPRT
  372.     DB    CR,LF,LF,ESC,DIM,'Options are :',LF
  373.     DB    CR,LF,LF,TAB,ESC,UNDIM,'SET BAUD XXXX',ESC,DIM
  374.     DB    TAB,TAB,'sets the baud rate to xxxx (110 to 19200).'
  375.     DB    CR,LF,LF,TAB,ESC,UNDIM,'SET PARITY X ',ESC,DIM
  376.     DB    TAB,TAB,'sets the parity to X (N, E, or O).'
  377.     DB    CR,LF,LF,TAB,ESC,UNDIM,'SET BITS X   ',ESC,DIM
  378.     DB    TAB,TAB,'sets Data Bits to X (5 to 8).'
  379.     DB    CR,LF,LF,TAB,ESC,UNDIM,'SET STOP X   ',ESC,DIM
  380.     DB    TAB,TAB,'sets stop bits to x (1 or 2).'
  381.     DB    CR,LF,LF,TAB,ESC,UNDIM,'SET KEY  n "string"',ESC,DIM
  382.     DB    TAB,    'sets function key n (1 to 20) to "string".'
  383.     DB    CR,LF,LF,TAB,ESC,UNDIM,'SET DUMP xxxx yyyy',ESC,DIM
  384.     DB    TAB,    'dumps memory from xxxx to yyyy (0 to 0FFFFh)'
  385.     DB    CR,LF,LF,TAB,ESC,UNDIM,'SET ?',ESC,DIM
  386.     DB    TAB,TAB,TAB,'prints this help screen'
  387.     DB    ESC,UNDIM,ESC,'=',54,32,0 ; GoToXY 22,0
  388.     RET
  389. ;
  390. ;    Set baud to that specified
  391. STBAUD:    MVI    C, BDPARS
  392.     CALL    MEX        ; ASK FOR BAUD RATE CODE
  393.     JC    SHOWBD
  394.     CALL    SETBD
  395.     JC    SETERR        ; BAD CODE
  396. ;                ELSE FALL INTO SHOWBD
  397. ;
  398. SHOWBD:    CALL    ILPRT        ; PRINT CURRENT BAUD RATE
  399.     DB    LF,ESC,UNDIM,CR,LF,'Baud ',ESC,DIM,'Rate is now: ',ESC,UNDIM
  400.     DB    TAB,TAB,TAB,ESC,PRINV,INVERT,0
  401.     LDA    MSPEED
  402.     MVI    C, PRBAUD
  403.     CALL    MEX
  404.     CALL    ILPRT
  405.     DB    ESC,PRINV,UNINV,CR
  406.     DB    LF,ESC,UNDIM,CR,LF,'Parameters ',ESC,DIM,'are now: ',ESC,UNDIM
  407.     DB    TAB,TAB,TAB,ESC,PRINV,INVERT
  408. DATA    DB    AFLTDT
  409. PARITY    DB    AFLTPA
  410. STOPS    DB    AFLTST
  411.     DB    ESC,PRINV,UNINV,CR,LF,LF,0
  412.     RET
  413. ;
  414. ; TABLE    OF BAUDRATE PARAMETERS FOR 2661 I/O
  415. BD110    EQU    00F4H        ; FOR 110, 0
  416. BD300    EQU    00F5H        ; FOR 300, 
  417. BD1200    EQU    00F7H
  418. BD2400    EQU    00FBH
  419. BD9600    EQU    00FCH
  420. BD1920    EQU    00FEH
  421. ;
  422. BAUDTB:    DB    BD110, BD300, 0, 0, 0
  423.     DB    BD1200, BD2400, 0
  424.     DB    BD9600, BD1920
  425. ;
  426. SETBD:    CPI    10        ; LEGIT CODE (i.e. <10?)
  427.     JNC    PBX        ; CONTINUE IF SO
  428.     MOV    E, A        ; BAUD CODE SAVED IN E
  429.     MVI    D, 0
  430.     LXI    H, BAUDTB
  431.     DAD    D        ; HL NOW POINTS AT APPROPRIATE ENTRY
  432.     MOV    A, M        ; GET IT
  433.     ORA    A        ; ZERO? (means unsupported)
  434.     JZ    PBX        ; BLOW IF SO
  435.     STA    INITMOD1+1    ; SET PARAMETER
  436.     MOV    A, E
  437.     STA    INITMOD+1    ; SET BAUD RATE
  438.     CALL    INITMOD        ; GO DO IT
  439. ;
  440. PBX:    STC            ; ERROR, SET THE CARRY
  441.     RET
  442. ;
  443. SETPRM:    LDA    INITPM+1    ; SET UP SERIAL PORT PARAMETERS
  444.     ANA    C        ; CLEAR OLD VALUE
  445.     ORA    B        ; SET NEW VALUE
  446.     STA    INITPM+1    ; STORE IT
  447.     CALL    INITMOD        ; GO DO IT
  448.     JMP    SHOWBD        ; AND TELL 'EM ABOUT IT.
  449. ;
  450. SETPAR:    MVI    C,GNC        ; GET THE NEXT CHARACTER FROM STREAM
  451.     CALL    MEX
  452.     JC    SETERR
  453.     CPI    ' '
  454.     JZ    SETPAR
  455.     CPI    9        ; TAB
  456.     JZ    SETPAR
  457.     MVI    D, 'N'
  458.     LXI    B, 000CFH    ; ASSUME NO PARITY
  459.     CPI    'N'
  460.     JZ    PARSET
  461.     CPI    'n'
  462.     JZ    PARSET
  463.     MVI    D, 'E'
  464.     MVI    B, 030H        ; NOT NO PARITY, MAYBE EVEN
  465.     CPI    'E'
  466.     JZ    PARSET
  467.     CPI    'e'
  468.     JZ    PARSET
  469.     MVI    D, 'O'
  470.     MVI    B, 010H        ; NOT EVEN, LAST TRY ON ODD
  471.     CPI    'O'
  472.     JZ    PARSET
  473.     CPI    'o'
  474.     JNZ    SETERR        ; STRUCK OUT
  475. PARSET:    MOV    A,D
  476.     STA    PARITY
  477.     JMP    SETPRM
  478. ;
  479. SETBIT:    MVI    C, EVALA    ; CHANGE DATA BITS, START BY GETTING NUMBER
  480.     CALL    MEX
  481.     MOV    A, L
  482.     CPI    5
  483.     JC    SETERR
  484.     CPI    9
  485.     JNC    SETERR
  486.     ADI    '0'
  487.     STA    DATA
  488.     SUI    '5'        ; ADJUST TO 0-3
  489.     ANI    3
  490.     RLC
  491.     RLC            ; ADJUST TO 0,4,8,C
  492.     MOV    B, A        ; A IS OR VALUE
  493.     MVI    C, 0F3H        ; C IS CLEAR VALUE
  494.     JMP    SETPRM        ; AND DO IT.
  495. ;
  496. SETSTP:    MVI    C, EVALA    ; CHANGE STOP BITS, GET NUMBER FIRST
  497.     CALL    MEX
  498.     MOV    A, L
  499.     LXI    B, 0403FH    ; ASSUME 1 STOP BIT
  500.     CPI    1
  501.     JC    SETERR
  502.     JZ    STPSET
  503.     CPI    3
  504.     JNC    SETERR
  505.     MVI    B, 0C0H
  506. STPSET:    ADI    '0'
  507.     STA    STOPS
  508.     JMP    SETPRM
  509. ;
  510. KEYBUF:    DS    FNBUF        ; BUFFER FOR FUNCTION KEY STRINGS
  511. FNSTRT:    DB    ESC,'F'
  512. FNNUM:    DB    0        ; SELF MODIFYING
  513.     DB    '$'
  514. ;
  515. SETKEY:    MVI    C, EVALA
  516.     CALL    MEX        ; GET THE FUNCTION KEY NUMBER
  517.     MOV    A, L        ; INTO A
  518.     CPI    21        ; LEGAL?
  519.     JNC    SETERR        ; NO.
  520.     CPI    1        ; BIG ENOUGH?
  521.     JC    SETERR        ; NO.
  522.     ADI    0DFh        ; 1 ==> E0, 20 ==> F3
  523.     STA    FNNUM        ; SAVE IT
  524. SKLD:    CALL    GNCD
  525.     JNZ    SKLD
  526.     MVI    B, 0        ; ZERO THE COUNTER
  527.     LXI    H, KEYBUF    ; POINT HL TO BEGINNING OF BUFFER
  528. ;
  529. LKLD:    CALL    GNCD
  530.     JZ    DOKEY
  531.     CPI    '^'        ; CARAT?
  532.     CZ    GETCTL        ; YES, GO GET A CONTROL CHARACTER
  533.     MOV    M, A        ; STORE IT
  534.     INX    H
  535.     INR    B
  536.     MOV    A, B
  537.     CPI    FNBUF+1
  538.     JC    LKLD
  539.     JP    SETERR
  540. ;
  541. GETCTL:    CALL    GNCD        ; GET A CONTROL CHARACTER BY GETTING NEXT CHAR
  542.     SUI    40H        ; AND MAKING IT A CONTROL CHARACTER
  543.     CPI    '>'        ; IS IT A '~' ('~'-40H='>')
  544.     RNZ            ; NO, RETURN
  545.     MVI    A, '^'        ; YES, STUFF IN A '^'
  546.     RET
  547. ;
  548. DOKEY:    PUSH    B        ; SAVE THE LENGTH
  549.     LXI    D, FNSTRT
  550.     MVI    C, PRINT
  551.     CALL    MEX
  552.     POP    B
  553.     MOV    A, B
  554.     ORA    A
  555.     JZ    DKEY
  556.     LXI    H, KEYBUF
  557. DKLP:    MOV    A, M        ; GET THE CHARACTER
  558.     CALL    TYPE        ; SEND IT TO THE TERMINAL
  559.     INX    H
  560.     DCR    B
  561.     JNZ    DKLP
  562. DKEY:    LXI    D, FNNUM
  563.     MVI    C, PRINT
  564.     JMP    MEX
  565. ;
  566. GNCD:    PUSH    H
  567.     PUSH    B
  568.     MVI    C, GNC        ; ASK MEX FOR NEXT CHAR
  569.     CALL    MEX
  570.     POP    B
  571.     POP    H
  572.     JC    GNER        ; RUN TO ERROR IF CARRY
  573.     CPI    '"'        ; TERMINATOR?
  574.     RET            ; RETURN WITH ZFLAG SET
  575. ;
  576. GNER:    POP    H        ; KILL RETURN ADDRESS
  577.     JMP    SETERR        ; INFORM USER OF HIS ERROR
  578. ;
  579. ;
  580. DUMP:    MVI    C, EVALA    ; GET OFFSET
  581.     CALL    MEX
  582.     MOV    A,L
  583.     ANI    0F0H        ; 11110000
  584.     PUSH    H
  585.     MVI    C, EVALA
  586.     CALL    MEX
  587.     MOV    B, H
  588.     MOV    C, L        ; ENDING ADDRESS IN BC
  589.     POP    H
  590.     CALL    CPHLBC
  591.     JC    SETERR
  592. LLP:    PUSH    B
  593.     PUSH    H
  594.     PUSH    H
  595.     CALL    PADD        ; AND PRINT IT
  596.     POP    H
  597.     PUSH    H
  598.     MVI    B, 16        ; DO 16 BYTES
  599. HXLP:    MOV    A, M        ; LOAD NEXT BYTE
  600.     CALL    HEX        ; PRINT IT
  601.     MVI    A, ' '
  602.     CALL    TYPE
  603.     INX    H        ; POINT TO NEXT BYTE
  604.     DCR    B        ; DONE?
  605.     JNZ    HXLP        ; LOOP IF NOT
  606. ;
  607.     CALL    ILPRT        ; SET UP TO PRINT ASCII
  608.     DB    '    "',0
  609.     POP    H        ; POINT TO START AGAIN
  610.     MVI    B, 16
  611. ;
  612. ASCLP:    MOV    A, M        ; GET NEXT BYTE
  613.     CPI    20H
  614.     JC    CTLCHR
  615.     CPI    80H        ; THE DMV CAN PRINT A DELETE
  616.     JNC    HIASC
  617.     CALL    TYPE
  618.     JMP    NEXASC
  619. CTLCHR:    CALL    ILPRT
  620.     DB    ESC,DIM,NOTASC,ESC,UNDIM,0
  621.     JMP    NEXASC
  622. HIASC:    ANI    07FH        ; STRIP THE HIGH BIT
  623.     CPI    20H        ; LEGAL NOW?
  624.     JNC    HIPRT
  625.     MVI    A,NOTASC    ; NO, PRINT THE PERIOD
  626. HIPRT:    STA    HIP
  627.     CALL    ILPRT
  628.     DB    ESC,PRINV,INVERT
  629. HIP:    DB    0        ; WILL BE REPLACED
  630.     DB    ESC,PRINV,UNINV,0
  631. NEXASC:    INX    H
  632.     DCR    B
  633.     JNZ    ASCLP
  634.     CALL    ILPRT
  635.     DB    '"',0
  636. ;
  637.     POP    H
  638.     POP    B
  639.     LXI    D, 16
  640.     DAD    D
  641.     CALL    CPHLBC
  642.     JC    LLP
  643.     CALL    ILPRT
  644.     DB    CR,LF,LF,0
  645.     RET
  646. ;
  647. PADD:    CALL    ILPRT        ; PRINT A CRLF, AND THEN THE ADDRESS IN HL
  648.     DB    CR,LF,ESC,PRINV,INVERT,0
  649.     MOV    A,H
  650.     PUSH    H
  651.     CALL    HEX
  652.     POP    H
  653.     MOV    A,L
  654.     CALL    HEX
  655.     CALL    ILPRT
  656.     DB    ESC,PRINV,UNINV,':    ',0
  657.     RET
  658. ;
  659. ; compare hl with bc, return c-flag if hl<bc
  660. CPHLBC:    MOV    A, H
  661.     CMP    B
  662.     RC
  663.     MOV    A, L
  664.     CMP    C
  665.     RET
  666. ;
  667. ; Print the hex byte in A
  668. HEX:    MOV    D,A        ; Save A
  669.     RRC
  670.     RRC
  671.     RRC
  672.     RRC            ; Switch nybbles
  673.     CALL    PNYB        ; Print high nybble
  674.     MOV    A, D        ; Get it back, and fall into PNYB
  675. ;
  676. PNYB:    ANI    0FH        ; Kill high nybble
  677.     ADI    90H        ; This is out of the Osborne Mex overlay,
  678.     DAA            ; which author gives credit to Kelly Smith,
  679.     ACI    40H        ; who must be a very sick, albeit fast and 
  680.     DAA            ; efficient, person
  681.     JMP    TYPE        ; and print it(?)
  682. ;
  683. ILPRT:    MVI    C, ILP
  684.     JMP    MEX        ; INLINE PRINT CALL
  685. ;
  686. TYPE:    PUSH    H
  687.     PUSH    D
  688.     PUSH    B
  689.     MOV    E, A
  690.     MVI    C, CONOUT
  691.     CALL    MEX
  692.     POP    B
  693.     POP    D
  694.     POP    H
  695.     RET
  696. ;
  697. ;           (END OF INITMOD AND SET ROUTINES)
  698. ;=======================================================================
  699. ;
  700. ; NOTE:  MUST TERMINATE PRIOR TO 0B00H (with Smartmodem)
  701. ;                 0D00H (without Smartmodem).
  702. ;
  703.     END
  704.