-
Notifications
You must be signed in to change notification settings - Fork 0
/
encoder.lst
418 lines (387 loc) · 22.3 KB
/
encoder.lst
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
MPASM 5.46 ENCODER.ASM 11-27-2015 17:22:53 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;label assignments to memories
00002
00000002 00003 pcl equ 02h
00000003 00004 status equ 03h
00000005 00005 porta equ 05h
00000006 00006 portb equ 06h
0000000B 00007 interrupt equ 0bh
00000001 00008 optionreg equ 01h
00000001 00009 tmr0 equ 01h
0000001F 00010 CMCON equ 1fh
00011 cblock 20h
00000020 00012 pin1; input pin for portb
00000021 00013 pin2; input pin for portb
00000022 00014 pin3; input pin for portb
00000023 00015 pin4; input pin for portb
00000024 00016 pin5; input pin for portb
00000025 00017 pin6; input pin for portb
00000026 00018 pin7; input pin for portb
00000027 00019 pin0; input pin for portb
00000028 00020 work; temporal register to hold the byte of the signal to be encoded during encoding
00000029 00021 encode; equ 15h
0000002A 00022 bitposition ;equ 16h
0000002B 00023 pointer ;pointer to be used for lookup tables
0000002C 00024 counter ;counter for the timer0
0000002D 00025 decode ;contains the decoded signal
00026 endc
00027
0000 3007 00028 movlw 0x07 ;Turn comparators off and
0001 009F 00029 movwf CMCON
0002 1683 00030 bsf status,5 ;switches to bank1
0003 3000 00031 movlw 00h
0004 0086 00032 movwf portb ;sets input and output for portb
0005 30FF 00033 movlw 0ffh
0006 0085 00034 movwf porta ;sets input and output porta
0007 30D2 00035 movlw b'11010010'
0008 0081 00036 movwf optionreg ;sets the optionreg register which includes prescaler
0009 1283 00037 bcf status,5 ;switches to bank0
000A 3000 00038 movlw 00h
000B 008B 00039 movwf interrupt ;clears the interrupt register
000C 168B 00040 bsf interrupt,5 ;sets the TMR0IE
000D 1283 00041 bcf status,5
00042 ;initialization of variables
000E 3000 00043 movlw 00h
000F 00AB 00044 movwf pointer ;sets the pointer for look up table to zero
0010 00A9 00045 movwf encode ;sets the register with the encoded signal to zero
0011 3001 00046 movlw b'00000001'
0012 0086 00047 movwf portb
0013 3000 00048 movlw b'00000000' ;initializes portb with zero
0014 00A7 00049 movwf pin0 ;assigns bytes to pin0
0015 3001 00050 movlw b'00000001'
0016 00A0 00051 movwf pin1 ;assigns bytes to pin1
0017 3002 00052 movlw b'00000010'
0018 00A1 00053 movwf pin2 ;assigns bytes to pin2
MPASM 5.46 ENCODER.ASM 11-27-2015 17:22:53 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0019 3003 00054 movlw b'00000011'
001A 00A2 00055 movwf pin3 ;assigns bytes to pin3
001B 3000 00056 movlw 00h
001C 00AD 00057 movwf decode ;initializes the decoding register with zeros
00058
001D 00059 start:
001D 1406 00060 bsf portb,0
001E 3000 00061 movlw 00h
001F 00AB 00062 movwf pointer ;initializes pointer register with zeros
0020 00A9 00063 movwf encode ;initializes encode register with zeros
0021 00AD 00064 movwf decode ;initializes decode register with zeros
0022 1805 00065 btfsc porta,0
0023 202B 00066 call pin0encode ;calls the subroutine if the input pin goes high
0024 1885 00067 btfsc porta,1
0025 202F 00068 call pin1encode ;calls the subroutine if the input pin goes high
0026 1905 00069 btfsc porta,2
0027 2033 00070 call pin2encode ;calls the subroutine if the input pin goes high
0028 1985 00071 btfsc porta,3
0029 2037 00072 call pin3encode ;calls the subroutine if the input pin goes high
002A 281D 00073 goto start ;goes back to start
00074
002B 00075 pin0encode:
002B 0827 00076 movf pin0,0 ;moves content of pin0 into the working register
002C 00A8 00077 movwf work ;copies content of pin0 into temp register, work
002D 203B 00078 call operate ;calls the subroutine that checks the bits
002E 0008 00079 return
00080
002F 00081 pin1encode:
002F 0820 00082 movf pin1,0 ;moves content of pin1 into the working register
0030 00A8 00083 movwf work ;copies content of pin1 into temp register, work
0031 203B 00084 call operate ;calls the subroutine that checks the bits
0032 0008 00085 return
00086
0033 00087 pin2encode:
0033 0821 00088 movf pin2,0 ;moves content of pin2 into the working register
0034 00A8 00089 movwf work ;copies content of pin2 into temp register, work
0035 203B 00090 call operate ;calls the subroutine that checks the bits
0036 0008 00091 return
00092
0037 00093 pin3encode:
0037 0822 00094 movf pin3,0 ;moves content of pin3 into the working register
0038 00A8 00095 movwf work ;copies content of pin3 into temp register, work
0039 203B 00096 call operate ;calls the subroutine that checks the bits
003A 0008 00097 return
00098
003B 00099 operate:
00100 ;performs a bit check on the nibbles
003B 1DA8 00101 btfss work,3 ;checks the 3rd bit to know if its set
003C 20AB 00102 call zero ;calls subroutine that handles zero bits
003D 19A8 00103 btfsc work,3 ;checks the 3rd bit to know if its clear
003E 20A4 00104 call one ;calls subroutine that handles one bits
003F 1D28 00105 btfss work,2 ;checks the 2nd bit to know if its set
0040 20AB 00106 call zero ;calls subroutine that handles zero bits
MPASM 5.46 ENCODER.ASM 11-27-2015 17:22:53 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0041 1928 00107 btfsc work,2 ;checks the 2nd bit to know if its clear
0042 20A4 00108 call one ;calls subroutine that handles one bits
0043 1CA8 00109 btfss work,1 ;checks the ist bit to know if its set
0044 20AB 00110 call zero ;calls subroutine that handles zero bits
0045 18A8 00111 btfsc work,1 ;checks the ist bit to know if its clear
0046 20A4 00112 call one ;calls subroutine that handles one bits
0047 1C28 00113 btfss work,0 ;checks the zero bit to know if its set
0048 20AB 00114 call zero ;calls subroutine that handles zero bits
0049 1828 00115 btfsc work,0 ;checks the zero bit to know if its clear
004A 20A4 00116 call one ;calls subroutine that handles one bits
004B 09A9 00117 comf encode,1 ;complements the encoded bytes
004C 2051 00118 call trigger
004D 2053 00119 call preamble
004E 2066 00120 call transmit ;calls subroutine that handles the transmission
004F 208B 00121 call checksum
0050 0008 00122 return
00123
0051 00124 trigger:
0051 1006 00125 bcf portb,0
0052 0008 00126 return
00127
0053 00128 preamble:
00129 ; bsf portb,0
0053 20D8 00130 call delay1
0054 1406 00131 bsf portb,0
0055 20CE 00132 call delay
0056 1006 00133 bcf portb,0
0057 20CE 00134 call delay
0058 1406 00135 bsf portb,0
0059 20CE 00136 call delay
005A 1006 00137 bcf portb,0
005B 20CE 00138 call delay
005C 1406 00139 bsf portb,0
005D 20CE 00140 call delay
005E 1006 00141 bcf portb,0
005F 20CE 00142 call delay
0060 1406 00143 bsf portb,0
0061 20CE 00144 call delay
0062 1006 00145 bcf portb,0
0063 20CE 00146 call delay
0064 20D8 00147 call delay1
0065 0008 00148 return
00149
0066 00150 transmit:
0066 1406 00151 bsf portb,0 ;sets the transmission pin
00152 ;the rest of the code in this subroutine checks the bits in the encode register and calls up the appropr
iate subroutine
0067 20D8 00153 call delay1
0068 1C29 00154 btfss encode,0
0069 209E 00155 call setb00
006A 1829 00156 btfsc encode,0
006B 20A1 00157 call setb01
006C 1CA9 00158 btfss encode,1
MPASM 5.46 ENCODER.ASM 11-27-2015 17:22:53 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
006D 209E 00159 call setb00
006E 18A9 00160 btfsc encode,1
006F 20A1 00161 call setb01
0070 1D29 00162 btfss encode,2
0071 209E 00163 call setb00
0072 1929 00164 btfsc encode,2
0073 20A1 00165 call setb01
0074 1DA9 00166 btfss encode,3
0075 209E 00167 call setb00
0076 19A9 00168 btfsc encode,3
0077 20A1 00169 call setb01
0078 1E29 00170 btfss encode,4
0079 209E 00171 call setb00
007A 1A29 00172 btfsc encode,4
007B 20A1 00173 call setb01
007C 1EA9 00174 btfss encode,5
007D 209E 00175 call setb00
007E 1AA9 00176 btfsc encode,5
007F 20A1 00177 call setb01
0080 1F29 00178 btfss encode,6
0081 209E 00179 call setb00
0082 1B29 00180 btfsc encode,6
0083 20A1 00181 call setb01
0084 1FA9 00182 btfss encode,7
0085 209E 00183 call setb00
0086 1BA9 00184 btfsc encode,7
0087 20A1 00185 call setb01
0088 1006 00186 bcf portb,0
0089 20CE 00187 call delay
008A 0008 00188 return
00189
008B 00190 checksum: ;this subrouting sends a checkbyte to the receiver to enable it know which signal to pro
cess
008B 20D8 00191 call delay1
008C 1406 00192 bsf portb,0
008D 20CE 00193 call delay
008E 1006 00194 bcf portb,0
008F 20CE 00195 call delay
0090 1406 00196 bsf portb,0
0091 20CE 00197 call delay
0092 1006 00198 bcf portb,0
0093 20CE 00199 call delay
0094 1406 00200 bsf portb,0
0095 20CE 00201 call delay
0096 1006 00202 bcf portb,0
0097 20CE 00203 call delay
0098 1406 00204 bsf portb,0
0099 20CE 00205 call delay
009A 1006 00206 bcf portb,0
009B 20CE 00207 call delay
009C 20D8 00208 call delay1
009D 0008 00209 return
00210
MPASM 5.46 ENCODER.ASM 11-27-2015 17:22:53 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
009E 00211 setb00:
009E 1006 00212 bcf portb,0 ;clears pin0 in port b
009F 20CE 00213 call delay ;calls a delay subroutine
00A0 0008 00214 return
00215
00A1 00216 setb01:
00A1 1406 00217 bsf portb,0 ;sets pin0 in port b
00A2 20CE 00218 call delay ;calls a delay subroutine
00A3 0008 00219 return
00220
00221
00222
00A4 00223 one: ;carries out encoding for bits that are 1
00A4 3080 00224 movlw b'10000000' ;moves the value into the working register
00A5 06A9 00225 xorwf encode,1 ;xors the value of gthe working register with that of the encode registe
r and stores the value in encode
00A6 0DA9 00226 rlf encode,1 ;rotates the bits to the left through carry
00A7 3000 00227 movlw 00h ;moves the value into the working register
00A8 06A9 00228 xorwf encode,1 ;xors the value of gthe working register with that of the encode register an
d stores the value in encode
00A9 0DA9 00229 rlf encode,1 ;rotates the bits to the left through carry
00AA 0008 00230 return
00231
00AB 00232 zero: ;carries out encoding for bits that are 0
00AB 3000 00233 movlw 00h ;moves the value into the working register
00AC 06A9 00234 xorwf encode,1 ;xors the value of gthe working register with that of the encode registe
r and stores the value in encode
00AD 0DA9 00235 rlf encode,1 ;rotates the bits to the left through carry
00AE 3001 00236 movlw b'00000001' ;moves the value into the working register
00AF 06A9 00237 xorwf encode,1 ;xors the value of gthe working register with that of the encode registe
r and stores the value in encode
00B0 0DA9 00238 rlf encode,1 ;rotates the bits to the left through carry
00B1 0008 00239 return
00240
00B2 00241 decrypt: ;this subroutine checks the odd bits in th encode register and calls up the appr
opriate subroutine
00B2 0829 00242 movf encode,0 ;moves the content of encode into the working register
00B3 00A8 00243 movwf work
00B4 1BA8 00244 btfsc work,7
00B5 20C6 00245 call decryptone
00B6 1FA8 00246 btfss work,7
00B7 20CA 00247 call decryptzero
00B8 1AA8 00248 btfsc work,5
00B9 20C6 00249 call decryptone
00BA 1EA8 00250 btfss work,5
00BB 20CA 00251 call decryptzero
00BC 19A8 00252 btfsc work,3
00BD 20C6 00253 call decryptone
00BE 1DA8 00254 btfss work,3
00BF 20CA 00255 call decryptzero
00C0 18A8 00256 btfsc work,1
00C1 20C6 00257 call decryptone
00C2 1CA8 00258 btfss work,1
MPASM 5.46 ENCODER.ASM 11-27-2015 17:22:53 PAGE 6
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00C3 20CA 00259 call decryptzero
00C4 0CAD 00260 rrf decode,1 ;rotates the bits right once to correct the effect from the decryption
00C5 0008 00261 return
00262
00C6 00263 decryptone:
00C6 3001 00264 movlw b'00000001' ;moves value to the working register
00C7 06AD 00265 xorwf decode,1 ;xors value in working register with decode and stores answer in decode
00C8 0DAD 00266 rlf decode,1 ;rotates left through carry
00C9 0008 00267 return
00268
00CA 00269 decryptzero:
00CA 3000 00270 movlw b'00000000' ;moves value to the working register
00CB 06AD 00271 xorwf decode,1 ;xors value in working register with decode and stores answer in decode
00CC 0DAD 00272 rlf decode,1 ;rotates left through carry
00CD 0008 00273 return
00274 ;the delay routine
00CE 00275 delay:
00CE 0181 00276 clrf tmr0
00CF 3008 00277 movlw d'8'
00D0 00AC 00278 movwf counter ;moves value in working register to counter
00D1 00279 frank:
00D1 1D0B 00280 btfss interrupt,2 ;checks the TMR0IF to know when its set
00D2 28D1 00281 goto frank
00D3 110B 00282 bcf interrupt,2 ;clears the TMR0IF
00D4 0BAC 00283 decfsz counter,1 ;decrements the value in the counter and puts the decremented value in the count
er
00D5 28D1 00284 goto frank
00D6 110B 00285 bcf interrupt,2 ;clears the TMR0IF
00D7 0008 00286 return
00287
00D8 00288 delay1:
00D8 0181 00289 clrf tmr0
00D9 302F 00290 movlw d'47'
00DA 00AC 00291 movwf counter ;moves value in working register to counter
00DB 00292 frank1:
00DB 1D0B 00293 btfss interrupt,2 ;checks the TMR0IF to know when its set
00DC 28DB 00294 goto frank1
00DD 110B 00295 bcf interrupt,2 ;clears the TMR0IF
00DE 0BAC 00296 decfsz counter,1 ;decrements the value in the counter and puts the decremented value in the count
er
00DF 28DB 00297 goto frank1
00E0 110B 00298 bcf interrupt,2 ;clears the TMR0IF
00E1 0008 00299 return
00300 end
MPASM 5.46 ENCODER.ASM 11-27-2015 17:22:53 PAGE 7
SYMBOL TABLE
LABEL VALUE
CMCON 0000001F
__16F84A 00000001
__DEBUG 1
bitposition 0000002A
checksum 0000008B
counter 0000002C
decode 0000002D
decrypt 000000B2
decryptone 000000C6
decryptzero 000000CA
delay 000000CE
delay1 000000D8
encode 00000029
frank 000000D1
frank1 000000DB
interrupt 0000000B
one 000000A4
operate 0000003B
optionreg 00000001
pcl 00000002
pin0 00000027
pin0encode 0000002B
pin1 00000020
pin1encode 0000002F
pin2 00000021
pin2encode 00000033
pin3 00000022
pin3encode 00000037
pin4 00000023
pin5 00000024
pin6 00000025
pin7 00000026
pointer 0000002B
porta 00000005
portb 00000006
preamble 00000053
setb00 0000009E
setb01 000000A1
start 0000001D
status 00000003
tmr0 00000001
transmit 00000066
trigger 00000051
work 00000028
zero 000000AB
MPASM 5.46 ENCODER.ASM 11-27-2015 17:22:53 PAGE 8
MEMORY USAGE MAP ('X' = Used, '-' = Unused)
0000 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
0040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
0080 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
00C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XX-------------- ----------------
All other memory blocks unused.
Program Memory Words Used: 226
Program Memory Words Free: 798
Errors : 0
Warnings : 0 reported, 0 suppressed
Messages : 0 reported, 0 suppressed