-
Notifications
You must be signed in to change notification settings - Fork 1
/
bankswitch.inc
134 lines (112 loc) · 3.58 KB
/
bankswitch.inc
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
; Copyright (c) 2009, Microchip Technology Inc.
;
; Microchip licenses this software to you solely for use with Microchip
; products. The software is owned by Microchip and its licensors, and
; is protected under applicable copyright laws. All rights reserved.
;
; SOFTWARE IS PROVIDED "AS IS." MICROCHIP EXPRESSLY DISCLAIMS ANY
; WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT
; NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
; FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL
; MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
; CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO YOUR
; EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY
; OR SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED
; TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION,
; OR OTHER SIMILAR COSTS.
;
; To the fullest extent allowed by law, Microchip and its licensors
; liability shall not exceed the amount of fees, if any, that you
; have paid directly to Microchip to use this software.
;
; MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE
; OF THESE TERMS.
;
; Author Date Comment
; ************************************************************************
; E. Schlunder 06/09/2009 Starting to move all bank switching code to
; macros in this include file. This will
; allow us to support the enhanced PIC16F core
; devices, which use a "movlb" instruction
; instead of STATUS<RP0/RP1> bits.
#ifdef BSR
; Enhanced PIC16F core, use movlb instruction instead of diddling STATUS<RP0/RP1>
BXtoB0 macro
movlb .0 ; Bx -> B0
endm
B0toB1 macro
movlb .1 ; Bx -> B1
endm
B0toB2 macro
movlb .2 ; Bx -> B2
endm
B1toB0 macro
movlb .0 ; Bx -> B0
endm
B1toB3 macro
movlb .3 ; Bx -> B3
endm
B2toB3 macro
movlb .3 ; Bx -> B3
endm
B3toB2 macro
movlb .2 ; Bx -> B2
endm
B2toB0 macro
movlb .0 ; Bx -> B0
endm
lfsr macro GPRADDR
movlw low(GPRADDR)
movwf FSR0L
movlw high(GPRADDR)
movwf FSR0H
endm
#ifndef INDF
#ifdef INDF0
#define INDF INDF0
#endif
#endif
#ifndef FSR
#define FSR FSR0L
#endif
#ifndef BAUDCTL
#define BAUDCTL BAUDCON
#endif
#else
; Original PIC16F core, no movlb instruction
BXtoB0 macro
clrf STATUS ; Bx -> B0
endm
B0toB1 macro
bsf STATUS, RP0 ; B0 -> B1
endm
B0toB2 macro
bsf STATUS, RP1 ; B0 -> B2
endm
B2toB0 macro
bcf STATUS, RP1 ; B2 -> B0
endm
B1toB0 macro
bcf STATUS, RP0 ; B1 -> B0
endm
B1toB3 macro
bsf STATUS, RP1 ; B1 -> B3
endm
B2toB3 macro
bsf STATUS, RP0 ; B2 -> B3
endm
B3toB2 macro
bcf STATUS, RP0 ; B3 to B2
endm
lfsr macro GPRADDR
movlw GPRADDR
movwf FSR
endm
#endif
#ifndef EEDATA
#ifdef EEDATL
#define EEDATA EEDATL
#else
#define EEDATA EEDAT
#endif
#endif