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