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
|
1 ;--------------------------------------------------------
2 ; File Created by SDCC : free open source ANSI-C Compiler
3 ; Version 2.9.0 #5416 (Feb 3 2010) (UNIX)
4 ; This file was generated Sun Dec 16 06:02:12 2012
5 ;--------------------------------------------------------
6 .module demo_c_0
7 .optsdcc -mmcs51 --model-small
8
9 ;--------------------------------------------------------
10 ; Public variables in this module
11 ;--------------------------------------------------------
12 .globl _main
13 .globl _someFunction
14 .globl _CY
15 .globl _AC
16 .globl _F0
17 .globl _RS1
18 .globl _RS0
19 .globl _OV
20 .globl _FL
21 .globl _P
22 .globl _PS
23 .globl _PT1
24 .globl _PX1
25 .globl _PT0
26 .globl _PX0
27 .globl _RD
28 .globl _WR
29 .globl _T1
30 .globl _T0
31 .globl _INT1
32 .globl _INT0
33 .globl _TXD
34 .globl _RXD
35 .globl _P3_7
36 .globl _P3_6
37 .globl _P3_5
38 .globl _P3_4
39 .globl _P3_3
40 .globl _P3_2
41 .globl _P3_1
42 .globl _P3_0
43 .globl _EA
44 .globl _ES
45 .globl _ET1
46 .globl _EX1
47 .globl _ET0
48 .globl _EX0
49 .globl _P2_7
50 .globl _P2_6
51 .globl _P2_5
52 .globl _P2_4
53 .globl _P2_3
54 .globl _P2_2
55 .globl _P2_1
56 .globl _P2_0
57 .globl _SM0
58 .globl _SM1
59 .globl _SM2
60 .globl _REN
61 .globl _TB8
62 .globl _RB8
63 .globl _TI
64 .globl _RI
65 .globl _P1_7
66 .globl _P1_6
67 .globl _P1_5
68 .globl _P1_4
69 .globl _P1_3
70 .globl _P1_2
71 .globl _P1_1
72 .globl _P1_0
73 .globl _TF1
74 .globl _TR1
75 .globl _TF0
76 .globl _TR0
77 .globl _IE1
78 .globl _IT1
79 .globl _IE0
80 .globl _IT0
81 .globl _P0_7
82 .globl _P0_6
83 .globl _P0_5
84 .globl _P0_4
85 .globl _P0_3
86 .globl _P0_2
87 .globl _P0_1
88 .globl _P0_0
89 .globl _B
90 .globl _A
91 .globl _ACC
92 .globl _PSW
93 .globl _IP
94 .globl _P3
95 .globl _IE
96 .globl _P2
97 .globl _SBUF
98 .globl _SCON
99 .globl _P1
100 .globl _TH1
101 .globl _TH0
102 .globl _TL1
103 .globl _TL0
104 .globl _TMOD
105 .globl _TCON
106 .globl _PCON
107 .globl _DPH
108 .globl _DPL
109 .globl _SP
110 .globl _P0
111 .globl _i
112 .globl _some_variable
113 ;--------------------------------------------------------
114 ; special function registers
115 ;--------------------------------------------------------
116 .area RSEG (DATA)
0080 117 G$P0$0$0 == 0x0080
0080 118 _P0 = 0x0080
0081 119 G$SP$0$0 == 0x0081
0081 120 _SP = 0x0081
0082 121 G$DPL$0$0 == 0x0082
0082 122 _DPL = 0x0082
0083 123 G$DPH$0$0 == 0x0083
0083 124 _DPH = 0x0083
0087 125 G$PCON$0$0 == 0x0087
0087 126 _PCON = 0x0087
0088 127 G$TCON$0$0 == 0x0088
0088 128 _TCON = 0x0088
0089 129 G$TMOD$0$0 == 0x0089
0089 130 _TMOD = 0x0089
008A 131 G$TL0$0$0 == 0x008a
008A 132 _TL0 = 0x008a
008B 133 G$TL1$0$0 == 0x008b
008B 134 _TL1 = 0x008b
008C 135 G$TH0$0$0 == 0x008c
008C 136 _TH0 = 0x008c
008D 137 G$TH1$0$0 == 0x008d
008D 138 _TH1 = 0x008d
0090 139 G$P1$0$0 == 0x0090
0090 140 _P1 = 0x0090
0098 141 G$SCON$0$0 == 0x0098
0098 142 _SCON = 0x0098
0099 143 G$SBUF$0$0 == 0x0099
0099 144 _SBUF = 0x0099
00A0 145 G$P2$0$0 == 0x00a0
00A0 146 _P2 = 0x00a0
00A8 147 G$IE$0$0 == 0x00a8
00A8 148 _IE = 0x00a8
00B0 149 G$P3$0$0 == 0x00b0
00B0 150 _P3 = 0x00b0
00B8 151 G$IP$0$0 == 0x00b8
00B8 152 _IP = 0x00b8
00D0 153 G$PSW$0$0 == 0x00d0
00D0 154 _PSW = 0x00d0
00E0 155 G$ACC$0$0 == 0x00e0
00E0 156 _ACC = 0x00e0
00E0 157 G$A$0$0 == 0x00e0
00E0 158 _A = 0x00e0
00F0 159 G$B$0$0 == 0x00f0
00F0 160 _B = 0x00f0
161 ;--------------------------------------------------------
162 ; special function bits
163 ;--------------------------------------------------------
164 .area RSEG (DATA)
0080 165 G$P0_0$0$0 == 0x0080
0080 166 _P0_0 = 0x0080
0081 167 G$P0_1$0$0 == 0x0081
0081 168 _P0_1 = 0x0081
0082 169 G$P0_2$0$0 == 0x0082
0082 170 _P0_2 = 0x0082
0083 171 G$P0_3$0$0 == 0x0083
0083 172 _P0_3 = 0x0083
0084 173 G$P0_4$0$0 == 0x0084
0084 174 _P0_4 = 0x0084
0085 175 G$P0_5$0$0 == 0x0085
0085 176 _P0_5 = 0x0085
0086 177 G$P0_6$0$0 == 0x0086
0086 178 _P0_6 = 0x0086
0087 179 G$P0_7$0$0 == 0x0087
0087 180 _P0_7 = 0x0087
0088 181 G$IT0$0$0 == 0x0088
0088 182 _IT0 = 0x0088
0089 183 G$IE0$0$0 == 0x0089
0089 184 _IE0 = 0x0089
008A 185 G$IT1$0$0 == 0x008a
008A 186 _IT1 = 0x008a
008B 187 G$IE1$0$0 == 0x008b
008B 188 _IE1 = 0x008b
008C 189 G$TR0$0$0 == 0x008c
008C 190 _TR0 = 0x008c
008D 191 G$TF0$0$0 == 0x008d
008D 192 _TF0 = 0x008d
008E 193 G$TR1$0$0 == 0x008e
008E 194 _TR1 = 0x008e
008F 195 G$TF1$0$0 == 0x008f
008F 196 _TF1 = 0x008f
0090 197 G$P1_0$0$0 == 0x0090
0090 198 _P1_0 = 0x0090
0091 199 G$P1_1$0$0 == 0x0091
0091 200 _P1_1 = 0x0091
0092 201 G$P1_2$0$0 == 0x0092
0092 202 _P1_2 = 0x0092
0093 203 G$P1_3$0$0 == 0x0093
0093 204 _P1_3 = 0x0093
0094 205 G$P1_4$0$0 == 0x0094
0094 206 _P1_4 = 0x0094
0095 207 G$P1_5$0$0 == 0x0095
0095 208 _P1_5 = 0x0095
0096 209 G$P1_6$0$0 == 0x0096
0096 210 _P1_6 = 0x0096
0097 211 G$P1_7$0$0 == 0x0097
0097 212 _P1_7 = 0x0097
0098 213 G$RI$0$0 == 0x0098
0098 214 _RI = 0x0098
0099 215 G$TI$0$0 == 0x0099
0099 216 _TI = 0x0099
009A 217 G$RB8$0$0 == 0x009a
009A 218 _RB8 = 0x009a
009B 219 G$TB8$0$0 == 0x009b
009B 220 _TB8 = 0x009b
009C 221 G$REN$0$0 == 0x009c
009C 222 _REN = 0x009c
009D 223 G$SM2$0$0 == 0x009d
009D 224 _SM2 = 0x009d
009E 225 G$SM1$0$0 == 0x009e
009E 226 _SM1 = 0x009e
009F 227 G$SM0$0$0 == 0x009f
009F 228 _SM0 = 0x009f
00A0 229 G$P2_0$0$0 == 0x00a0
00A0 230 _P2_0 = 0x00a0
00A1 231 G$P2_1$0$0 == 0x00a1
00A1 232 _P2_1 = 0x00a1
00A2 233 G$P2_2$0$0 == 0x00a2
00A2 234 _P2_2 = 0x00a2
00A3 235 G$P2_3$0$0 == 0x00a3
00A3 236 _P2_3 = 0x00a3
00A4 237 G$P2_4$0$0 == 0x00a4
00A4 238 _P2_4 = 0x00a4
00A5 239 G$P2_5$0$0 == 0x00a5
00A5 240 _P2_5 = 0x00a5
00A6 241 G$P2_6$0$0 == 0x00a6
00A6 242 _P2_6 = 0x00a6
00A7 243 G$P2_7$0$0 == 0x00a7
00A7 244 _P2_7 = 0x00a7
00A8 245 G$EX0$0$0 == 0x00a8
00A8 246 _EX0 = 0x00a8
00A9 247 G$ET0$0$0 == 0x00a9
00A9 248 _ET0 = 0x00a9
00AA 249 G$EX1$0$0 == 0x00aa
00AA 250 _EX1 = 0x00aa
00AB 251 G$ET1$0$0 == 0x00ab
00AB 252 _ET1 = 0x00ab
00AC 253 G$ES$0$0 == 0x00ac
00AC 254 _ES = 0x00ac
00AF 255 G$EA$0$0 == 0x00af
00AF 256 _EA = 0x00af
00B0 257 G$P3_0$0$0 == 0x00b0
00B0 258 _P3_0 = 0x00b0
00B1 259 G$P3_1$0$0 == 0x00b1
00B1 260 _P3_1 = 0x00b1
00B2 261 G$P3_2$0$0 == 0x00b2
00B2 262 _P3_2 = 0x00b2
00B3 263 G$P3_3$0$0 == 0x00b3
00B3 264 _P3_3 = 0x00b3
00B4 265 G$P3_4$0$0 == 0x00b4
00B4 266 _P3_4 = 0x00b4
00B5 267 G$P3_5$0$0 == 0x00b5
00B5 268 _P3_5 = 0x00b5
00B6 269 G$P3_6$0$0 == 0x00b6
00B6 270 _P3_6 = 0x00b6
00B7 271 G$P3_7$0$0 == 0x00b7
00B7 272 _P3_7 = 0x00b7
00B0 273 G$RXD$0$0 == 0x00b0
00B0 274 _RXD = 0x00b0
00B1 275 G$TXD$0$0 == 0x00b1
00B1 276 _TXD = 0x00b1
00B2 277 G$INT0$0$0 == 0x00b2
00B2 278 _INT0 = 0x00b2
00B3 279 G$INT1$0$0 == 0x00b3
00B3 280 _INT1 = 0x00b3
00B4 281 G$T0$0$0 == 0x00b4
00B4 282 _T0 = 0x00b4
00B5 283 G$T1$0$0 == 0x00b5
00B5 284 _T1 = 0x00b5
00B6 285 G$WR$0$0 == 0x00b6
00B6 286 _WR = 0x00b6
00B7 287 G$RD$0$0 == 0x00b7
00B7 288 _RD = 0x00b7
00B8 289 G$PX0$0$0 == 0x00b8
00B8 290 _PX0 = 0x00b8
00B9 291 G$PT0$0$0 == 0x00b9
00B9 292 _PT0 = 0x00b9
00BA 293 G$PX1$0$0 == 0x00ba
00BA 294 _PX1 = 0x00ba
00BB 295 G$PT1$0$0 == 0x00bb
00BB 296 _PT1 = 0x00bb
00BC 297 G$PS$0$0 == 0x00bc
00BC 298 _PS = 0x00bc
00D0 299 G$P$0$0 == 0x00d0
00D0 300 _P = 0x00d0
00D1 301 G$FL$0$0 == 0x00d1
00D1 302 _FL = 0x00d1
00D2 303 G$OV$0$0 == 0x00d2
00D2 304 _OV = 0x00d2
00D3 305 G$RS0$0$0 == 0x00d3
00D3 306 _RS0 = 0x00d3
00D4 307 G$RS1$0$0 == 0x00d4
00D4 308 _RS1 = 0x00d4
00D5 309 G$F0$0$0 == 0x00d5
00D5 310 _F0 = 0x00d5
00D6 311 G$AC$0$0 == 0x00d6
00D6 312 _AC = 0x00d6
00D7 313 G$CY$0$0 == 0x00d7
00D7 314 _CY = 0x00d7
315 ;--------------------------------------------------------
316 ; overlayable register banks
317 ;--------------------------------------------------------
318 .area REG_BANK_0 (REL,OVR,DATA)
0000 319 .ds 8
320 ;--------------------------------------------------------
321 ; internal ram data
322 ;--------------------------------------------------------
323 .area DSEG (DATA)
0000 324 G$some_variable$0$0==.
0000 325 _some_variable::
0000 326 .ds 4
0004 327 G$i$0$0==.
0004 328 _i::
0004 329 .ds 2
330 ;--------------------------------------------------------
331 ; overlayable items in internal ram
332 ;--------------------------------------------------------
333 .area OSEG (OVR,DATA)
334 ;--------------------------------------------------------
335 ; Stack segment in internal ram
336 ;--------------------------------------------------------
337 .area SSEG (DATA)
0000 338 __start__stack:
0000 339 .ds 1
340
341 ;--------------------------------------------------------
342 ; indirectly addressable internal ram data
343 ;--------------------------------------------------------
344 .area ISEG (DATA)
345 ;--------------------------------------------------------
346 ; absolute internal ram data
347 ;--------------------------------------------------------
348 .area IABS (ABS,DATA)
349 .area IABS (ABS,DATA)
350 ;--------------------------------------------------------
351 ; bit data
352 ;--------------------------------------------------------
353 .area BSEG (BIT)
354 ;--------------------------------------------------------
355 ; paged external ram data
356 ;--------------------------------------------------------
357 .area PSEG (PAG,XDATA)
358 ;--------------------------------------------------------
359 ; external ram data
360 ;--------------------------------------------------------
361 .area XSEG (XDATA)
362 ;--------------------------------------------------------
363 ; absolute external ram data
364 ;--------------------------------------------------------
365 .area XABS (ABS,XDATA)
366 ;--------------------------------------------------------
367 ; external initialized ram data
368 ;--------------------------------------------------------
369 .area XISEG (XDATA)
370 .area HOME (CODE)
371 .area GSINIT0 (CODE)
372 .area GSINIT1 (CODE)
373 .area GSINIT2 (CODE)
374 .area GSINIT3 (CODE)
375 .area GSINIT4 (CODE)
376 .area GSINIT5 (CODE)
377 .area GSINIT (CODE)
378 .area GSFINAL (CODE)
379 .area CSEG (CODE)
380 ;--------------------------------------------------------
381 ; interrupt vector
382 ;--------------------------------------------------------
383 .area HOME (CODE)
0000 384 __interrupt_vect:
0000 02s00r00 385 ljmp __sdcc_gsinit_startup
386 ;--------------------------------------------------------
387 ; global & static initialisations
388 ;--------------------------------------------------------
389 .area HOME (CODE)
390 .area GSINIT (CODE)
391 .area GSFINAL (CODE)
392 .area GSINIT (CODE)
393 .globl __sdcc_gsinit_startup
394 .globl __sdcc_program_startup
395 .globl __start__stack
396 .globl __mcs51_genXINIT
397 .globl __mcs51_genXRAMCLEAR
398 .globl __mcs51_genRAMCLEAR
0000 399 G$main$0$0 ==.
0000 400 C$demo_c_0.c$10$1$1 ==.
401 ; demo_c_0.c:10: unsigned long some_variable=0; ///< Documentation for this variable comes here
0000 E4 402 clr a
0001 F5*00 403 mov _some_variable,a
0003 F5*01 404 mov (_some_variable + 1),a
0005 F5*02 405 mov (_some_variable + 2),a
0007 F5*03 406 mov (_some_variable + 3),a
407 .area GSFINAL (CODE)
0000 02s00r03 408 ljmp __sdcc_program_startup
409 ;--------------------------------------------------------
410 ; Home
411 ;--------------------------------------------------------
412 .area HOME (CODE)
413 .area HOME (CODE)
0003 414 __sdcc_program_startup:
0003 12s00r0A 415 lcall _main
416 ; return from main will lock up
0006 80 FE 417 sjmp .
418 ;--------------------------------------------------------
419 ; code
420 ;--------------------------------------------------------
421 .area CSEG (CODE)
422 ;------------------------------------------------------------
423 ;Allocation info for local variables in function 'someFunction'
424 ;------------------------------------------------------------
425 ;somevalue Allocated to registers r2
426 ;------------------------------------------------------------
0000 427 G$someFunction$0$0 ==.
0000 428 C$demo_c_0.c$20$0$0 ==.
429 ; demo_c_0.c:20: void someFunction(unsigned char somevalue)
430 ; -----------------------------------------
431 ; function someFunction
432 ; -----------------------------------------
0000 433 _someFunction:
0002 434 ar2 = 0x02
0003 435 ar3 = 0x03
0004 436 ar4 = 0x04
0005 437 ar5 = 0x05
0006 438 ar6 = 0x06
0007 439 ar7 = 0x07
0000 440 ar0 = 0x00
0001 441 ar1 = 0x01
0000 AA 82 442 mov r2,dpl
0002 443 C$demo_c_0.c$23$1$1 ==.
444 ; demo_c_0.c:23: P1=somevalue;
0002 8A 90 445 mov _P1,r2
0004 446 C$demo_c_0.c$24$1$1 ==.
447 ; demo_c_0.c:24: P3=somevalue^0xFF;
0004 74 FF 448 mov a,#0xFF
0006 6A 449 xrl a,r2
0007 F5 B0 450 mov _P3,a
0009 451 C$demo_c_0.c$25$1$1 ==.
0009 452 XG$someFunction$0$0 ==.
0009 22 453 ret
454 ;------------------------------------------------------------
455 ;Allocation info for local variables in function 'main'
456 ;------------------------------------------------------------
457 ;------------------------------------------------------------
000A 458 G$main$0$0 ==.
000A 459 C$demo_c_0.c$28$1$1 ==.
460 ; demo_c_0.c:28: int main()
461 ; -----------------------------------------
462 ; function main
463 ; -----------------------------------------
000A 464 _main:
000A 465 C$demo_c_0.c$31$1$1 ==.
466 ; demo_c_0.c:31: while(1) {
000A 467 00102$:
000A 468 C$demo_c_0.c$32$2$2 ==.
469 ; demo_c_0.c:32: for(i=0; i<255; i++) {
000A E4 470 clr a
000B F5*04 471 mov _i,a
000D F5*05 472 mov (_i + 1),a
000F 473 00104$:
000F C3 474 clr c
0010 E5*04 475 mov a,_i
0012 94 FF 476 subb a,#0xFF
0014 E5*05 477 mov a,(_i + 1)
0016 64 80 478 xrl a,#0x80
0018 94 80 479 subb a,#0x80
001A 50 26 480 jnc 00107$
001C 481 C$demo_c_0.c$33$3$3 ==.
482 ; demo_c_0.c:33: someFunction(i+2);
001C AA*04 483 mov r2,_i
001E 74 02 484 mov a,#0x02
0020 2A 485 add a,r2
0021 F5 82 486 mov dpl,a
0023 12s00r00 487 lcall _someFunction
0026 488 C$demo_c_0.c$34$3$3 ==.
489 ; demo_c_0.c:34: some_variable++;
0026 05*00 490 inc _some_variable
0028 E4 491 clr a
0029 B5*00 0C 492 cjne a,_some_variable,00114$
002C 05*01 493 inc (_some_variable + 1)
002E B5*01 07 494 cjne a,(_some_variable + 1),00114$
0031 05*02 495 inc (_some_variable + 2)
0033 B5*02 02 496 cjne a,(_some_variable + 2),00114$
0036 05*03 497 inc (_some_variable + 3)
0038 498 00114$:
0038 499 C$demo_c_0.c$32$2$2 ==.
500 ; demo_c_0.c:32: for(i=0; i<255; i++) {
0038 05*04 501 inc _i
003A E4 502 clr a
003B B5*04 D1 503 cjne a,_i,00104$
003E 05*05 504 inc (_i + 1)
0040 80 CD 505 sjmp 00104$
0042 506 00107$:
0042 507 C$demo_c_0.c$36$2$2 ==.
508 ; demo_c_0.c:36: some_variable-=22;
0042 E5*00 509 mov a,_some_variable
0044 24 EA 510 add a,#0xea
0046 F5*00 511 mov _some_variable,a
0048 E5*01 512 mov a,(_some_variable + 1)
004A 34 FF 513 addc a,#0xff
004C F5*01 514 mov (_some_variable + 1),a
004E E5*02 515 mov a,(_some_variable + 2)
0050 34 FF 516 addc a,#0xff
0052 F5*02 517 mov (_some_variable + 2),a
0054 E5*03 518 mov a,(_some_variable + 3)
0056 34 FF 519 addc a,#0xff
0058 F5*03 520 mov (_some_variable + 3),a
005A 521 C$demo_c_0.c$40$1$1 ==.
522 ; demo_c_0.c:40: return 0;
005A 523 C$demo_c_0.c$41$1$1 ==.
005A 524 XG$main$0$0 ==.
005A 80 AE 525 sjmp 00102$
526 .area CSEG (CODE)
527 .area CONST (CODE)
528 .area XINIT (CODE)
529 .area CABS (ABS,CODE)
|