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.

132 lines
3.1KB

  1. .PAG 'RS-232 RECEIVER'
  2. ; RSRCVR - NMI ROUTINE TO COLLECT
  3. ; DATA INTO BYTES
  4. ;
  5. ; RSR 8/18/80
  6. ;
  7. ; VARIABLES USED
  8. ; INBIT - INPUT BIT VALUE
  9. ; BITCI - BIT COUNT IN
  10. ; RINONE - FLAG FOR START BIT CHECK <>0 START BIT
  11. ; RIDATA - BYTE INPUT BUFFER
  12. ; RIPRTY - HOLDS BYTE INPUT PARITY
  13. ; RIBUF - INDIRECT POINTER TO DATA BUFFER
  14. ; RIDBE - INPUT BUFFER INDEX TO END
  15. ; RIDBS - INPUT BUFFER POINTER TO START
  16. ; IF RIDBE=RIDBS THEN INPUT BUFFER EMPTY
  17. ;
  18. RSRCVR LDX RINONE ;CHECK FOR START BIT
  19. BNE RSRTRT ;WAS START BIT
  20. ;
  21. DEC BITCI ;CHECK WHERE WE ARE IN INPUT...
  22. BEQ RSR030 ;HAVE A FULL BYTE
  23. BMI RSR020 ;GETTING STOP BITS
  24. ;
  25. ; CALC PARITY
  26. ;
  27. LDA INBIT ;GET DATA UP
  28. EOR RIPRTY ;CALC NEW PARITY
  29. STA RIPRTY
  30. ;
  31. ; SHIFT DATA BIT IN
  32. ;
  33. LSR INBIT ;IN BIT POS 0
  34. ROR RIDATA ;C INTO DATA
  35. ;
  36. ; EXIT
  37. ;
  38. RSREXT RTS
  39. .PAG 'RS-232 RECEIVER'
  40. ; HAVE STOP BIT, SO STORE IN BUFFER
  41. ;
  42. RSR018 DEC BITCI ;NO PARITY, DEC SO CHECK WORKS
  43. RSR020 LDA INBIT ;GET DATA...
  44. BEQ RSR060 ;...ZERO, AN ERROR?
  45. ;
  46. LDA M51CTR ;CHECK FOR CORRECT # OF STOP BITS
  47. ASL A ;CARRY TELL HOW MAY STOP BITS
  48. LDA #01
  49. ADC BITCI
  50. BNE RSREXT ;NO..EXIT
  51. ;
  52. ; RSRABL - ENABLE TO RECIEVE A BYTE
  53. ;
  54. RSRABL LDA #$90 ;ENABLE FLAG FOR NEXT BYTE
  55. STA D2ICR ;TOSS BAD/OLD NMI
  56. ORA ENABL ;MARK IN ENABLE REGISTER***********
  57. STA ENABL ;RE-ENABLED BY JMP OENABL
  58. STA RINONE ;FLAG FOR START BIT
  59. ;
  60. RSRSXT LDA #$02 ;DISABLE T2
  61. JMP OENABL ;FLIP-OFF ENABL***************
  62. .SKI 2
  63. ; RECIEVER START BIT CHECK
  64. ;
  65. RSRTRT LDA INBIT ;CHECK IF SPACE
  66. BNE RSRABL ;BAD...TRY AGAIN
  67. JMP PRTYP ;GO TO PARITY PATCH 901227-03
  68. ; STA RINONE ;GOOD...DISABLE FLAG
  69. ; RTS ;AND EXIT
  70. .SKI 4
  71. ;
  72. ; PUT DATA IN BUFFER (AT PARITY TIME)
  73. ;
  74. RSR030 LDY RIDBE ;GET END
  75. INY
  76. CPY RIDBS ;HAVE WE PASSED START?
  77. BEQ RECERR ;YES...ERROR
  78. ;
  79. STY RIDBE ;MOVE RIDBE FOWARD
  80. DEY
  81. ;
  82. LDA RIDATA ;GET BYTE BUFFER UP
  83. LDX BITNUM ;SHIFT UNTILL FULL BYTE
  84. RSR031 CPX #9 ;ALWAYS 8 BITS
  85. BEQ RSR032
  86. LSR A ;FILL WITH ZEROS
  87. INX
  88. BNE RSR031
  89. ;
  90. RSR032 STA (RIBUF)Y ;DATA TO PAGE BUFFER
  91. ;
  92. ; PARITY CHECKING
  93. ;
  94. LDA #$20 ;CHECK 6551 COMMAND REGISTER
  95. BIT M51CDR
  96. BEQ RSR018 ;NO PARITY BIT SO STOP BIT
  97. BMI RSREXT ;NO PARITY CHECK
  98. ;
  99. ; CHECK CALC PARITY
  100. ;
  101. LDA INBIT
  102. EOR RIPRTY ;PUT IN WITH PARITY
  103. BEQ RSR050 ;EVEN PARITY
  104. BVS RSREXT ;ODD...OKAY SO EXIT
  105. .BYT $2C ;SKIP TWO
  106. RSR050 BVC RSREXT ;EVEN...OKAY SO EXIT
  107. ;
  108. ; ERRORS REPORTED
  109. LDA #1 ;PARITY ERROR
  110. .BYT $2C
  111. RECERR LDA #$4 ;RECIEVER OVERRUN
  112. .BYT $2C
  113. BREAKE LDA #$80 ;BREAK DETECTED
  114. .BYT $2C
  115. FRAMEE LDA #$02 ;FRAME ERROR
  116. ERR232 ORA RSSTAT
  117. STA RSSTAT
  118. JMP RSRABL ;BAD EXIT SO HANG ##????????##
  119. ;
  120. ; CHECK FOR ERRORS
  121. ;
  122. RSR060 LDA RIDATA ;EXPECTING STOP...
  123. BNE FRAMEE ;FRAME ERROR
  124. BEQ BREAKE ;COULD BE A BREAK
  125. .END
  126. ; RSR - 8/21/80 ADD MODS
  127. ; RSR - 8/24/80 FIX ERRORS
  128. ; RSR - 8/27/80 FIX MAJOR ERRORS
  129. ; RSR - 8/30/80 FIX T2 ADJUST
  130. ; RSR - 12/11/81 MODIFY FOR VIC-40 I/O
  131. ; RSR - 3/11/82 FIX FOR BAD/OLD NMI'S