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 / BEEHIVE / COMMS / IMP-OV5C.LBR / I2ZB-2.AZM / I2ZB-2.ASM
Assembly Source File  |  2000-06-30  |  11KB  |  377 lines

  1.  
  2. ; I2ZB-2.ASM  -  ZORBA overlay for IMP  -  06/01/87
  3. ;
  4. ;        8251A I/O and 8254-2 baudrate generator
  5. ;
  6. ; You will want to look this file over carefully. There are a number of
  7. ; options that you can use to configure the program to suit your taste.
  8. ; This file adapts the Zorba computer to IMP.COM.
  9. ;
  10. ; Edit this file for your preferences then follow the "TO USE:" example
  11. ; shown below.
  12. ;
  13. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  14. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  15. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  16. ; (The ESC will automatically be typed with no CTL-character present.)
  17. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  18. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  19. ; looking at the function key table, typing CTL-Z in command mode, etc.
  20. ;
  21. ; Use the "SET" command to change the baudrate when desired.  The value
  22. ; at MSPEED controls the baudrate when the program is first called up.
  23. ;
  24. ;    TO USE: First edit this file filling in answers for your own
  25. ;        equipment.  Then assemble with ASM.COM or equivalent
  26. ;        assembler.  Then use MLOAD to merge into the main file:
  27. ;
  28. ;        MLOAD IMP.COM=IMP.COM,I2ZB-x.HEX
  29. ;
  30. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  31. ;
  32. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  33. ;        IMP245 to use it.            - Irv Hoff
  34. ;
  35. ; 10/27/85  Written for use with IMP        - Irv Hoff
  36. ;
  37. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  38. ;
  39. ;
  40. YES    EQU    0FFH
  41. NO    EQU    0
  42. ;
  43. ;
  44. ; Values shown are for a 8251A
  45. ;
  46. PORT    EQU    20H    ; Your base data port
  47. MDCTL1    EQU    PORT+1    ; Modem control port
  48. MDDATP    EQU    PORT    ; Modem data port
  49. MDRCV    EQU    02H    ; Modem receive ready bit
  50. MDSND    EQU    01H    ; Modem send ready bit
  51. MDTXE    EQU    05H    ; Modem send buffer empty, holding buffer empty
  52. COMMND    EQU    03H    ; 8254-2 Timer control/status
  53. BRPORT    EQU    00H    ; Baudrate generator timer 0 (port A)
  54. ;
  55. MDMODE    EQU    82H    ; Insures 8251 is out of mode with DTR high
  56. MDRSET    EQU    42H    ; Resets USART for additional commands
  57. MDSET1    EQU    4EH    ; 1 stop bit, no parity, 8 bits, 16x
  58. MDSET2    EQU    0CEH    ; 2 stop bits, no parity, 8 bits, 16x
  59. MDCOM    EQU    17H    ; Reset error flags, RCV, DTR, TX ready
  60. ;
  61. ;
  62. ;-----------------------------------------------------------------------
  63. ;
  64. ESC    EQU    '['-40H    ; ^[ = Escape
  65. BELL    EQU    'G'-40H    ; ^G = Bell character
  66. LF    EQU    'J'-40H    ; ^J = Linefeed
  67. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  68. CR    EQU    'M'-40H    ; ^M = Carriage return
  69. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  70. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  71. ;
  72. ;
  73. ;-----------------------------------------------------------------------
  74. ;
  75. ;
  76.     ORG    0100H
  77. ;
  78. ;
  79.     DS    3    ; Skip the data area below
  80. ;
  81. ;
  82. ; These routines and equates are at the beginning of the program so
  83. ; they can be patched by a monitor or overlay file without re-assembling
  84. ; the program.
  85. ;
  86. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  87.             ; 6=2400 7=4800 8=9600 9=19200 default
  88. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  89. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  90. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  91. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  92. RESVD1:     DB    NO    ; Reserved for special modems            108H
  93. RESVD2:     DB    NO    ; Reserved for special modems            109H
  94. ;
  95. ;
  96. CLEAR:     DB    'E'    ; Clear screen character (ESC not needed)    10AH
  97. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  98.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  99. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  100.             ;   default time to send character in ter-
  101.             ;   minal mode file transfer for slow BBS
  102. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  103.             ;   default time for extra wait after CRLF
  104.             ;   in terminal mode file transfer
  105. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  106. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (only for 'AT' mode)        10FH
  107. ;.....
  108. ;
  109. ;
  110. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  111.             ;   mode (normally added by remote echo)
  112. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  113. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  114. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  115. ;.....
  116. ;
  117. ;
  118. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  119. EXITCHR: DB    'E'    ; Exit character                115H
  120. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  121. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  122. LOGCHR:     DB    'L'    ; Send logon                    118H
  123. LSTCHR:     DB    'P'    ; Toggle printer                119H
  124. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  125. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  126. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  127. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  128. NODTR:     DB    NO    ; YES if no DTR and need ATH0 to disconnect    11EH
  129. ;.....
  130. ;
  131. ;
  132. ; Handles in/out ports for data and status
  133. ;
  134. I$MDCTL1: IN    MDCTL1        ; IN modem control port         11FH
  135.       RET            ;                    121H
  136.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  137. ;
  138. I$MDTXE:  IN    MDCTL1        ; (Needed for SIO or DART register 1    129H
  139.       RET            ;                    12BH
  140.       DB    0,0,0,0,0,0,0    ;                    12CH
  141. ;
  142. I$MDDATP: MVI    A,37H        ;                    133H
  143.       OUT    MDCTL1        ;                    135H
  144.       IN    MDDATP        ;                    137H
  145.       RET            ;                    139H
  146.       DB    0,0,0        ; Spares if needed            13AH
  147. ;
  148. O$MDDATP: OUT    MDDATP        ; OUT modem data port            13DH
  149.       RET            ;                    13EH
  150.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  151. ;.....
  152. ;
  153. ;
  154. A$MDRCV:  ANI    MDRCV        ;                    147H
  155.       RET            ;                    149H
  156. ;
  157. C$MDRCV:  CPI    MDRCV        ;                    14AH
  158.       RET            ;                    14CH
  159. ;
  160. A$MDSND:  ANI    MDSND        ;                    14DH
  161.       RET            ;                    14FH
  162. ;
  163. C$MDSND:  CPI    MDSND        ;                    150H
  164.       RET            ;                    152H
  165. ;
  166. A$MDTXE:  ANI    MDTXE        ;                    153H
  167.       RET            ;                    155H
  168. ;
  169. C$MDTXE:  CPI    MDTXE        ;                    156H
  170.       RET            ;                    158H
  171. ;.....
  172. ;
  173. ;
  174. ; Special exit vector, used by some computers to reset interrupt vectors
  175. ;
  176. J$EXITVEC:RET            ;                    159H
  177.       DB    0,0        ;                    15AH
  178. ;.....
  179. ;
  180. ;
  181. ; Jump vectors needed by each overlay
  182. ;
  183. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  184. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  185. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  186. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  187. ;.....
  188. ;
  189. ;
  190. ; "AT" command strings, can be replaced in individual overlay if needed
  191. ;
  192. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  193. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  194. ;
  195. ;
  196. ; Next fourteen lines should not be changed by user overlay as these go
  197. ; to specific locations in the main program, not in the overlay.
  198. ;
  199. ;
  200. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  201. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  202. J$DIAL:      DS    3        ; Start of dialing routine        174H
  203. J$DSCONT: DS    3        ; Terminates modem use            177H
  204. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  205. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  206. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  207. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  208. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  209. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  210. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  211. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  212. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  213. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  214. J$NEW2:      DB    0,0,0        ; For future needs            198H
  215. ;.....
  216. ;
  217. ;
  218. ; For 2400 bps auto-stepdown units
  219. ;
  220. MANUAL:      DB    0        ; For manual selection flag        19BH
  221. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  222. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  223. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  224. ;.....
  225. ;
  226. ;
  227. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  228. ;
  229. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  230.       DB    'Version for ZORBA  Computer' ;             1AAH
  231.       DB    CR,LF,0
  232.       RET
  233. ;.....
  234. ;
  235. ;
  236. ;-----------------------------------------------------------------------
  237. ;
  238. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  239. ;     end of your last routine should terminate by 0400H (601 bytes
  240. ;     available after start of SYSVER).
  241. ;
  242. ;-----------------------------------------------------------------------
  243. ;
  244. ; You can put in a message at this location which can be called up with
  245. ; (special character-L).  You can put in several lines.  End with a 0.
  246. ;
  247. LOGON:    DB    'Hello, This is a ZORBA computer',CR,LF,0
  248. ;
  249. ;-----------------------------------------------------------------------
  250. ;
  251. ; This routine sets a 300 ms break tone
  252. ;
  253. SENDBRK:
  254.     MVI    A,3FH        ; DTR normal, send break tone
  255.     JMP    GOODBYE+2
  256. ;.....
  257. ;
  258. ;
  259. ; This routine sets DTR low for 300 ms to disonnect the phone
  260. ;
  261. GOODBYE:
  262.     MVI    A,3DH        ; Send break, turn off DTR
  263.     OUT    MDCTL1        ; Send to status port
  264.     MVI    B,3        ; Delay 300 ms to hang up phone
  265.     CALL    J$TIMER
  266.     MVI    A,37H        ; Normal send/receive with DTR
  267.     OUT    MDCTL1        ; Send to status port
  268.     RET
  269. ;.....
  270. ;
  271. ;
  272. ; Sets 8251 to 8 bits, DTR, RCV and TX ready
  273. ;
  274. INITMOD:
  275.     MVI    A,MDMODE    ; Insure 8251 is out of mode
  276.     OUT    MDCTL1
  277.     XTHL            ; Small delay to complete command
  278.     XTHL
  279.     MVI    A,MDRSET    ; Reset the 8251A for new command
  280.     OUT    MDCTL1
  281.     XTHL            ; Small delay to complete command
  282.     XTHL
  283.     MVI    A,4EH        ; Set stop pulse, no parity 8 bits, x16
  284.     OUT    MDCTL1        ; (4EH = 1 stop, 0CEH = 2 stop)
  285.     XTHL            ; Small delay to complete command
  286.     XTHL
  287.     MVI    A,MDCOM        ; Error reset, RCV, DTR, TX ready
  288.     OUT    MDCTL1
  289.     XTHL            ; Small delay to complete command
  290.     XTHL
  291. ;
  292.     LDA    MSPEED        ; Get the selected value
  293.     CPI    1        ; 300 bps
  294.     JZ    OK300
  295.     CPI    5        ; 1200 bps
  296.     JZ    OK1200
  297.     CPI    6        ; 2400 bps
  298.     JZ    OK2400
  299.     CPI    8        ; 9600 bps
  300.     JZ    OK9600
  301.     JMP    STUPR1        ; Else ask what is wanted
  302. ;.....
  303. ;
  304. ;
  305. ; Set the baudrate
  306. ;
  307. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  308.     JNC    STUPR2
  309. ;
  310. STUPR1:    CALL    J$ILPRT
  311.     DB    'Input Baud Rate (300, 1200, 2400, 9600): ',0
  312.     LXI    D,BAUDBUF    ; Point to new input buffer
  313.     CALL    J$INBUF
  314.     CALL    J$CRLF
  315.     LXI    D,BAUDBUF+2
  316. ;
  317. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  318.     DB    '300',0
  319.     JNC    OK300        ; Go if got match
  320.     CALL    J$INLNCP
  321.     DB    '1200',0
  322.     JNC    OK1200
  323.     CALL    J$INLNCP
  324.     DB    '2400',0
  325.     JNC    OK2400
  326.     CALL    J$INLNCP
  327.     DB    '9600',0
  328.     JNC    OK9600
  329.     CALL    J$ILPRT        ; All matches failed, tell operator
  330.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  331.     JMP    STUPR1        ; Try again
  332. ;
  333. OK300:    MVI    A,1        ; MSPEED 300 baud value
  334.     LXI    H,BD300        ; Get 300 baud parameters in 'HL'
  335.     JMP    LOADBD        ; Go load them
  336. ;
  337. OK1200:    MVI    A,5
  338.     LXI    H,BD1200
  339.     JMP    LOADBD
  340. ;
  341. OK2400:    XRA    A        ; Reset the auto-stepdown flag
  342.     STA    MANUAL
  343.     MVI    A,6
  344.     LXI    H,BD2400
  345.     JMP    LOADBD
  346. ;
  347. OK9600:    MVI    A,8
  348.     LXI    H,BD9600
  349. ;
  350. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  351.     MVI    A,36H        ; Set to square wave
  352.     OUT    COMMND        ; Control port
  353.     MOV    A,L        ; Get least significant baudrate byte
  354.     OUT    BRPORT        ; LSP of baudrate
  355.     MOV    A,H        ; Get most significant baudrate byte
  356.     OUT    BRPORT        ; Store
  357.     RET
  358. ;.....
  359. ;
  360. ;
  361. ; Baudrate table
  362. ;
  363. BD300    EQU    1667        ; 300 baud
  364. BD1200    EQU    417        ; 1200 bps
  365. BD2400    EQU    208        ; 2400 bps
  366. BD9600    EQU    52        ; 9600 bps
  367. ;
  368. BAUDBUF:DB    10,0,0,0,0,0
  369.     DB    0,0,0,0,0,0
  370. ;
  371. ;                   end
  372. ;-----------------------------------------------------------------------
  373. ;
  374. ; NOTE: Must terminate by 0400H
  375. ;
  376.     END
  377.