Chapter 5 Detailed Applications

- 85 -

5.8.1 C Language Startup Program (crt0mr.a30)

Figure 5.14 C Language Startup Program (crt0mr.a30)

shows the C language startup program(crt0mr.a30).

1 ;****************************************************************
2 ;
3 ; MR308 start up program for C language
4 ; COPYRIGHT(C) 2003 RENESAS TECHNOLOGY CORPORATION
5 ; AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED
6 ; MR308 V.1.10 Release 1
7 ;
8 ; ****************************************************************
9 ; "$Id: crt0mr.a30,v 1.1 2005/05/20 06:28:47 inui Exp $"
10 ;*A1* 2005-02-28 for ES
11 ;
12 .LIST OFF
13 .INCLUDE c_sec.inc
14 .INCLUDE mr308.inc
15 .INCLUDE sys_rom.inc
16 .INCLUDE sys_ram.inc
17 .LIST ON
18
19 .GLB __SYS_INITIAL
20 .GLB __END_INIT
21 .GLB __init_sys,__init_tsk
22
23 .IF M16C70!=0
24 regoffset .EQU -0220H
25 .ELSE
26 regoffset .EQU 0
27 .ENDIF
28
29 ;-----------------------------------------------------------------
30 ; SBDATA area definition
31 ;-----------------------------------------------------------------
32 .GLB __SB__
33 .SB __SB__
34
35 ;=================================================================
36 ; Initialize Macro declaration
37 ;-----------------------------------------------------------------
38 N_BZERO .MACRO TOP_,SECT_
39 MOV.B #00H, R0L
40 MOV.L #TOP_, A1
41 MOV.W #sizeof SECT_, R3
42 SSTR.B
43 .ENDM
44
45 N_BCOPY .MACRO FROM_,TO_,SECT_
46 MOV.L #FROM_,A0
47 MOV.L #TO_,A1
48 MOV.W #sizeof SECT_, R3
49 SMOVF.B
50 .ENDM
51
52 BZERO .MACRO TOP_,SECT_
53 .local _end, _loop
54
55 MOV.L #TOP_, A1
56 MOV.B #00H, R0L
57 MOV.L #(sizeof SECT_ & 0FFFFFFH), R3R1
58 XCHG.W R1,R3
59 _loop:
60 SSTR.B
61 CMP.W #0,R1
62 JEQ _end
63 MOV.B R0L,[A1]
64 ADD.L #1,A1
65 MOV.W #0FFFFH,R3
66 SUB.W #1,R1
67 JMP _loop
68 _end:
69 .ENDM
70
71 BCOPY .MACRO FROM_,TO_,SECT_
72 .local _end, _loop