You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
3.6KB

  1. .PAGE 'RS-232 TRANSMITT'
  2. ; RSTRAB - ENTRY FOR NMI CONTINUE ROUTINE
  3. ; RSTBGN - ENTRY FOR START TRANSMITTER
  4. ;
  5. ; RSR - 8/18/80
  6. ;
  7. ; VARIABLES USED
  8. ; BITTS - # OF BITS TO BE SENT (<>0 NOT DONE)
  9. ; NXTBIT - BYTE CONTAINS NEXT BIT TO BE SENT
  10. ; ROPRTY - BYTE CONTAINS PARITY BIT CALCULATED
  11. ; RODATA - STORES DATA BYTE CURRENTLY BEING TRANSMITTED
  12. ; RODBS - OUTPUT BUFFER INDEX START
  13. ; RODBE - OUTPUT BUFFER INDEX END
  14. ; IF RODBS=RODBE THEN BUFFER EMPTY
  15. ; ROBUF - INDIRECT POINTER TO DATA BUFFER
  16. ; RSSTAT - RS-232 STATUS BYTE
  17. ;
  18. ; XXX US - NORMAL BIT PATH
  19. ; XXX US - WORST CASE PARITY BIT PATH
  20. ; XXX US - STOP BIT PATH
  21. ; XXX US - START BIT PATH
  22. ;
  23. RSTRAB LDA BITTS ;CHECK FOR PLACE IN BYTE...
  24. BEQ RSTBGN ;...DONE, =0 START NEXT
  25. ;
  26. BMI RST050 ;...DOING STOP BITS
  27. ;
  28. LSR RODATA ;SHIFT DATA INTO CARRY
  29. LDX #00 ;PREPARE FOR A ZERO
  30. BCC RST005 ;YES...A ZERO
  31. DEX ;NO...MAKE AN $FF
  32. RST005 TXA ;READY TO SEND
  33. ;
  34. EOR ROPRTY ;CALC INTO PARITY
  35. STA ROPRTY
  36. ;
  37. DEC BITTS ;BIT COUNT DOWN
  38. BEQ RST010 ;WANT A PARITY INSTEAD
  39. ;
  40. RSTEXT TXA ;CALC BIT WHOLE TO SEND
  41. AND #$20 ;GOES OUT CB2
  42. STA NXTBIT
  43. RTS
  44. .PAGE 'RS-232 TRANSMITT'
  45. ; CALCULATE PARITY
  46. ; NXTBIT =0 UPON ENTRY
  47. ;
  48. RST010 LDA #$20 ;CHECK 6551 REG BITS
  49. BIT M51CDR
  50. BEQ RSPNO ;...NO PARITY, SEND A STOP
  51. BMI RST040 ;...NOT REAL PARITY
  52. BVS RST030 ;...EVEN PARITY
  53. ;
  54. LDA ROPRTY ;CALC ODD PARITY
  55. BNE RSPEXT ;CORRECT GUESS
  56. ;
  57. RSWEXT DEX ;WRONG GUESS...ITS A ONE
  58. ;
  59. RSPEXT DEC BITTS ;ONE STOP BIT ALWAYS
  60. LDA M51CTR ;CHECK # OF STOP BITS
  61. BPL RSTEXT ;...ONE
  62. DEC BITTS ;...TWO
  63. BNE RSTEXT ;JUMP
  64. ;
  65. RSPNO ;LINE TO SEND CANNOT BE PB0
  66. INC BITTS ;COUNTS AS ONE STOP BIT
  67. BNE RSWEXT ;JUMP TO FLIP TO ONE
  68. ;
  69. RST030 LDA ROPRTY ;EVEN PARITY
  70. BEQ RSPEXT ;CORRECT GUESS...EXIT
  71. BNE RSWEXT ;WRONG...FLIP AND EXIT
  72. ;
  73. RST040 BVS RSPEXT ;WANTED SPACE
  74. BVC RSWEXT ; WANTED MARK
  75. .SKI 3
  76. ; STOP BITS
  77. ;
  78. RST050 INC BITTS ;STOP BIT COUNT TOWARDS ZERO
  79. LDX #$FF ;SEND STOP BIT
  80. BNE RSTEXT ;JUMP TO EXIT
  81. ;
  82. .PAG 'RS-232 TRANSMITT'
  83. ; RSTBGN - ENTRY TO START BYTE TRANS
  84. ;
  85. RSTBGN LDA M51CDR ;CHECK FOR 3/X LINE
  86. LSR A
  87. BCC RST060 ;3 LINE...NO CHECK
  88. BIT D2ORB ;CHECK FOR...
  89. BPL DSRERR ;...DSR ERROR
  90. BVC CTSERR ;...CTS ERROR
  91. ;
  92. ; SET UP TO SEND NEXT BYTE
  93. ;
  94. RST060 LDA #0
  95. STA ROPRTY ;ZERO PARITY
  96. STA NXTBIT ;SEND START BIT
  97. LDX BITNUM ;GET # OF BITS
  98. RST070 STX BITTS ;BITTS=#OF BITTS+1
  99. ;
  100. RST080 LDY RODBS ;CHECK BUFFER POINTERS
  101. CPY RODBE
  102. BEQ RSODNE ;ALL DONE...
  103. ;
  104. LDA (ROBUF)Y ;GET DATA...
  105. STA RODATA ;...INTO BYTE BUFFER
  106. INC RODBS
  107. ;
  108. ; CARRIAGE RETURN DELAY
  109. ;
  110. CMP #$13 ;DELAY ON C/R
  111. BNE RST090 ;NONE
  112. LDX M51ADJ ;M51CRD
  113. BEQ RST090
  114. LDY #$40 ;TURN OF T1
  115. STY D1IER
  116. ;
  117. RST085 LDY #0 ;DELAY LOOP
  118. JSR TOARTS
  119. JSR TOARTS
  120. DEY
  121. BNE RST085
  122. DEX
  123. BNE RST085
  124. LDX #$C0 ;TURN T1 BACK ON
  125. STX D1IER
  126. ;
  127. RST090
  128. TOARTS RTS
  129. .SKI 3
  130. ; SET ERRORS
  131. ;
  132. DSRERR LDA #$40 ;DSR GONE ERROR
  133. .BYT $2C
  134. CTSERR LDA #$10 ;CTS GONE ERROR
  135. ORA RSSTAT
  136. STA RSSTAT
  137. ;
  138. ; ERRORS TURN OFF T1
  139. ;
  140. RSODNE LDA #$40 ;KILL T1 NMI
  141. STA D1IER
  142. RTS
  143. .SKI 3
  144. ; BITCNT - CAL # OF BITS TO BE SENT
  145. ; RETURNS #OF BITS+1
  146. ;
  147. BITCNT LDX #9 ;CALC WORD LENGTH
  148. LDA #$20
  149. BIT M51CTR
  150. BEQ BIT010
  151. DEX ;BIT 5 HIGH IS A 7 OR 5
  152. BIT010 BVC BIT020
  153. DEX ;BIT 6 HIGH IS A 6 OR 5
  154. DEX
  155. BIT020 RTS
  156. .END
  157. ; RSR 8/24/80 CORRECT SOME MISTAKES
  158. ; RSR 8/27/80 CHANGE BITNUM BASE TO #BITS+1
  159. ; RSR 9/23/80 ADD C/R DELAY