-
Notifications
You must be signed in to change notification settings - Fork 0
/
FTPUBDEC.MAC
888 lines (790 loc) · 17.3 KB
/
FTPUBDEC.MAC
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
LIST
; FTPUBDEC.MAC Macro definition file, Version 4.1 Inform Software Corporation
NOLIST
;*-----------------------------------------------------------------------------*
;*------------------------- fuzzyTECH MCU-MP V4.1 -----------------------------*
;* (c) 1995 Inform Software Corporation, 2001 Midwest Road, Oak Brook, IL60521 *
;*------------ (c) 1995 Inform GmbH, Pascalstr. 23, 52076 Aachen --------------*
;*-----------------------------------------------------------------------------*
;*---------------------- global macros for common use -------------------------*
;*-----------------------------------------------------------------------------*
;*---------------------------- General purpose macros -------------------------*
FCLR MACRO filereg
if FAMILY < 2
if RESOLUTION == 8
clrf filereg+0
else
clrf filereg+0
clrf filereg+1
endif
else
if RESOLUTION == 8
clrf filereg+0,F
else
clrf filereg+0,F
clrf filereg+1,F
endif
endif
ENDM
FSET MACRO filereg
if FAMILY < 2
if RESOLUTION == 8
movlw 0xFF
movwf filereg+0
else
movlw 0xFF
movwf filereg+0
movwf filereg+1
endif
else
if RESOLUTION == 8
setf filereg+0,F
else
setf filereg+0,F
setf filereg+1,F
endif
endif
ENDM
FCLR16 MACRO filereg
if FAMILY < 2
clrf filereg+0
clrf filereg+1
else
clrf filereg+0,F
clrf filereg+1,F
endif
ENDM
FCLR24 MACRO filereg
if FAMILY < 2
clrf filereg+0
clrf filereg+1
clrf filereg+2
else
clrf filereg+0,F
clrf filereg+1,F
clrf filereg+2,F
endif
ENDM
FCLR32 MACRO filereg
if FAMILY < 2
clrf filereg+0
clrf filereg+1
clrf filereg+2
clrf filereg+3
else
clrf filereg+0,F
clrf filereg+1,F
clrf filereg+2,F
clrf filereg+3,F
endif
ENDM
FCLR0F16 MACRO
if FAMILY < 2
clrf 0
incf FSR,F
clrf 0
decf FSR,F
else
clrf INDF0,F
clrf INDF0,F
endif
ENDM
FSET0F16 MACRO
setf 0
incf FSR,F
setf 0
decf FSR,F
ENDM
FADD16 MACRO filereg1,filereg2
if FAMILY == 2
movfp filereg1+1,WREG
addwf filereg2+1,F
movfp filereg1+0,WREG
addwfc filereg2+0,F
else
movf filereg1+1,W
addwf filereg2+1,F
movf filereg1+0,W
btfsc _C
incf filereg2+0,F
addwf filereg2+0,F
endif
ENDM
FADD32 MACRO filereg1, filereg2
if FAMILY == 2
movfp filereg1+3,WREG
addwf filereg2+3,F
movfp filereg1+2,WREG
addwfc filereg2+2,F
movfp filereg1+1,WREG
addwfc filereg2+1,F
movfp filereg1+0,WREG
addwfc filereg2+0,F
else
movf filereg1+3,W
addwf filereg2+3,F
movlw 1
btfss _C
btfsc _C
addwf filereg2+2,F
btfsc _C
addwf filereg2+1,F
btfsc _C
incf filereg2+0,F
movf filereg1+2,W
addwf filereg2+2,F
movlw 1
btfss _C
btfsc _C
addwf filereg2+1,F
btfsc _C
incf filereg2+0,F
movf filereg1+1,W
addwf filereg2+1,F
btfsc _C
incf filereg2+0,F
movf filereg1+0,W
addwf filereg2+0,F
endif
ENDM
FADD8TO16 MACRO filereg1, filereg2
if FAMILY == 2
movfp filereg1,WREG
addwf filereg2+1,F
movlw 0
addwfc filereg2+0,F
else
movf filereg1,W
addwf filereg2+1,F
btfsc _C
incf filereg2+0,F
endif
ENDM
FADD16TO24 MACRO filereg1, filereg2
if FAMILY == 2
movfp filereg1+1,WREG
addwf filereg2+2,F
movfp filereg1+0,WREG
addwfc filereg2+1,F
movlw 0x00
addwfc filereg2+0,F
else
movf filereg1+1,W
addwf filereg2+2,F
movlw 0x01
btfsc _C
addwf filereg2+1,F
btfsc _C
addwf filereg2+0,F
movf filereg1+0,W
addwf filereg2+1,F
btfsc _C
incf filereg2+0,F
endif
ENDM
FSUB16F MACRO filereg1,filereg2,filereg3
if FAMILY == 2
movfp filereg1+1,WREG
subwf filereg2+1,W
movwf filereg3+1
movfp filereg1+0,WREG
subwfb filereg2+0,W
movwf filereg3+0
else
movf filereg1+1,W
subwf filereg2+1,W
movwf filereg3+1
movf filereg1+0,W
btfss _C
addlw 1
subwf filereg2+0,W
movwf filereg3+0
endif
ENDM
FMOV0F16 MACRO filereg
if FAMILY == 1
movf 0,W
movwf filereg+0
incf FSR,F
movf 0,W
movwf filereg+1
decf FSR,F
endif
if FAMILY == 2
movpf INDF0,filereg+0
movpf INDF0,filereg+1
endif
ENDM
FMOV16F0 MACRO filereg
if FAMILY == 1
movf filereg+0,W
movwf 0
incf FSR,F
movf filereg+1,W
movwf 0
decf FSR,F
endif
if FAMILY == 2
movfp filereg+0,INDF0
movfp filereg+1,INDF0
endif
ENDM
FTMOV16 MACRO filereg1,filereg2
if FAMILY == 2
if ORDER == LSB_MSB
; Please specify the order of the linguistic variables in your main program
; Use 'ORDER EQU MSB_LSB' for compatibilty with the old fuzzyTECH format
; or 'ORDER EQU LSB_MSB' for compatibilty with existing PIC macros
movfp filereg1+0,WREG
movwf filereg2+1
movfp filereg1+1,WREG
movwf filereg2+0
else
movfp filereg1+0,WREG
movwf filereg2+0
movfp filereg1+1,WREG
movwf filereg2+1
endif
else
if ORDER == LSB_MSB
movf filereg1+0,W
movwf filereg2+1
movf filereg1+1,W
movwf filereg2+0
else
movf filereg1+0,W
movwf filereg2+0
movf filereg1+1,W
movwf filereg2+1
endif
endif
ENDM
FMOV16 MACRO filereg1, filereg2
if FAMILY == 2
movfp filereg1+0,WREG
movwf filereg2+0
movfp filereg1+1,WREG
movwf filereg2+1
else
movf filereg1+0,W
movwf filereg2+0
movf filereg1+1,W
movwf filereg2+1
endif
ENDM
FMOV16K MACRO filereg, Fconstant
movlw high Fconstant
movwf filereg+0
movlw low Fconstant
movwf filereg+1
ENDM
FTSTFSZ16 MACRO filereg
if FAMILY == 2
movfp filereg+0,WREG
iorwf filereg+1,W
tstfsz WREG
else
movf filereg+0,W
iorwf filereg+1,W
btfss _Z
endif
ENDM
FCPFSGT16 MACRO filereg1, filereg2
if FAMILY == 1
LOCAL ready
movf filereg1+0,W
subwf filereg2+0,W
btfss _C
goto ready
btfss _Z
goto ready
movf filereg1+1,W
subwf filereg2+1,W
ready
else
movfp filereg1+1,WREG
subwf filereg2+1,W
movfp filereg1+0,WREG
subwfb filereg2+0,W
endif
btfsc _C
ENDM
FCPFSLE16 MACRO filereg1, filereg2
if FAMILY == 1
LOCAL ready
movf filereg2+0,W
subwf filereg1+0,W
btfss _C
goto ready
btfss _Z
goto ready
movf filereg2+1,W
subwf filereg1+1,W
btfsc _Z
bcf _C
ready
else
movfp filereg2+1,WREG
subwf filereg1+1,W
movfp filereg2+0,WREG
subwfb filereg1+0,W
btfsc _Z
bcf _C
endif
btfsc _C
ENDM
FCPFSLT16 MACRO filereg1, filereg2
if FAMILY == 1
LOCAL ready
movf filereg2+0,W
subwf filereg1+0,W
btfss _C
goto ready
btfss _Z
goto ready
movf filereg2+1,W
subwf filereg1+1,W
ready
else
movfp filereg2+1,WREG
subwf filereg1+1,W
movfp filereg2+0,WREG
subwfb filereg1+0,W
endif
btfsc _C
ENDM
FDEC16 MACRO filereg
if FAMILY == 2
clrf WREG,F
decf filereg+1,F
subwfb filereg+0,F
endif
ENDM
FCLR_AUTO MACRO
bsf ALUSTA,4
bsf ALUSTA,5
ENDM
FSET_AUTO_INC MACRO
bsf ALUSTA,4
bcf ALUSTA,5
if BANKED == 1
movlr 0x000
bcf BBANK
endif
ENDM
FSET_AUTO_DEC MACRO
bcf ALUSTA,4
bcf ALUSTA,5
if BANKED == 1
movlr 0x000
bcf BBANK
endif
ENDM
FCOMF16 MACRO filereg
comf filereg+1,F
comf filereg+0,F
ENDM
FRR16 MACRO filename
if FAMILY < 2
rrf filename+0,F
rrf filename+1,F
else
rrcf filename+0,F
rrcf filename+1,F
endif
ENDM
FRR24 MACRO filename
if FAMILY < 2
rrf filename+0,F
rrf filename+1,F
rrf filename+2,F
else
rrcf filename+0,F
rrcf filename+1,F
rrcf filename+2,F
endif
ENDM
FRR32 MACRO filename
if FAMILY == 2
rrcf filename+0,F
rrcf filename+1,F
rrcf filename+2,F
rrcf filename+3,F
else
rrf filename+0,F
rrf filename+1,F
rrf filename+2,F
rrf filename+3,F
endif
ENDM
;--------------------------- fuzzyTECH specific macros ------------------------
FCLR_INC_FSR MACRO
if BANKED == 0
if FAMILY < 2
clrf 0
incf FSR,F
if RESOLUTION == 16
clrf 0
incf FSR,F
endif
else
clrf INDF0,F
if RESOLUTION == 16
clrf INDF0,F
endif
endif
else
if FAMILY == 0
SET_PAGE
clrf 0
incf FSR,F
bsf FSR,4
RES_PAGE
endif
if FAMILY == 1
LOCAL p1_test
LOCAL end_test
clrf 0
btfss FSR,7
goto p1_test
incf FSR,F
if RESOLUTION == 16
clrf 0
incf FSR,F
endif
goto end_test
p1_test
incf FSR,F
if RESOLUTION == 16
clrf 0
incf FSR,F
endif
btfss FSR,7
goto end_test
movlw RAM_GAP_SIZE
addwf FSR,F
end_test
endif
if FAMILY == 2
LOCAL cross_page
SET_PAGE
clrf INDF0,F
if RESOLUTION == 16
clrf INDF0,F
endif
movpf FSR0,WREG
btfss _Z
goto cross_page
bsf BBANK
movlw 0x20
movwf FSR0
cross_page
RES_PAGE
endif
endif
ENDM
INC_FSR MACRO
if BANKED == 0
if FAMILY < 2
incf FSR,F
if RESOLUTION == 16
incf FSR,F
endif
else
endif
else
if FAMILY == 0
incf FSR,F
bsf FSR,4
endif
if FAMILY == 1
LOCAL p1_test
LOCAL end_test
btfss FSR,7
goto p1_test
incf FSR,F
if RESOLUTION == 16
incf FSR,F
endif
goto end_test
p1_test
incf FSR,F
if RESOLUTION == 16
incf FSR,F
endif
btfss FSR,7
goto end_test
movlw RAM_GAP_SIZE
addwf FSR,F
end_test
endif
if FAMILY == 2
LOCAL first_page
movpf FSR0,FSR0
btfss _Z
goto first_page
movwf FSR1
movlw RAM_GAP_SIZE
addwf FSR0,F
movpf FSR1,WREG
bsf BBANK
first_page
endif
endif
ENDM
DEC_FSR MACRO
if BANKED == 0
decf FSR,F
if RESOLUTION == 16
decf FSR,F
endif
else
if FAMILY == 0
bcf FSR,4
decf FSR,F
bsf FSR,4
endif
if FAMILY == 1
LOCAL p0_test
LOCAL end_test
btfsc FSR,7
goto p0_test
decf FSR,F
if RESOLUTION == 16
decf FSR,F
endif
goto end_test
p0_test
decf FSR,F
if RESOLUTION == 16
decf FSR,F
endif
movlw RAM_GAP_END
subwf FSR,W
btfsc _C
goto end_test
movlw RAM_GAP_SIZE
subwf FSR,F
end_test
endif
if FAMILY == 2
endif
endif
ENDM
ADD_TBL16 MACRO tbl_addr, offset
addlw (tbl_addr) & 0x0FF
movwf TBLPTRL
clrf TBLPTRH,F
movlw page tbl_addr
addwfc TBLPTRH,F
ENDM
LD8TBL MACRO table, offset
movlw page table
movwf PCLATH
movlw ( table & 0x0FF )
addwf offset,W
btfsc _C
incf PCLATH,F
movwf PCL
ENDM
LD_TBL16 MACRO tbl_addr
if FAMILY < 2
movlw page tbl_addr
movwf rt_table+1
movlw (tbl_addr) & 0x0FF
movwf rt_table
else
movlw page tbl_addr
movwf TBLPTRH
movlw (tbl_addr) & 0x0FF
movwf TBLPTRL
endif
ENDM
LD16TBL MACRO table, offset
movlw page table
addwf offset+1,W
movwf PCLATH
movlw ( table & 0x0FF )
addwf offset,W
btfsc _C
incf PCLATH,F
movwf PCL
ENDM
LD8PTR MACRO table, offset
movf table+1,W
movwf PCLATH
movf table,W
addwf offset,W
btfsc _C
incf PCLATH,F
movwf PCL
ENDM
LD16PTR MACRO table, offset
movf table+1,W
addwf offset+1,W
movwf PCLATH
movf table,W
addwf offset,W
btfsc _C
incf PCLATH,F
movwf PCL
ENDM
IS_PAGE MACRO Fpage
if BANKED == 0
else
if FAMILY == 0
if ( Fpage < 0x20 )
movlw 0x020
endif
if ( (Fpage >= 0x20) && (Fpage < 0x40) )
movlw 0x040
endif
if ( (Fpage >= 0x40) && (Fpage < 0x60) )
movlw 0x060
endif
if ( (Fpage >= 0x60) && (Fpage < 0x80) )
movlw 0x080
endif
movwf page_bound
else
endif
endif
ENDM
FPREP_PAGE MACRO adr
if BANKED == 0
movlw fuzvals + adr
if FAMILY < 2
movwf FSR
else
movwf FSR0
endif
else
if FAMILY == 0
if ((fuzvals + adr) < 0x20 )
movlw fuzvals + adr
endif
if ( ((fuzvals + adr) >= 0x20 ) && ((fuzvals + adr) < 0x2F ) )
movlw fuzvals + adr + 1 * RAM_GAP_SIZE
endif
if ( ((fuzvals + adr) >= 0x30 ) && ((fuzvals + adr) < 0x3F ) )
movlw fuzvals + adr + 2 * RAM_GAP_SIZE
endif
if ( ((fuzvals + adr) >= 0x40 ) && ((fuzvals + adr) < 0x4F ) )
movlw fuzvals + adr + 3 * RAM_GAP_SIZE
endif
movwf save_page
endif
if FAMILY == 1
if ((fuzvals + adr) < RAM_GAP_START )
movlw fuzvals + adr
else
movlw fuzvals + adr + RAM_GAP_SIZE
endif
movwf FSR
endif
if FAMILY == 2
if ((fuzvals + adr) < RAM_GAP_START )
bcf BBANK
movlw fuzvals + adr
else
bsf BBANK
movlw low (fuzvals + adr + RAM_GAP_SIZE)
endif
movwf FSR0
endif
endif
ENDM
SET_PAGE MACRO
if BANKED == 0
else
if FAMILY == 0
movwf save_wreg
movf save_page,W
movwf FSR
movf save_wreg,W
endif
if FAMILY == 1
endif
if FAMILY == 2
btfsc BBANK
bsf BSR,4
endif
endif
ENDM
RES_PAGE MACRO
if BANKED == 0
else
if FAMILY == 0
movwf save_wreg
movf FSR,W
clrf FSR
movwf save_page
movf save_wreg,W
endif
if FAMILY == 1
endif
if FAMILY == 2
bcf BSR,4
endif
endif
ENDM
COMP_FSR MACRO
if BANKED == 0
if FAMILY < 2
movwf FSR
movlw fuzvals
addwf FSR,F
else
movwf FSR0
movlw fuzvals
addwf FSR0,F
endif
else
if FAMILY == 0
LOCAL add_page_loop
LOCAL add_page_end
movwf save_page
movlw fuzvals
addwf save_page,F
movf page_bound,W
add_page_loop
subwf save_page,W
btfss _C
goto add_page_end
movlw RAM_GAP_SIZE
addwf save_page,F
movlw 0x020
addwf page_bound,W
goto add_page_loop
add_page_end
endif
if FAMILY == 1
LOCAL add_page_end
movwf FSR
movlw fuzvals
addwf FSR,F
movlw RAM_GAP_START
subwf FSR,W
btfss _C
goto add_page_end
movlw RAM_GAP_SIZE
addwf FSR,F
add_page_end
endif
if FAMILY == 2
LOCAL cross_page
bcf BBANK
movwf FSR0
movlw fuzvals
addwf FSR0,F
btfss _C
goto cross_page
movlw RAM_GAP_SIZE
addwf FSR0,F
bsf BBANK
cross_page
endif
endif
ENDM
; The end of module public declarations
LIST