📄 start12.lst
字号:
ANSI-C/cC++ Compiler for HC12 V-5.0.30 Build 6037, Feb 7 2006
1: /*****************************************************
2: start12.c - standard startup code
3: The startup code may be optimized to special user requests
4: ----------------------------------------------------
5: Copyright (c) Metrowerks, Basel, Switzerland
6: All rights reserved
7:
8: Note: ROM libraries are not implemented in this startup code
9: Note: C++ destructors of global objects are NOT yet supported in the HIWARE Object File Format.
10: To use this feature, please build your application with the ELF object file format.
11: *****************************************************/
12: /*lint -esym(750, __NO_FLAGS_OFFSET, __NO_MAIN_OFFSET, __NO_STACKOFFSET_OFFSET) */
13: /* these macros remove some unused fields in the startup descriptor */
14: #define __NO_FLAGS_OFFSET /* we do not need the flags field in the startup data descriptor */
15: #define __NO_MAIN_OFFSET /* we do not need the main field in the startup data descriptor */
16: #define __NO_STACKOFFSET_OFFSET /* we do not need the stackOffset field in the startup data descriptor */
17:
18: /*#define __BANKED_COPY_DOWN : allow to allocate .copy in flash area */
19: #if defined(__BANKED_COPY_DOWN) && (!defined(__HCS12X__) || !defined(__ELF_OBJECT_FILE_FORMAT__))
20: #error /* the __BANKED_COPY_DOWN switch is only supported for the HCS12X with ELF */
21: /* (and not for the HC12, HCS12 or for the HIWARE object file format) */
22: #endif
23:
24: #include "hidef.h"
25: #include "start12.h"
26:
27: /***************************************************************************/
28: /* Macros to control how the startup code handles the COP: */
29: /* #define _DO_FEED_COP_ : do feed the COP */
30: /* #define _DO_ENABLE_COP_: do enable the COP */
31: /* #define _DO_DISABLE_COP_: disable the COP */
32: /* Without defining any of these, the startup code does NOT handle the COP */
33: /***************************************************************************/
34: /* __ONLY_INIT_SP define: */
35: /* This define selects an shorter version of the startup code */
36: /* which only loads the stack pointer and directly afterwards calls */
37: /* main. This version does however NOT initialized global variables */
38: /* (So this version is not ANSI compliant!) */
39: /***************************************************************************/
40: /* __FAR_DATA define: */
41: /* By default, the startup code only supports to initialize the default */
42: /* kind of memory. If some memory is allocated far in the small or banked */
43: /* memory model, then the startup code only supports to initialize this */
44: /* memory blocks if __FAR_DATA is defined. If __FAR_DATA is not defined, */
45: /* then the linker will issue a message like */
46: /* "L1128: Cutting value _Range beg data member from 0xF01000 to 0x1000" */
47: /* and this startup code writes to the cutted address */
48: /***************************************************************************/
49: /* __BANKED_COPY_DOWN define: */
50: /* by default, the startup code assumes that the startup data structure */
51: /* _startupData, the zero out areas and the .copy section are all */
52: /* allocated in NON_BANKED memory. Especially the .copy section can be */
53: /* if there are many or large RAM areas to initialize. */
54: /* for the HCS12X, which also copies the XGATE RAM located code via .copy */
55: /* section, the startup code supports to allocate .copy in a banked flash */
56: /* The placement of .copy in the prm file has to be adapted when adding or */
57: /* removing the this macro. */
58: /* Note: This macro is only supported for the HCS12X and when using ELF */
59: /***************************************************************************/
60:
61: #ifdef __cplusplus
62: #define __EXTERN_C extern "C"
63: #else
64: #define __EXTERN_C
65: #endif
66:
67: __EXTERN_C void main(void); /* prototype of main function */
68:
69: #ifndef __ONLY_INIT_SP
70: #pragma DATA_SEG __NEAR_SEG STARTUP_DATA /* _startupData can be accessed using 16 bit accesses. */
71: /* This is needed because it contains the stack top, and without stack, far data cannot be accessed */
72: /*lint -e1065 */
73: struct _tagStartup _startupData; /* read-only: */
74: /* _startupData is allocated in ROM and */
75: /* initialized by the linker */
76: /*lint +e1065 */
77: #pragma DATA_SEG DEFAULT
78: #endif /* __ONLY_INIT_SP */
79:
80: #if defined(FAR_DATA) && (!defined(__HCS12X__) || defined(__BANKED_COPY_DOWN))
81: #include "non_bank.sgm"
82: /* the init function must be in non banked memory if banked variables are used */
83: /* because _SET_PAGE is called, which may change any page register. */
84:
85: __EXTERN_C void _SET_PAGE(void); /* the inline assembler needs a prototype */
86: /* this is a runtime routine with a special */
87: /* calling convention, do not use it in c code! */
88: #else
89: #include "default.sgm"
90: #endif /* defined(FAR_DATA) && (!defined(__HCS12X__) || defined(__BANKED_COPY_DOWN)) */
91:
92:
93: /* define value and bits for Windef Register */
94: #ifdef HC812A4
95: #define WINDEF (*(volatile unsigned char*) 0x37)
96: #if defined( __BANKED__) || defined(__LARGE__) || defined(__PPAGE__)
97: #define __ENABLE_PPAGE__ 0x40
98: #else
99: #define __ENABLE_PPAGE__ 0x0
100: #endif
101: #if defined(__DPAGE__)
102: #define __ENABLE_DPAGE__ 0x80
103: #else
104: #define __ENABLE_DPAGE__ 0x0
105: #endif
106: #if defined(__EPAGE__)
107: #define __ENABLE_EPAGE__ 0x20
108: #else
109: #define __ENABLE_EPAGE__ 0x0
110: #endif
111: #endif /* HC812A4 */
112:
113: #ifdef _HCS12_SERIALMON
114: /* for Monitor based software remap the RAM & EEPROM to adhere
115: to EB386. Edit RAM and EEPROM sections in PRM file to match these. */
116: #define ___INITRM (*(volatile unsigned char *) 0x0010)
117: #define ___INITRG (*(volatile unsigned char *) 0x0011)
118: #define ___INITEE (*(volatile unsigned char *) 0x0012)
119: #endif
120:
121: #if defined(_DO_FEED_COP_)
122: #define __FEED_COP_IN_HLI() } __asm movb #0x55, _COP_RST_ADR; __asm movb #0xAA, _COP_RST_ADR; __asm {
123: #else
124: #define __FEED_COP_IN_HLI() /* do nothing */
125: #endif
126:
127: #ifndef __ONLY_INIT_SP
128: #if (!defined(FAR_DATA) || defined(__HCS12X__)) && (defined( __BANKED__) || defined(__LARGE__) || defined(__BANKED_COPY_DOWN))
129: static void __far Init(void)
130: #else
131: static void Init(void)
132: #endif
133: {
Function: Init
Source : D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006\Sources\Start12.c
Options : -CPUHCS12 -D__NO_FLOAT__ -Env"GENPATH=D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006;D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006\bin;D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006\prm;D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006\cmd;D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006\Sources;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\lib;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\src;D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\include" -Env"LIBPATH=D:\Program Files\Freescale\CW for HC12 V4.5\lib\HC12c\include" -Env"OBJPATH=D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006\bin" -Env"TEXTPATH=D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006\bin" -Lasm=%n.lst -Mb -ObjN="D:\Chg\Tech\FSL_Support\from ChatRoom\9S12DP256_Vector Remapping_Jul262006\9S12DP256_Vector_Remapping_Jul262006_Data\Full_Chip_Simulation\ObjectCode\Start12.c.o"
134: /* purpose: 1) zero out RAM-areas where data is allocated */
135: /* 2) copy initialization data from ROM to RAM */
136: /* 3) call global constructors in C++ */
137: /* called from: _Startup, LibInits */
138: __asm {
139: ZeroOut:
140: #if defined(__HIWARE_OBJECT_FILE_FORMAT__) && defined(__LARGE__)
141: LDX _startupData.pZeroOut:1 ; in the large memory model in the HIWARE format, pZeroOut is a 24 bit pointer
142: #else
143: LDX _startupData.pZeroOut ; *pZeroOut
0000 fe0000 [3] LDX _startupData:2
144: #endif
145: LDY _startupData.nofZeroOuts ; nofZeroOuts
0003 fd0000 [3] LDY _startupData
146: BEQ CopyDown ; if nothing to zero out
0006 270e [3/1] BEQ *+16 ;abs = 0016
147:
148: NextZeroOut: PSHY ; save nofZeroOuts
0008 35 [2] PSHY
149: #if defined(FAR_DATA)
150: LDAB 1,X+ ; load page of destination address
151: LDY 2,X+ ; load offset of destination address
152: #if defined(__HCS12X__)
153: STAB __GPAGE_ADR__
154: #else /* defined(__HCS12X__) */
155: __PIC_JSR(_SET_PAGE) ; sets the page in the correct page register
156: #endif /* defined(__HCS12X__) */
157: #else /* FAR_DATA */
158: LDY 2,X+ ; start address and advance *pZeroOut (X = X+4)
0009 ed31 [3] LDY 2,X+
159: #endif /* FAR_DATA */
160:
161: #if defined(__HCS12X__) && defined(FAR_DATA)
162: PSHX
163: LDX 0,X ; byte count
164: #if defined(__OPTIMIZE_FOR_SIZE__)
165: CLRA
166: NextWord: GSTAA 1,Y+ ; clear memory byte
167: __FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
168: DBNE X, NextWord ; dec byte count
169: #else
170: LDD #0
171: LSRX
172: BEQ LoopClrW1 ; do we copy more than 1 byte?
173: NextWord: GSTD 2,Y+ ; clear memory word
174: __FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
175: DBNE X, NextWord ; dec word count
176: LoopClrW1:
177: BCC LastClr ; handle last byte
178: GSTAA 1,Y+ ; handle last byte
179: LastClr:
180: #endif
181: PULX
182: LEAX 2,X
183: #elif defined(__OPTIMIZE_FOR_SIZE__) /* -os, default */
184: LDD 2,X+ ; byte count
000b ec31 [3] LDD 2,X+
185: NextWord: CLR 1,Y+ ; clear memory byte
000d 6970 [2] CLR 1,Y+
186: __FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
187: DBNE D, NextWord ; dec byte count
000f 0434fb [3] DBNE D,*-2 ;abs = 000d
188: #else /* __OPTIMIZE_FOR_TIME__ */
189: LDD 2,X+ ; byte count
190: LSRD ; /2 and save bit 0 in the carry
191: BEQ LoopClrW1 ; do we copy more than 1 byte?
192: PSHX
193: LDX #0
194: LoopClrW: STX 2,Y+ ; Word-Clear
195: __FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
196: DBNE D, LoopClrW
197: PULX
198: LoopClrW1:
199: BCC LastClr ; handle last byte
200: CLR 1,Y+
201: LastClr:
202: #endif /* __OPTIMIZE_FOR_SIZE__/__OPTIMIZE_FOR_TIME__ */
203: PULY ; restore nofZeroOuts
0012 31 [3] PULY
204: DEY ; dec nofZeroOuts
0013 03 [1] DEY
205: BNE NextZeroOut
0014 26f2 [3/1] BNE *-12 ;abs = 0008
206: CopyDown:
207: #if defined(__BANKED_COPY_DOWN)
208: LDAA _startupData.toCopyDownBeg:0 ; get PAGE address of .copy section
209: STAA __PPAGE_ADR__ ; set PPAGE address
210: LDX _startupData.toCopyDownBeg:1 ; load address of copy down desc.
211: #elif defined(__ELF_OBJECT_FILE_FORMAT__)
212: LDX _startupData.toCopyDownBeg ; load address of copy down desc.
0016 fe0000 [3] LDX _startupData:4
213: #else
214: LDX _startupData.toCopyDownBeg:2 ; load address of copy down desc.
215: #endif
216: NextBlock:
217: LDD 2,X+ ; size of init-data -> D
0019 ec31 [3] LDD 2,X+
218: BEQ funcInits ; end of copy down desc.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -