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 / MODEM9.ARC / SYS.ASM < prev    next >
Assembly Source File  |  1991-02-02  |  13KB  |  539 lines

  1. ;        22.11.83
  2. ;        8251+8253 SYS.ASM
  3. ;
  4. ;Intel 8251/8253 support file for MODEM9.xx.
  5. ;
  6. ;Rename to SYS.ASM before assembly.
  7. ;
  8. ;This SYS file is presently configured for a 4 MHz M-D.
  9. ;
  10. ;    Three levels of installation and customization are possible.
  11. ;
  12. ;LEVEL 1. Minimum installation
  13. ;
  14. ;    The user who has ported I/O and who wants to get the program
  15. ;operating with minimum effort should:
  16. ;
  17. ;   1. change the equates for MODDATP, MODCTLP, MODSNDB,
  18. ;    MODSNDR, MODRCVB and MODRCVR (these six equates
  19. ;    are crucial to the program's operation)
  20. ;   2. change CLKRATE to the appropriate value for their system
  21. ;   3. set VERMSG, INIT, SETUP, DISCON, CARDET, EOSCLR, SCRNCLR
  22. ;    and STRGOK to FALSE
  23. ;
  24. ;LEVEL 2. Customized installation
  25. ;
  26. ;    The user who wants to refine the program to meet his/her
  27. ;communications needs can make simple changes in this file that
  28. ;require very little programming skill. As in LEVEL 1, INIT and
  29. ;SETUP, DISCON should be set to false. Customization involves one
  30. ;or more of the following changes:
  31. ;
  32. ;   1. In this file:
  33. ;    a) Set VERMSG to TRUE and enter the name of your computer
  34. ;       below location SYSVER
  35. ;    b) Set EOSCLR and SCRNCLR to TRUE and enter the clear-to-end-
  36. ;       of-screen and home-and-clear equates for your terminal
  37. ;       at the appropriate locations below
  38. ;
  39. ;   2. In the file START:
  40. ;       a) Set the TRUE/FALSE statements in the lookup table which
  41. ;       begins with BAKUPBYTE and ends with EOFSEND
  42. ;       b) Change the control characters that are used for local commands,
  43. ;       this sequence starts with EXITCHR and ends with EXTCHR
  44. ;    c) Set STROK to TRUE and enter up to ten strings at location
  45. ;       STRINGS. These strings can be logon sequences or frequently
  46. ;       used commands that are sent to a remote computer
  47. ;
  48. ;   3. Change the phone numbers given in the file NUMLIB to systems
  49. ;    you normally use
  50. ;
  51. ;LEVEL 3. Modem control
  52. ;
  53. ;    The user who wants the ability to initialize his modem port
  54. ;should set INIT to true and write an initialization routine. If on-line
  55. ;modem port control is desired and INIT is TRUE, SETUP should be set to
  56. ;TRUE and a reinitialization sequence written in. If it is possible to
  57. ;disconnect your modem from the telephone line under program control then
  58. ;DISCON may be set to true and an appropriate sequence written at location
  59. ;DISCR. If you know how to test a modem port for carrier detect set CARDET
  60. ;to true and modify the routine at location DETCAR. The routines require
  61. ;some programming skill; the second routine is more complex than the first,
  62. ;third and fourth.
  63. ;
  64. ;
  65. VERMSG    EQU    TRUE         ;change to TRUE if you have given at
  66.                 ;location SYSVER the name of the
  67.                 ;system for which MODEM9 has been
  68.                 ;configured.
  69. ;
  70. INIT    EQU    TRUE         ;change to TRUE if you are using a
  71.                 ;routine at location INITMOD to
  72.                 ;initialize your modem port on MODEM9
  73.                 ;execution.
  74. ;
  75. SETUP    EQU    TRUE         ;change to TRUE if you are using a
  76.                 ;routine at location SETUPR to change
  77.                 ;baud rate, etc.
  78.                 
  79. ;
  80. DISCON    EQU    FALSE        ;change to TRUE if you have written a
  81.                 ;routine at location DISCR to disconnect
  82.                 ;the modem from the telephone line.
  83. ;
  84. CARDET    EQU    FALSE        ;change to TRUE if you have written a
  85.                 ;routine at location DETCAR to give carrier
  86.                 ;detect status.
  87. ;
  88. EOSCLR    EQU    TRUE        ;change to TRUE if you have defined the
  89.                 ;clear to end of screen sequence for
  90.                 ;your terminal. Clear to end of screen is
  91.                 ;used on returning from terminal mode to
  92.                 ;keep the screen from becoming jumbled if
  93.                 ;the remote can positon your cursor.
  94. ;
  95. SCRNCLR    EQU    TRUE        ;change to TRUE if you have defined the
  96.                 ;home cursor and clear screen sequence
  97.                 ;for you terminal.
  98. ;
  99. MICROD    EQU    TRUE        ;Micro-Decision
  100. ;
  101. ;THE FOLLOWING MUST BE CHANGED FOR YOUR MICRO IF YOU DON'T HAVE
  102. ; A MICRO-DECISION.
  103. MODDATP    EQU    0FEh        ;data port for MD  (8251A)
  104. MODCTLP    EQU    MODDATP+1    ;modem status port for MD 
  105. MODSNDB    EQU    01h        ;bit to test for ready to send
  106. MODSNDR    EQU    MODSNDB        ;change to 0 if bit is 0 when
  107.                 ;...ready to send
  108. MODRCVB    EQU    02        ;bit to test for received data
  109. MODRCVR    EQU    MODRCVB        ;change to 0 if bit is 0 when
  110.                 ;data received
  111. ;
  112. CLKRATE    EQU    4        ;clock speed in MHz, 8 MHz maximum
  113. ;
  114. ;CHANGE CLR1, CLR2, CLR3, AND CLR4 TO THE APPROPRIATE VALUES FOR
  115. ;YOUR TERMINAL IF EOSCLR IS TRUE
  116. ;FREEDOM 100 VALUES:-
  117.     IF    EOSCLR
  118. CLR1    EQU    ESC        ;Clear to end
  119. CLR2    EQU    'y'        ;of screen sequence
  120. CLR3    EQU    0        ;the unused bytes MUST be 0
  121. CLR4    EQU    0
  122.     ENDIF    ;EOSCLR
  123. ;
  124. ;CHANGE SCLR1, SCLR2, SCLR3, AND SCLR4 TO THE APPROPRIATE VALUES FOR
  125. ;YOUR TERMINAL IF SCRNCLR IS TRUE
  126.     IF    SCRNCLR
  127. SCLR1    EQU    ESC        ;Home cursor
  128. SCLR2    EQU    '*'        ;and clear screen sequence
  129. SCLR3    EQU    0        ;the unused bytes MUST be 0
  130. SCLR4    EQU    0
  131.     ENDIF    ;SCRNCLR
  132. ;
  133. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  134. ;
  135.         ORG    140H
  136. ;
  137. CLREOS:        CALL    ILPRT
  138. ;
  139.     IF    EOSCLR
  140.         DB    CLR1,CLR2,CLR3,CLR4,0
  141.     ENDIF    ;EOSCLR
  142. ;
  143.         RET
  144. ;
  145.         DS    CLREOS-$+16
  146. ;
  147. CLRSCRN:    CALL    ILPRT
  148. ;
  149.     IF    SCRNCLR
  150.         DB    SCLR1,SCLR2,SCLR3,SCLR4,0
  151.     ENDIF    ;SCRNCLR
  152. ;
  153.         RET
  154. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  155. ;
  156.     ORG    160H
  157. ;
  158. IN$MODCTLP:    IN    MODCTLP ! RET     ;in modem control port
  159.         DS    IN$MODCTLP-$+16  ;extra space
  160. OUT$MODDATP:    OUT    MODDATP ! RET     ;out modem data port
  161.         DS    OUT$MODDATP-$+16 ;extra space
  162. IN$MODDATP:    IN    MODDATP ! RET     ;in modem data port
  163.         DS    IN$MODDATP-$+16  ;extra space
  164. ANI$MODSNDB:    ANI    MODSNDB ! RET     ;bit to test for send ready
  165.         DS    ANI$MODSNDB-$+16 ;extra space
  166. CPI$MODSNDR:    CPI    MODSNDR ! RET     ;value of send bit when ready
  167.         DS    CPI$MODSNDR-$+16 ;extra space
  168. ANI$MODRCVB:    ANI    MODRCVB ! RET     ;bit to test for receive ready
  169.         DS    ANI$MODRCVB-$+16 ;extra space
  170. CPI$MODRCVR:    CPI    MODRCVR ! RET     ;value of receive bit when ready
  171.         DS    CPI$MODRCVR-$+16 ;extra space
  172. ;
  173.         ORG    208H
  174. ;
  175. SYSVER:
  176. ;
  177. ;This is where the message goes giving the system for
  178. ;which MODEM9 has been customized.
  179. ;
  180.     CALL    ILPRT
  181.     DB    'Version for: Micro-Decision',CR,LF,0
  182.     RET
  183. ;
  184. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  185. ;
  186.         ORG    6D0H
  187. ;
  188. ;The following are used in setting up the 8251 
  189. ;No need to change for another micro if INIT and SETUP are FALSE.
  190. ;
  191. ;
  192. ;control bytes
  193. WORDLEN        EQU    4Eh        ;8 bits,no parity,1 stop bit
  194. DTR        EQU    37h        ;turn on DTR,RTS,Error-reset,RxEn,TxEn
  195. MODRESET    EQU    0C0h        ;bit 6
  196. ;
  197. ;
  198. ;The following is used to initialize the MD on execution of MODEM9. 
  199. ;
  200. CH2DIV    EQU    0F2h        ; Micro-Decision
  201. CTCSEL    EQU    0F3h        ; CTC channel 2
  202. CTCch2    EQU    0BEh        ; mode 3
  203. ;
  204.     IF    INIT
  205. ;
  206. INITMOD:            ; set baudrate in CTC ch 2
  207.     mvi    a,1        ; 300 baud
  208.     sta    mspeed        ; keep this for standardization
  209. SETBD:
  210.     MVI    A,CTCch2 
  211.     OUT    CTCSEL        ; F3
  212.     LDA    mspeed        ; get baud rate
  213.     MOV    C,A
  214. ;
  215. GETVAL:                ; set HL to point to divisor for baud rate
  216.     LXI    H,BAUDTBL    ; point to base of table
  217.     MVI    B,0
  218.     DAD    B
  219.     DAD    B        ; HL now points to req'd divisor
  220. ;
  221. SETBAUD:            ; output divisor bytes to CTC
  222.     MOV    A,M        ; get low byte
  223.     OUT    CH2DIV        ; output it
  224.     INX    H        ; point to high byte
  225.     MOV    A,M        ; get it
  226.     OUT    CH2DIV        ; output it
  227. ;
  228. PARM:    MVI    A,MODRESET    ; software reset of modem
  229.     OUT    MODCTLP        ; FF
  230.     LDA    MODEWORD    ; current settings
  231.     OUT    MODCTLP
  232.     MVI    A,DTR        ; command word
  233.     OUT    MODCTLP
  234.     RET
  235. ;
  236. BAUDTBL:            ; from SETUP.COM
  237.     DW    1136        ;110
  238.     DW     417        ;300
  239.     DW     208        ;600
  240.     DW     104        ;1200
  241.     DW      52        ;2400
  242.     DW      26        ;4800
  243.     DW      13        ;9600
  244. ;
  245.     ENDIF    ;INIT
  246. ;
  247. ;
  248.     IF    NOT INIT
  249. INITMOD: RET
  250.     ENDIF    ;NOT INIT
  251. ;
  252. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  253. ;
  254.     ORG    710H
  255. ;
  256. ;The following routine changes the baud rate, stop bits and parity 
  257. ;from the command level. Write your own routine here to change
  258. ;your modem parameters. Note the routine MUST modify the parameters
  259. ;used by the INITMOD routine.
  260. ;
  261. ;The following are parameters/masks used in setting word length
  262. ;stop bits and parity for the 8251.
  263. ;
  264. MSKST    EQU    11000000b    ;stop bit mask
  265. MSKPA    EQU    00110000b    ;mask for first two parity bits
  266. MSKWD    EQU    00001100b    ; word length mask
  267. ;
  268. SEVEN    EQU    00001000b    ;seven bit word
  269. EIGHT    EQU    00001100b    ;eight bit word
  270. ;
  271. ONE    EQU    01000000b    ;one stop bit
  272. TWO    EQU    11000000b    ;two stop bits
  273. ;
  274. NONE    EQU    00000000b    ;no parity
  275. ODD    EQU    00010000b    ;odd parity
  276. EVEN    EQU    00110000b    ;even parity
  277. ;
  278. X16    EQU    00000010b    ;X16
  279. ;
  280.     IF    INIT AND SETUP
  281. ;
  282. SETUPR:
  283.     PUSH    H
  284.     CALL    CLRTST
  285.     CALL    ILPRT
  286.     DB    '                 UART/Modem Control',CR,LF,LF,LF
  287.     DB    'Current settings -',CR,LF,0
  288.     CALL    SETTIM2
  289.     CALL    GIVEPRM
  290.     CALL    ILPRT
  291.     DB    CR,LF
  292.     DB    'Enter choices below - <CR> for no change',CR,LF,0
  293. AGAIN:    LXI    D,BAUDBUF    ;point to input buffer for ILCOMP
  294.     CALL    ILPRT
  295.     DB    'Baud Rate (110, 300, 600, 1200, 2400, 4800, 9600): ',0
  296.     CALL    INBUFF
  297.     LXI    D,BAUDBUF+2
  298.     CALL    ILCOMP    ;compare BAUDBUF+2 with characters below
  299.     DB    '110',0
  300.     MVI    A,0
  301.     JNC    OK        ;go if got match
  302.     CALL    ILCOMP
  303.     DB    '300',0
  304.     MVI    A,1
  305.     JNC    OK
  306.     CALL    ILCOMP
  307.     DB    '600',0
  308.     MVI    A,2
  309.     JNC    OK
  310.     CALL    ILCOMP
  311.     DB    '1200',0
  312.     MVI    A,3
  313.     JNC    OK
  314.     CALL    ILCOMP
  315.     DB    '2400',0
  316.     MVI    A,4
  317.     JNC    OK
  318.     CALL    ILCOMP
  319.     DB    '4800',0
  320.     MVI    A,5
  321.     JNC    OK
  322.     CALL    ILCOMP
  323.     DB    '9600',0
  324.     MVI    A,6
  325.     JNC    OK
  326.     CALL    ILCOMP
  327.     DB    ' ',0
  328.     JNC    AGAIN2
  329.     CALL    WRONG
  330.     JMP    AGAIN        ;try again
  331. ;
  332. OK:    STA    INITMOD+1
  333.     STA    MSPEED
  334.     call    INITMOD
  335. ;
  336. AGAIN2:    LXI    D,BAUDBUF    ;point to input buffer for ILCOMP
  337.     CALL    ILPRT
  338.     DB    'Word Length (7, 8): ',0
  339.     CALL    INBUFF
  340.     LXI    D,BAUDBUF+2
  341.     CALL    ILCOMP    ;compare BAUDBUF+2 with characters below
  342.     DB    '7',0
  343.     MVI    A,SEVEN
  344.     JNC    OK2
  345.     CALL    ILCOMP
  346.     DB    '8',0
  347.     MVI    A,EIGHT
  348.     JNC    OK2
  349.     CALL    ILCOMP
  350.     DB    ' ',0
  351.     JNC    AGAIN3
  352.     CALL    WRONG
  353.     JMP    AGAIN2
  354. ;
  355. OK2:    STA    WDLEN
  356. ;
  357. AGAIN3:    LXI    D,BAUDBUF    ;point to input buffer for ILCOMP
  358.     CALL    ILPRT
  359.     DB    'Stop Bits (1, 2): ',0
  360.     CALL    INBUFF
  361.     LXI    D,BAUDBUF+2
  362.     CALL    ILCOMP    ;compare BAUDBUF+2 with characters below
  363.     DB    '1',0
  364.     MVI    A,ONE
  365.     JNC    OK3
  366.     CALL    ILCOMP
  367.     DB    '2',0
  368.     MVI    A,TWO
  369.     JNC    OK3
  370.     CALL    ILCOMP
  371.     DB    ' ',0
  372.     JNC    AGAIN4
  373.     CALL    WRONG
  374.     JMP    AGAIN3
  375. ;
  376. OK3:    STA    STPLN
  377. ;
  378. AGAIN4:    LXI    D,BAUDBUF    ;point to input buffer for ILCOMP
  379.     CALL    ILPRT
  380.     DB    'Parity (None, Even, Odd): ',0
  381.     CALL    INBUFF
  382.     LXI    D,BAUDBUF+2
  383.     CALL    ILCOMP    ;compare BAUDBUF+2 with characters below
  384.     DB    'NONE',0
  385.     MVI    A,NONE
  386.     JNC    OK4        ;go if got match
  387.     CALL    ILCOMP
  388.     DB    'EVEN',0
  389.     MVI    A,EVEN
  390.     JNC    OK4
  391.     CALL    ILCOMP
  392.     DB    'ODD',0
  393.     MVI    A,ODD
  394.     JNC    OK4
  395.     CALL    ILCOMP
  396.     DB    ' ',0
  397.     JNC    GOSET
  398.     CALL    WRONG
  399.     JMP    AGAIN4        ;try again
  400. ;
  401. OK4:    STA    PARIT
  402. ;
  403. GOSET:    LDA    WDLEN
  404.     MOV    B,A
  405.     LDA    STPLN
  406.     ADD    B
  407.     MOV    B,A
  408.     LDA    PARIT
  409.     ADD    B
  410.     MOV    B,A
  411.     LDA    SYNC        ;x16 clock for 8251A
  412.     ADD    B
  413.     STA    MODEWORD
  414.     CALL    ILPRT
  415.     DB    CR,LF
  416.     DB    'New settings -',CR,LF,0
  417.     CALL    SETTIM2
  418.     CALL    GIVEPRM
  419.     POP    H
  420.     JMP    INITMOD        ;reset 8251
  421. ;
  422. GIVEPRM:
  423.     CALL    GETPRM
  424.     CALL    ILPRT
  425.     DB    'Word length      : ',0
  426.     LDA    WDLEN
  427.     CPI    SEVEN
  428.     JNZ    NOTSEV
  429.     CALL    ILPRT
  430.     DB    '7',CR,LF,0
  431.     JMP    GIVEST
  432. NOTSEV:    CALL    ILPRT
  433.     DB    '8',CR,LF,0
  434. GIVEST:    CALL    ILPRT
  435.     DB    'Stop bits        : ',0
  436.     LDA    STPLN
  437.     CPI    ONE
  438.     JNZ    NOTONE
  439.     CALL    ILPRT
  440.     DB    '1',CR,LF,0
  441.     JMP    GIVEPA
  442. NOTONE:    CALL    ILPRT
  443.     DB    '2',CR,LF,0
  444. GIVEPA:    CALL    ILPRT
  445.     DB    'Parity           : ',0
  446.     LDA    PARIT
  447.     CPI    NONE
  448.     JNZ    NOTNON
  449.     CALL    ILPRT
  450.     DB    'None',CR,LF,0
  451.     RET
  452. NOTNON:    LDA    PARIT
  453.     CPI    ODD
  454.     JNZ    NOTODD
  455.     CALL    ILPRT
  456.     DB    'Odd',CR,LF,0
  457.     RET
  458. NOTODD:    CALL    ILPRT
  459.     DB    'Even',CR,LF,0
  460.     RET
  461. ;
  462. GETPRM:    LDA    MODEWORD    ;get present word length, stop bit and parity
  463.     MOV    B,A        ;save them
  464.     ANI    MSKWD    
  465.     STA    WDLEN
  466.     MOV    A,B
  467.     ANI    MSKST
  468.     STA    STPLN
  469.     MOV    A,B
  470.     ANI    MSKPA
  471.     STA    PARIT
  472.     RET
  473. ;
  474. WRONG:    CALL    ILPRT    ;all matches failed - tell operator
  475.     DB    '++ Incorrect entry ++',CR,LF,BELL,0
  476.     RET
  477. ;
  478. ;
  479. WDLEN:    DB    EIGHT
  480. STPLN:    DB    ONE
  481. PARIT:    DB    NONE
  482. SYNC:    db    X16
  483. MODEWORD:
  484.     DB    WORDLEN
  485. ;
  486. BAUDBUF:
  487.     DB    10,0
  488.     DS    10
  489. ;
  490.     ENDIF    ;INIT AND SETUP
  491. ;
  492.     IF    NOT (INIT AND SETUP)
  493. SETUPR:    RET
  494. GIVEPRM    RET
  495. ENDIF    ;NOT INIT AND SETUP
  496. ;
  497. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  498. ;
  499.     ORG    0A70H
  500. ;
  501. ;For MODEMs which disconnect from the telephone line when data terminal
  502. ;ready (DTR) drops, write a routine to disconnect.
  503. ;
  504. ;
  505.     IF    DISCON
  506. DISCR:    ;write your routine here
  507.     RET
  508.     ENDIF    ;DISCON
  509. ;
  510.     IF    NOT DISCON
  511. DISCR:    RET
  512.     ENDIF    ;NOT DISCON
  513. ;
  514. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  515.     ORG    0A90H
  516. ;
  517. ;
  518. ;CTS    EQU    10H        ;CLEAR TO SEND
  519. ;RLSD    EQU    80H        ;RECEIVED LINE SIGNAL (CARRIER) DETECT
  520. ;
  521.     IF    CARDET
  522. ;
  523. DETCAR:    ; write your routine here
  524.     RET
  525. ;
  526.     ENDIF    ;CARDET
  527. ;
  528. ;
  529.     IF    NOT CARDET
  530. ;
  531.     DETCAR    RET
  532. ;
  533.     ENDIF    ;CARDET
  534. ;
  535. ;
  536.     LINK    MAIN
  537. ;
  538.  
  539.