-
Notifications
You must be signed in to change notification settings - Fork 0
/
LABORATORIO_DISPLAY.asm
1353 lines (1353 loc) · 23.8 KB
/
LABORATORIO_DISPLAY.asm
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
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; /\\\\\\\\\
; /\\\///////\\\
; \/\\\ \/\\\ /\\\ /\\\
; \/\\\\\\\\\\\/ /\\\\\ /\\\\\\\\\\ /\\\\\\\\ /\\\\\\\\\\\ /\\\\\\\\\\\ /\\\\\\\\\
; \/\\\//////\\\ /\\\///\\\ \/\\\////// /\\\/////\\\ \////\\\//// \////\\\//// \////////\\\
; \/\\\ \//\\\ /\\\ \//\\\ \/\\\\\\\\\\ /\\\\\\\\\\\ \/\\\ \/\\\ /\\\\\\\\\\
; \/\\\ \//\\\ \//\\\ /\\\ \////////\\\ \//\\/////// \/\\\ /\\ \/\\\ /\\ /\\\/////\\\
; \/\\\ \//\\\ \///\\\\\/ /\\\\\\\\\\ \//\\\\\\\\\\ \//\\\\\ \//\\\\\ \//\\\\\\\\/\\
; \/// \/// \///// \////////// \////////// \///// \///// \////////\//
; Let's find out together what makes a PIC Tick!
;
; Code Produced by the Proton BASIC Compiler. Version 3.7.3.6
; Written by Les Johnson. January 2020
;----------------------------------------------------------
;
#define Config_Req 1
LIST P = 16F886, F = INHX8M, W = 2, X = ON, R = DEC, MM = ON, N = 0, C = 255
INDF equ 0X0000
TMR0 equ 0X0001
PCL equ 0X0002
STATUS equ 0X0003
FSR equ 0X0004
PORTA equ 0X0005
PORTB equ 0X0006
PORTC equ 0X0007
PORTE equ 0X0009
PCLATH equ 0X000A
INTCON equ 0X000B
PIR1 equ 0X000C
PIR2 equ 0X000D
TMR1L equ 0X000E
TMR1LH equ 0X000F
TMR1H equ 0X000F
T1CON equ 0X0010
TMR2 equ 0X0011
T2CON equ 0X0012
SSPBUF equ 0X0013
SSPCON equ 0X0014
CCPR1L equ 0X0015
CCPR1LH equ 0X0016
CCPR1H equ 0X0016
CCP1CON equ 0X0017
RCSTA equ 0X0018
TXREG equ 0X0019
RCREG equ 0X001A
CCPR2L equ 0X001B
CCPR2LH equ 0X001C
CCPR2H equ 0X001C
CCP2CON equ 0X001D
ADRESLH equ 0X001E
ADRESH equ 0X001E
ADCON0 equ 0X001F
OPTION_REG equ 0X0081
TRISA equ 0X0085
TRISB equ 0X0086
TRISC equ 0X0087
TRISE equ 0X0089
PIE1 equ 0X008C
PIE2 equ 0X008D
PCON equ 0X008E
OSCCON equ 0X008F
OSCTUNE equ 0X0090
SSPCON2 equ 0X0091
PR2 equ 0X0092
SSPADD equ 0X0093
SSPMSK equ 0X0093
MSK equ 0X0093
SSPSTAT equ 0X0094
WPUB equ 0X0095
IOCB equ 0X0096
VRCON equ 0X0097
TXSTA equ 0X0098
SPBRG equ 0X0099
SPBRGH equ 0X009A
PWM1CON equ 0X009B
ECCPAS equ 0X009C
PSTRCON equ 0X009D
ADRESL equ 0X009E
ADCON1 equ 0X009F
WDTCON equ 0X0105
CM1CON0 equ 0X0107
CM2CON0 equ 0X0108
CM2CON1 equ 0X0109
EEDATL equ 0X010C
EEDATA equ 0X010C
EEDAT equ 0X010C
EEADR equ 0X010D
EEDATLH equ 0X010E
EEDATH equ 0X010E
EEADRH equ 0X010F
SRCON equ 0X0185
BAUDCTL equ 0X0187
ANSEL equ 0X0188
ANSELH equ 0X0189
EECON1 equ 0X018C
EECON2 equ 0X018D
_I2C_SCL_Port=TRISC
_I2C_SCL_Pin=3
_I2C_SDA_Port=TRISC
_I2C_SDA_Pin=4
; SFR BITS
IRP=7
PP_IRP=7
RP1=6
PP_RP1=6
RP0=5
PP_RP0=5
NOT_TO=4
NOT_PD=3
Z=2
DC=1
C=0
GIE=7
PEIE=6
T0IE=5
TMR0IE=5
INTE=4
RBIE=3
T0IF=2
TMR0IF=2
INTF=1
RBIF=0
ADIF=6
RCIF=5
PP_RCIF=5
TXIF=4
PP_TXIF=4
SSPIF=3
CCP1IF=2
TMR2IF=1
TMR1IF=0
OSFIF=7
C2IF=6
C1IF=5
EEIF=4
BCLIF=3
ULPWUIF=2
CCP2IF=0
T1GIV=7
TMR1GE=6
T1CKPS1=5
T1CKPS0=4
T1OSCEN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
ANS0=0
ANS13=5
ANS12=4
ANS11=3
ANS10=2
ANS9=1
ANS8=0
EEPGD=7
PP_EEPGD=7
WRERR=3
PP_WRERR=3
WREN=2
PP_WREN=2
WR=1
PP_WR=1
RD=0
PP_RD=0
__MAXRAM 0X1FF
__BADRAM 0X18E-0X18F
_config1 equ 0X2007
_config2 equ 0X2008
DEBUG_ON equ 0X1FFF
DEBUG_OFF equ 0X3FFF
LVP_ON equ 0X3FFF
LVP_OFF equ 0X2FFF
FCMEN_ON equ 0X3FFF
FCMEN_OFF equ 0X37FF
IESO_ON equ 0X3FFF
IESO_OFF equ 0X3BFF
BOR_ON equ 0X3FFF
BOR_NSLEEP equ 0X3EFF
BOR_SBODEN equ 0X3DFF
BOR_OFF equ 0X3CFF
CPD_ON equ 0X3F7F
CPD_OFF equ 0X3FFF
CP_ON equ 0X3FBF
CP_OFF equ 0X3FFF
MCLRE_ON equ 0X3FFF
MCLRE_OFF equ 0X3FDF
PWRTE_ON equ 0X3FEF
PWRTE_OFF equ 0X3FFF
WDT_ON equ 0X3FFF
WDT_OFF equ 0X3FF7
LP_OSC equ 0X3FF8
XT_OSC equ 0X3FF9
HS_OSC equ 0X3FFA
EC_OSC equ 0X3FFB
INTRC_OSC_NOCLKOUT equ 0X3FFC
INTRC_OSC_CLKOUT equ 0X3FFD
EXTRC_OSC_NOCLKOUT equ 0X3FFE
EXTRC_OSC_CLKOUT equ 0X3FFF
INTOSCIO equ 0X3FFC
INTOSC equ 0X3FFD
EXTRCIO equ 0X3FFE
EXTRC equ 0X3FFF
WRT_OFF equ 0X3FFF
WRT_256 equ 0X3DFF
WRT_1FOURTH equ 0X3BFF
WRT_HALF equ 0X39FF
BOR21V equ 0X3EFF
BOR40V equ 0X3FFF
BOR4V_BOR21V equ 0X3EFF
BOR4V_BOR40V equ 0X3FFF
BOREN_NSLEEP equ 0X3EFF
BOREN_OFF equ 0X3CFF
BOREN_ON equ 0X3FFF
BOREN_SBODEN equ 0X3DFF
FOSC_EC equ 0X3FFB
FOSC_EXTRC_CLKOUT equ 0X3FFF
FOSC_EXTRC_NOCLKOUT equ 0X3FFE
FOSC_HS equ 0X3FFA
FOSC_INTRC_CLKOUT equ 0X3FFD
FOSC_INTRC_NOCLKOUT equ 0X3FFC
FOSC_LP equ 0X3FF8
FOSC_XT equ 0X3FF9
WDTE_OFF equ 0X3FF7
WDTE_ON equ 0X3FFF
#define __16F886 1
#define Xtal 20
#define _Core 14
#define _MaxRAM 368
#define _Ram_End 0X0170
#define _MaxMem 8192
#define _ADC 11
#define _ADC_Res 10
#define _Eeprom 256
#define _Pages 4
#define _Banks 3
#define RAM_Banks 4
#define _USART 1
#define _USB 0
#define _Flash 1
#define _Cwrite_Block 8
#define Bank0_Start 0X20
#define Bank0_End 0X7F
#define Bank1_Start 0XA0
#define Bank1_End 0XEF
#define Bank2_Start 0X110
#define Bank2_End 0X16F
#define Bank3_Start 0X190
#define Bank3_End 0X1EF
#define _System_Variable_Count 9
ram_bank = 0
Current@Page = 0
Dest@Page = 0
#define LCD#Type 0
f@call macro pDest
if(pDest < 1)
if((pDest & 2048) == 0)
bcf PCLATH,3
else
bsf PCLATH,3
endif
if((pDest & 4096) == 0)
bcf PCLATH,4
else
bsf PCLATH,4
endif
else
if(pDest > $)
if((pDest & 2048) == 0)
bcf PCLATH,3
else
bsf PCLATH,3
endif
if((pDest & 4096) == 0)
bcf PCLATH,4
else
bsf PCLATH,4
endif
else
if((pDest & 6144) == 0)
clrf PCLATH
else
if((pDest & 2048) == 0)
bcf PCLATH,3
else
bsf PCLATH,3
endif
if((pDest & 4096) == 0)
bcf PCLATH,4
else
bsf PCLATH,4
endif
endif
endif
endif
call pDest
endm
f@jump macro pDest
if(pDest < 1)
if((pDest & 2048) == 0)
bcf PCLATH,3
else
bsf PCLATH,3
endif
if((pDest & 4096) == 0)
bcf PCLATH,4
else
bsf PCLATH,4
endif
else
if(pDest > $)
if((pDest & 2048) == 0)
bcf PCLATH,3
else
bsf PCLATH,3
endif
if((pDest & 4096) == 0)
bcf PCLATH,4
else
bsf PCLATH,4
endif
else
if((pDest & 6144) == 0)
clrf PCLATH
else
if((pDest & 2048) == 0)
bcf PCLATH,3
else
bsf PCLATH,3
endif
if((pDest & 4096) == 0)
bcf PCLATH,4
else
bsf PCLATH,4
endif
endif
endif
endif
goto pDest
endm
set@page macro pDest
if((pDest & 2048) == 0)
bcf PCLATH,3
else
bsf PCLATH,3
endif
if((pDest & 4096) == 0)
bcf PCLATH,4
else
bsf PCLATH,4
endif
endm
s@b macro pVarin
if((pVarin & 384) == 0)
if(ram_bank == 1)
bcf STATUS,PP_RP0
endif
if(ram_bank == 2)
bcf STATUS,PP_RP1
endif
if(ram_bank == 3)
bcf STATUS,PP_RP0
bcf STATUS,PP_RP1
endif
ram_bank = 0
endif
if((pVarin & 384) == 128)
if(ram_bank == 0)
bsf STATUS,PP_RP0
endif
if(ram_bank == 2)
bsf STATUS,PP_RP0
bcf STATUS,PP_RP1
endif
if(ram_bank == 3)
bcf STATUS,PP_RP1
endif
ram_bank = 1
endif
if((pVarin & 384) == 256)
if(ram_bank == 0)
bsf STATUS,PP_RP1
endif
if(ram_bank == 1)
bcf STATUS,PP_RP0
bsf STATUS,PP_RP1
endif
if(ram_bank == 3)
bcf STATUS,PP_RP0
endif
ram_bank = 2
endif
if((pVarin & 384) == 384)
if(ram_bank == 0)
bsf STATUS,PP_RP0
bsf STATUS,PP_RP1
endif
if(ram_bank == 1)
bsf STATUS,PP_RP1
endif
if(ram_bank == 2)
bsf STATUS,PP_RP0
endif
ram_bank = 3
endif
endm
r@b macro
if((ram_bank & 1) != 0)
bcf STATUS,PP_RP0
endif
if((ram_bank & 2) != 0)
bcf STATUS,PP_RP1
endif
ram_bank = 0
endm
variable Current@Page = 0
variable PDESTINATION@PAGE = 0
FIND@PAGE macro pLabelIn
local CURRENT_ADDR = $
local DEST_ADDR = pLabelIn
if((CURRENT_ADDR >= 0X1800) && (CURRENT_ADDR <= 0X2000))
Current@Page = 3
endif
if((CURRENT_ADDR >= 0X1000) && (CURRENT_ADDR <= 0X1800))
Current@Page = 2
endif
if((CURRENT_ADDR >= 0X0800) && (CURRENT_ADDR <= 0X1000))
Current@Page = 1
endif
if((CURRENT_ADDR >= 0) && (CURRENT_ADDR <= 0X0800))
Current@Page = 0
endif
if((DEST_ADDR >= 0X1800) && (DEST_ADDR <= 0X2000))
PDESTINATION@PAGE = 3
endif
if((DEST_ADDR >= 0X1000) && (DEST_ADDR <= 0X1800))
PDESTINATION@PAGE = 2
endif
if((DEST_ADDR >= 0X0800) && (DEST_ADDR <= 0X1000))
PDESTINATION@PAGE = 1
endif
if((DEST_ADDR >= 0) && (DEST_ADDR <= 0X0800))
PDESTINATION@PAGE = 0
endif
endm
jump macro pLabel
goto pLabel
endm
wreg_byte macro pByteOut
s@b pByteOut
movwf pByteOut
r@b
endm
wreg_bit macro pVarOut,pBitout
s@b pVarOut
andlw 1
btfsc STATUS,2
bcf pVarOut,pBitout
btfss STATUS,2
bsf pVarOut,pBitout
r@b
endm
wreg_word macro pWordOut
s@b pWordOut
movwf pWordOut
s@b pWordOut+1
clrf pWordOut+1
r@b
endm
wreg_dword macro pDwordOut
s@b pDwordOut+3
clrf pDwordOut+3
s@b pDwordOut+2
clrf pDwordOut+2
s@b pDwordOut+1
clrf pDwordOut+1
s@b pDwordOut
movwf pDwordOut
r@b
endm
byte_wreg macro pByteIn
s@b pByteIn
movf pByteIn,W
r@b
endm
num_SFR macro pNumIn,pSFROut
s@b pSFROut
movlw pNumIn
movwf pSFROut
endm
num16_SFR macro pNumIn,pSFROut
s@b pSFROut
movlw (pNumIn & 255)
movwf pSFROut
s@b pSFROut + 1
movlw ((pNumIn >> 8) & 255)
movwf pSFROut + 1
r@b
endm
num_wreg macro pNumIn
movlw (pNumIn & 255)
endm
num_byte macro pNumIn,pByteOut
s@b pByteOut
if(pNumIn == 0)
clrf pByteOut
else
movlw (pNumIn & 255)
movwf pByteOut
endif
r@b
endm
num_bit macro pNumIn,pVarOut,pBitout
s@b pVarOut
if((pNumIn & 1) == 1)
bsf pVarOut,pBitout
else
bcf pVarOut,pBitout
endif
r@b
endm
num_word macro pNumIn,pWordOut
if((pNumIn & 255) == 0)
s@b pWordOut
clrf pWordOut
else
s@b pWordOut
movlw low (pNumIn)
movwf pWordOut
endif
if(((pNumIn >> 8) & 255) == 0)
s@b pWordOut+1
clrf pWordOut+1
else
s@b pWordOut+1
movlw high (pNumIn)
movwf pWordOut+1
endif
r@b
endm
num_dword macro pNumIn,pDwordOut
if ((pNumIn >> 24 & 255) == 0)
s@b pDwordOut+3
clrf pDwordOut+3
else
s@b pDwordOut+3
movlw ((pNumIn >> 24) & 255)
movwf pDwordOut+3
endif
if( ((pNumIn >> 16) & 255) == 0)
s@b pDwordOut+2
clrf pDwordOut+2
else
s@b pDwordOut+2
movlw ((pNumIn >> 16) & 255)
movwf pDwordOut+2
endif
if( ((pNumIn >> 8) & 255) == 0)
s@b pDwordOut+1
clrf pDwordOut+1
else
s@b pDwordOut+1
movlw high (pNumIn)
movwf pDwordOut+1
endif
if((pNumIn & 255) == 0)
s@b pDwordOut
clrf pDwordOut
else
s@b pDwordOut
movlw low (pNumIn)
movwf pDwordOut
endif
r@b
endm
bit_wreg macro pVarin,pBitIn
s@b pVarin
clrw
btfsc pVarin,pBitIn
movlw 1
r@b
endm
bit_byte macro pVarin,pBitIn,pByteOut
s@b pVarin
clrw
btfsc pVarin,pBitIn
movlw 1
s@b pByteOut
movwf pByteOut
r@b
endm
bit_bit macro pVarin,pBitIn,pVarOut,pBitout
if((pVarin & 65408) == (pVarOut & 65408))
s@b pVarOut
btfsc pVarin,pBitIn
bsf pVarOut,pBitout
btfss pVarin,pBitIn
bcf pVarOut,pBitout
else
s@b pVarin
clrdc
btfsc pVarin,pBitIn
setdc
s@b pVarOut
skpndc
bsf pVarOut,pBitout
skpdc
bcf pVarOut,pBitout
endif
endm
bit_word macro pVarin,pBitIn,pWordOut
s@b pWordOut+1
clrf pWordOut+1
bit_byte pVarin,pBitIn,pWordOut
endm
bit_dword macro pVarin,pBitIn,pDwordOut
s@b pDwordOut+3
clrf pDwordOut+3
s@b pDwordOut+2
clrf pDwordOut+2
s@b pDwordOut+1
clrf pDwordOut+1
bit_byte pVarin,pBitIn,pDwordOut
endm
word_wreg macro pWordIn
byte_wreg pWordIn
endm
word_byte macro pWordIn,pByteOut
byte_byte pWordIn,pByteOut
endm
word_bit macro pWordIn,pVarOut,pBitout
byte_bit pWordIn, pVarOut, pBitout
endm
word_word macro pWordIn,pWordOut
s@b pWordIn+1
movf pWordIn+1,W
s@b pWordOut+1
movwf pWordOut+1
byte_byte pWordIn,pWordOut
endm
word_dword macro pWordIn,pDwordOut
s@b pDwordOut+3
clrf pDwordOut+3
s@b pDwordOut+2
clrf pDwordOut+2
byte_byte pWordIn+1,pDwordOut+1
byte_byte pWordIn,pDwordOut
endm
byte_byte macro pByteIn,pByteOut
s@b pByteIn
movf pByteIn,W
s@b pByteOut
movwf pByteOut
r@b
endm
byte_word macro pByteIn,pWordOut
s@b pWordOut+1
clrf pWordOut+1
byte_byte pByteIn,pWordOut
endm
byte_dword macro pByteIn,pDwordOut
s@b pDwordOut+3
clrf pDwordOut+3
s@b pDwordOut+2
clrf pDwordOut+2
s@b pDwordOut+1
clrf pDwordOut+1
byte_byte pByteIn,pDwordOut
endm
byte_bit macro pByteIn,pVarOut,pBitout
if((pByteIn & 65408) == (pVarOut & 65408))
s@b pByteIn
btfsc pByteIn,0
bsf pVarOut,pBitout
btfss pByteIn,0
bcf pVarOut,pBitout
else
s@b pByteIn
rrf pByteIn,W
s@b pVarOut
skpnc
bsf pVarOut,pBitout
skpc
bcf pVarOut,pBitout
endif
r@b
endm
dword_wreg macro pDwordIn
byte_wreg pDwordIn
endm
dword_byte macro pDwordIn,pByteOut
byte_byte pDwordIn,pByteOut
endm
dword_word macro pDwordIn,pWordOut
s@b pDwordIn+1
movf pDwordIn+1,W
s@b pWordOut+1
movwf pWordOut+1
byte_byte pDwordIn,pWordOut
endm
dword_dword macro pDwordIn,pDwordOut
byte_byte pDwordIn+3,pDwordOut+3
byte_byte pDwordIn+2,pDwordOut+2
byte_byte pDwordIn+1,pDwordOut+1
byte_byte pDwordIn,pDwordOut
endm
dword_bit macro pDwordIn,pVarOut,pBitout
byte_bit pDwordIn,pVarOut,pBitout
endm
num_float macro pNumIn,pFloatOut
num_byte pNumIn,pFloatOut+3
num_byte ((pNumIn >> 8) & 255),pFloatOut+2
num_byte ((pNumIn >> 16) & 255),pFloatOut+1
num_byte ((pNumIn >> 24) & 255),pFloatOut
endm
wreg_float macro pFloatOut
PAGESEL _UNS_INT08_TOFL32
call _UNS_INT08_TOFL32
byte_byte PP_AARG,pFloatOut
byte_byte PP_AARGH,pFloatOut+1
byte_byte PP_AARGHH,pFloatOut+2
byte_byte PP_AARGHHH,pFloatOut+3
endm
bit_float macro pVarin,pBitIn,pFloatOut
bit_wreg pVarin,pBitIn
PAGESEL _UNS_INT08_TOFL32
call _UNS_INT08_TOFL32
byte_byte PP_AARG,pFloatOut
byte_byte PP_AARGH,pFloatOut+1
byte_byte PP_AARGHH,pFloatOut+2
byte_byte PP_AARGHHH,pFloatOut+3
endm
byte_float macro pByteIn,pFloatOut
byte_wreg pByteIn
PAGESEL _UNS_INT08_TOFL32
call _UNS_INT08_TOFL32
byte_byte PP_AARG,pFloatOut
byte_byte PP_AARGH,pFloatOut+1
byte_byte PP_AARGHH,pFloatOut+2
byte_byte PP_AARGHHH,pFloatOut+3
endm
word_float macro pWordIn,pFloatOut
byte_byte pWordIn,PP_AARG
byte_byte pWordIn+1,PP_AARGH
PAGESEL _UNS_INT16_TOFL32
call _UNS_INT16_TOFL32
byte_byte PP_AARG,pFloatOut