-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINIT.A51
310 lines (287 loc) · 9.8 KB
/
INIT.A51
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
$NOMOD51
;------------------------------------------------------------------------------
; This file is part of the C51 Compiler package
; Copyright (c) 1988-2003 Keil Elektronik GmbH and Keil Software, Inc.
;
; *** <<< Use Configuration Wizard in Context Menu >>> ***
;------------------------------------------------------------------------------
; INIT.A51: This code is executed, if the application program contains
; initialized variables at file level.
;
; If you are using uVision2, just add the file as last file to your project.
; *** IMPORTANT NOTE ***: this file needs to be the last file of the linker
; input list. If you are using uVision2 this file should be therefore the
; last file in your project tree.
;
;
; To translate this file use Ax51 with the following invocation:
;
; Ax51 INIT.A51
;
; To link the modified INIT.OBJ file to your application use the following
; linker invocation:
;
; Lx51 your object file list, INIT.OBJ controls
;
;------------------------------------------------------------------------------
;
; User-defined Watch-Dog Refresh.
;
; If the C application contains many initialized variables uses a watchdog
; it might be possible that the user has to include a watchdog refresh into
; the initialization process. The watchdog refresh routine can be included
; in the following MACRO and can alter all CPU registers except
; DPTR.
;
PCA0CPH4 EQU 0xFE
WATCHDOG MACRO
; MOV R6,#0xFF
; MOV PCA0CPH4,R6 ; Include any Watchdog refresh code here
ENDM
;
;------------------------------------------------------------------------------
;
;<h> Far Memory Support
;
; If the C application contains variables in the far memory space that are
; initialized, you need to set the following define to 1.
;
; --- Set XBANK = 1 when far variables should be initialized
; <q> XBANK: Initialize variables in far memory
; <i>If the C application contains variables in the far memory space that are
; <i>initialized, you need to check this box.
$SET (XBANK = 0)
;
;</h>
;------------------------------------------------------------------------------
;
;<h> Dallas 390,400 and 5240 CPU Contiguous Mode
;
; If you are using the Dallas Contigious Mode you need to set the following
; define to 1.
;
; --- Set DS390 = 1 when CPU runs in Dallas Contigious Mode
; <q> DS390: Enable Dallas contiguous mode
$SET (DS390 = 0)
;
;</h>
;------------------------------------------------------------------------------
; Standard SFR Symbols
ACC DATA 0E0H
DPL DATA 82H
DPH DATA 83H
NAME ?C_INIT
?C_C51STARTUP SEGMENT CODE
?C_INITSEG SEGMENT CODE ; Segment with Initializing Data
INIT_IorP MACRO
IorPData: ; If CY=1 PData Values
CLR A
MOVC A,@A+DPTR
INC DPTR
MOV R0,A ; Start Address
IorPLoop: CLR A
MOVC A,@A+DPTR
INC DPTR
JC PData
MOV @R0,A
SJMP Common
PData: MOVX @R0,A
Common: INC R0
DJNZ R7,IorPLoop
JMP Loop
ENDM
EXTRN CODE (MAIN)
PUBLIC ?C_START
RSEG ?C_C51STARTUP
INITEND: LJMP MAIN
$IF (XBANK = 0)
INIT_IorP
$ENDIF
Bits: CLR A
MOVC A,@A+DPTR
INC DPTR
MOV R0,A
ANL A,#007H
ADD A,#Table-LoadTab
XCH A,R0
CLR C
RLC A ; Bit Condition to Carry
SWAP A
ANL A,#00FH
ORL A,#20H ; Bit Address
XCH A,R0 ; convert to Byte Addressen
MOVC A,@A+PC
LoadTab: JC Setzen
CPL A
ANL A,@R0
SJMP BitReady
Setzen: ORL A,@R0
BitReady: MOV @R0,A
DJNZ R7,Bits
SJMP Loop
Table: DB 00000001B
DB 00000010B
DB 00000100B
DB 00001000B
DB 00010000B
DB 00100000B
DB 01000000B
DB 10000000B
?C_START:
MOV DPTR,#?C_INITSEG
Loop:
WATCHDOG
CLR A
MOV R6,#1
MOVC A,@A+DPTR
JZ INITEND
INC DPTR
MOV R7,A
ANL A,#3FH
JNB ACC.5,NOBIG
ANL A,#01FH
MOV R6,A
CLR A
MOVC A,@A+DPTR
INC DPTR
JZ NOBIG
INC R6
NOBIG: XCH A,R7
; ---- Init for far Variables
$IF (DS390)
DPX DATA 93H
EXTRN CODE (?C?CODESEG)
EXTRN CODE (?C?XDATASEG)
$ENDIF
$IF (XBANK = 1)
EXTRN CODE (?C?CSTPTR)
ANL A,#0E0H
CJNE A,#0E0H,NOHDATA
;
HPTRINIT: CLR A
MOVC A,@A+DPTR
MOV R3,A
INC DPTR
CLR A
MOVC A,@A+DPTR
MOV R2,A
INC DPTR
CLR A
MOVC A,@A+DPTR
MOV R1,A
INC DPTR
HLOOP: CLR A
MOVC A,@A+DPTR
PUSH DPH
PUSH DPL
CALL ?C?CSTPTR
$IF (DS390)
MOV DPX,#BYTE0 (?C?CODESEG)
$ENDIF
POP DPL
POP DPH
INC DPTR
INC R1
MOV A,R1
JNZ HINC
INC R2
HINC: DJNZ R7,HLOOP
DJNZ R6,HLOOP
SJMP Loop
NOHDATA:
$ENDIF
ANL A,#0C0H ; Typ is in Bit 6 and Bit 7
ADD A,ACC
JZ IorPData
JC Bits
XdataMem: CLR A
MOVC A,@A+DPTR
INC DPTR
MOV R2,A ; High
CLR A
MOVC A,@A+DPTR
INC DPTR
MOV R0,A ; LOW
XLoop: CLR A
MOVC A,@A+DPTR
INC DPTR
XCH A,R0
XCH A,DPL
XCH A,R0
XCH A,R2
XCH A,DPH
XCH A,R2
$IF (DS390)
MOV DPX,#BYTE0 (?C?XDATASEG)
$ENDIF
MOVX @DPTR,A
$IF (DS390)
MOV DPX,#BYTE0 (?C?CODESEG)
$ENDIF
INC DPTR
XCH A,R0
XCH A,DPL
XCH A,R0
XCH A,R2
XCH A,DPH
XCH A,R2
DJNZ R7,XLoop
DJNZ R6,XLoop
SJMP Loop
$IF (XBANK = 1)
INIT_IorP
$ENDIF
RSEG ?C_INITSEG
DB 0
;-------------------------------------------------------------------------
; STRUCTURE OF THE INITIALIZATION INFORMATION
; -------------------------------------------
; This section describes the initialization data generated by C51 for
; explicit variable initializations (in segment ?C_INITSEC).
;
; Explicit variable initilizations at C source level are stored by C51 in
; the segment ?C_INITSEC. All partial segments are combined at linker level
; to one segment. The segment end value DB 0 is taken from this library module
; INIT.A51.
;
; Structure of the ?C_INITSEC information:
; Info (see below) [BYTE] ----+ repeated
; additional info [BYTES depend on Info] ----+ repeated
; 0x00 [BYTE] end of list mark
;
; Info has the following format:
;
; Bit 7 6 5 4 3 2 1 0
; Info T T B L L L L L T=Type B=BIGBIT L=LENGTH
;
; If BIGBIT is set, another LENGTH BYTE FOLLOWS. The LENGTH
; info of the first byte is then the HIGH part.
;
; Typ is one of the following:
; 0 := IDATA init values; the following bytes follow:
; - 1 byte address
; - init data bytes according LENGTH specification
;
; 1 := XDATA init values; the following bytes follow:
; - 2 byte address (high byte first)
; - init data bytes according LENGTH specification
;
; 2 := PDATA init values; the following bytes follow:
; - 1 byte address
; - init data bytes according LENGTH specification
;
; 3, BIGBIT=0 := BIT init values; the followign bytes follow:
; - 1 byte for each bit according LENGTH specification
; this byte has the following format:
;
; Bit 7 6 5 4 3 2 1 0
; I B B B B B B B I := state of the bit
; B := bit address
;
; 3, BIGBIT=1 := HDATA init values; the following bytes follow:
; - another LENGTH byte (since BIGBIT is always 1)
; - 3 byte address (MSB first)
; - data bytes according LENGTH specification
;
;----------------------------------------------------------------------
END