📄 datapage.lst
字号:
ANSI-C/cC++ Compiler for HC12 V-5.0.30 Build 6157, Jun 7 2006
1: /******************************************************************************
2: FILE : datapage.c
3: PURPOSE : paged data access runtime routines
4: MACHINE : Freescale 68HC12 (Target)
5: LANGUAGE : ANSI-C
6: HISTORY : 21.7.96 first version created
7: ******************************************************************************/
8:
9: #include "hidef.h"
10:
11: #include "non_bank.sgm"
12: #include "runtime.sgm"
13:
14:
15:
16: #ifndef __HCS12X__ /* it's different for the HCS12X. See the text below at the #else // __HCS12X__ */
17:
18: /*
19: According to the -Cp option of the compiler the
20: __DPAGE__, __PPAGE__ and __EPAGE__ macros are defined.
21: If none of them is given as argument, then no page accesses should occur and
22: this runtime routine should not be used !
23: To be on the save side, the runtime routines are created anyway.
24: If some of the -Cp options are given an adapted versions which only covers the
25: needed cases is produced.
26: */
27:
28: /* if no compiler option -Cp is given, it is assumed that all possible are given : */
29:
30: /* Compile with option -DHCS12 to activate this code */
31: #if defined(HCS12) || defined(_HCS12) || defined(__HCS12__) /* HCS12 family has PPAGE register only at 0x30 */
32: #define PPAGE_ADDR (0x30+REGISTER_BASE)
33: #ifndef __PPAGE__ /* may be set already by option -CPPPAGE */
34: #define __PPAGE__
35: #endif
36: /* Compile with option -DDG128 to activate this code */
37: #elif defined DG128 /* HC912DG128 derivative has PPAGE register only at 0xFF */
38: #define PPAGE_ADDR (0xFF+REGISTER_BASE)
39: #ifndef __PPAGE__ /* may be set already by option -CPPPAGE */
40: #define __PPAGE__
41: #endif
42: #elif defined(HC812A4)
43: /* all setting default to A4 already */
44: #endif
45:
46:
47: #if !defined(__EPAGE__) && !defined(__PPAGE__) && !defined(__DPAGE__)
48: /* as default use all page registers */
49: #define __DPAGE__
50: #define __EPAGE__
51: #define __PPAGE__
52: #endif
53:
54: /* modify the following defines to your memory configuration */
55:
56: #define EPAGE_LOW_BOUND 0x400u
57: #define EPAGE_HIGH_BOUND 0x7ffu
58:
59: #define DPAGE_LOW_BOUND 0x7000u
60: #define DPAGE_HIGH_BOUND 0x7fffu
61:
62: #define PPAGE_LOW_BOUND (DPAGE_HIGH_BOUND+1)
63: #define PPAGE_HIGH_BOUND 0xBFFFu
64:
65: #define REGISTER_BASE 0x0u
66: #ifndef DPAGE_ADDR
67: #define DPAGE_ADDR (0x34u+REGISTER_BASE)
68: #endif
69: #ifndef EPAGE_ADDR
70: #define EPAGE_ADDR (0x36u+REGISTER_BASE)
71: #endif
72: #ifndef PPAGE_ADDR
73: #define PPAGE_ADDR (0x35u+REGISTER_BASE)
74: #endif
75:
76: /*
77: The following parts about the defines are assumed in the code of _GET_PAGE_REG :
78: - the memory region controlled by DPAGE is above the area controlled by the EPAGE and
79: below the area controlled by the PPAGE.
80: - the lower bound of the PPAGE area is equal to be the higher bound of the DPAGE area + 1
81: */
82: #if EPAGE_LOW_BOUND >= EPAGE_HIGH_BOUND || EPAGE_HIGH_BOUND >= DPAGE_LOW_BOUND || DPAGE_LOW_BOUND >= DPAGE_HIGH_BOUND || DPAGE_HIGH_BOUND >= PPAGE_LOW_BOUND || PPAGE_LOW_BOUND >= PPAGE_HIGH_BOUND
83: #error /* please adapt _GET_PAGE_REG for this non default page configuration */
84: #endif
85:
86: #if DPAGE_HIGH_BOUND+1 != PPAGE_LOW_BOUND
87: #error /* please adapt _GET_PAGE_REG for this non default page configuration */
88: #endif
89:
90:
91: /* this module does either control if any access is in the bounds of the specified page or */
92: /* ,if only one page is specified, just use this page. */
93: /* This behavior is controlled by the define USE_SEVERAL_PAGES. */
94: /* If !USE_SEVERAL_PAGES does increase the performance significantly */
95: /* NOTE : When !USE_SEVERAL_PAGES, the page is also set for accesses outside of the area controlled */
96: /* by this single page. But this is should not cause problems because the page is restored to the old value before any other access could occur */
97:
98: #if !defined(__DPAGE__) && !defined(__EPAGE__) && !defined(__PPAGE__)
99: /* no page at all is specified */
100: /* only specifying the right pages will speed up these functions a lot */
101: #define USE_SEVERAL_PAGES 1
102: #elif defined(__DPAGE__) && defined(__EPAGE__) || defined(__DPAGE__) && defined(__PPAGE__) || defined(__EPAGE__) && defined(__PPAGE__)
103: /* more than one page register is used */
104: #define USE_SEVERAL_PAGES 1
105: #else
106:
107: #define USE_SEVERAL_PAGES 0
108:
109: #if defined(__DPAGE__) /* check which pages are used */
110: #define PAGE_ADDR PPAGE_ADDR
111: #elif defined(__EPAGE__)
112: #define PAGE_ADDR EPAGE_ADDR
113: #elif defined(__PPAGE__)
114: #define PAGE_ADDR PPAGE_ADDR
115: #else /* we do not know which page, decide it at runtime */
116: #error /* must not happen */
117: #endif
118:
119: #endif
120:
121:
122: #if USE_SEVERAL_PAGES /* only needed for several pages support */
123: /*--------------------------- _GET_PAGE_REG --------------------------------
124: Runtime routine to detect the right register depending on the 16 bit offset part
125: of an address.
126: This function is only used by the functions below.
127:
128: Depending on the compiler options -Cp different versions of _GET_PAGE_REG are produced.
129:
130: Arguments :
131: - Y : offset part of an address
132:
133: Result :
134: if address Y is controlled by a page register :
135: - X : address of page register if Y is controlled by an page register
136: - Zero flag cleared
137: - all other registers remain unchanged
138:
139: if address Y is not controlled by a page register :
140: - Zero flag is set
141: - all registers remain unchanged
142:
143: --------------------------- _GET_PAGE_REG ----------------------------------*/
144:
145: #if defined(__DPAGE__)
146:
147: #ifdef __cplusplus
148: extern "C"
149: #endif
150: #pragma NO_ENTRY
151: #pragma NO_EXIT
152: #pragma NO_FRAME
153:
154: static void NEAR _GET_PAGE_REG(void) { /*lint -esym(528, _GET_PAGE_REG) used in asm code */
155: __asm {
156: L_DPAGE:
157: CPY #DPAGE_LOW_BOUND ;// test of lower bound of DPAGE
158: #if defined(__EPAGE__)
159: BLO L_EPAGE ;// EPAGE accesses are possible
160: #else
161: BLO L_NOPAGE ;// no paged memory below accesses
162: #endif
163: CPY #DPAGE_HIGH_BOUND ;// test of higher bound DPAGE/lower bound PPAGE
164: #if defined(__PPAGE__)
165: BHI L_PPAGE ;// EPAGE accesses are possible
166: #else
167: BHI L_NOPAGE ;// no paged memory above accesses
168: #endif
169: FOUND_DPAGE:
170: LDX #DPAGE_ADDR ;// load page register address and clear zero flag
171: RTS
172:
173: #if defined(__PPAGE__)
174: L_PPAGE:
175: CPY #PPAGE_HIGH_BOUND ;// test of higher bound of PPAGE
176: BHI L_NOPAGE
177: FOUND_PPAGE:
178: LDX #PPAGE_ADDR ;// load page register address and clear zero flag
179: RTS
180: #endif
181:
182: #if defined(__EPAGE__)
183: L_EPAGE:
184: CPY #EPAGE_LOW_BOUND ;// test of lower bound of EPAGE
185: BLO L_NOPAGE
186: CPY #EPAGE_HIGH_BOUND ;// test of higher bound of EPAGE
187: BHI L_NOPAGE
188:
189: FOUND_EPAGE:
190: LDX #EPAGE_ADDR ;// load page register address and clear zero flag
191: RTS
192: #endif
193:
194: L_NOPAGE:
195: ORCC #0x04 ;// sets zero flag
196: RTS
197: }
198: }
199:
200: #else /* !defined(__DPAGE__) */
201:
202: #if defined( __PPAGE__ )
203:
204: #ifdef __cplusplus
205: extern "C"
206: #endif
207: #pragma NO_ENTRY
208: #pragma NO_EXIT
209: #pragma NO_FRAME
210:
211: static void NEAR _GET_PAGE_REG(void) { /*lint -esym(528, _GET_PAGE_REG) used in asm code */
212: __asm {
213: L_PPAGE:
214: CPY #PPAGE_LOW_BOUND ;// test of lower bound of PPAGE
215: #if defined( __EPAGE__ )
216: BLO L_EPAGE
217: #else
218: BLO L_NOPAGE ;// no paged memory below
219: #endif
220: CPY #PPAGE_HIGH_BOUND ;// test of higher bound PPAGE
221: BHI L_NOPAGE
222: FOUND_PPAGE:
223: LDX #PPAGE_ADDR ;// load page register address and clear zero flag
224: RTS
225: #if defined( __EPAGE__ )
226: L_EPAGE:
227: CPY #EPAGE_LOW_BOUND ;// test of lower bound of EPAGE
228: BLO L_NOPAGE
229: CPY #EPAGE_HIGH_BOUND ;// test of higher bound of EPAGE
230: BHI L_NOPAGE
231: FOUND_EPAGE:
232: LDX #EPAGE_ADDR ;// load page register address and clear zero flag
233: RTS
234: #endif
235:
236: L_NOPAGE: ;// not in any allowed page area
237: ;// its a far access to a non paged variable
238: ORCC #0x04 ;// sets zero flag
239: RTS
240: }
241: }
242:
243: #else /* !defined(__DPAGE__ ) && !defined( __PPAGE__) */
244: #if defined(__EPAGE__)
245:
246: #ifdef __cplusplus
247: extern "C"
248: #endif
249: #pragma NO_ENTRY
250: #pragma NO_EXIT
251: #pragma NO_FRAME
252:
253: static void NEAR _GET_PAGE_REG(void) { /*lint -esym(528, _GET_PAGE_REG) used in asm code */
254: __asm {
255: L_EPAGE:
256: CPY #EPAGE_LOW_BOUND ;// test of lower bound of EPAGE
257: BLO L_NOPAGE
258: CPY #EPAGE_HIGH_BOUND ;// test of higher bound of EPAGE
259: BHI L_NOPAGE
260: FOUND_EPAGE:
261: LDX #EPAGE_ADDR ;// load page register address and clear zero flag
262: RTS
263:
264: L_NOPAGE: ;// not in any allowed page area
265: ;// its a far access to a non paged variable
266: ORCC #0x04 ;// sets zero flag
267: RTS
268: }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -