📄 main.lst
字号:
ARM COMPILER V2.00f, main 19/02/05 11:56:34 PAGE 1
ARM COMPILER V2.00f, COMPILATION OF MODULE main
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe main.c THUMB BROWSE DEBUG TABS(4)
stmt level source
1 /************************************************************/
2 /* PROJECT NAME: API */
3 /* Project: LPC2100 Training course */
4 /* Engineer: T Martin tmartin@hitex.co.uk */
5 /* Filename: API.c */
6 /* Language: C */
7 /* Compiler: Keil ARM V2.00b */
8 /* Assembler: */
9 /* */
10 /************************************************************/
11 /* COPYRIGHT: Hitex UK Ltd 2005 */
12 /* LICENSE: THIS VERSION CREATED FOR FREE DISTRIBUTION */
13 /************************************************************/
14 /* Function: */
15 /* */
16 /* IAP Example */
17 /* */
18 /* Demonstrates use of the In Application Functions */
19 /* */
20 /* Oscillator frequency 12.000 Mhz */
21 /* Target board Keil MCB2100 */
22 /************************************************************/
23
24 typedef void (*IAP)(unsigned int [],unsigned int []);
25 IAP iap_bypointer;
26 void iap_byfunction (unsigned *cmd,unsigned *rslt,unsigned entry);
27
28 unsigned command[5];
29 unsigned result[5];
30 char Ram_Arry[] = "Hello World";
31 char *Ram_Pointer;
32
33
34 void main (void) __arm //Compile this in ARM instruction set
35 {
36 1 unsigned char index;
37 1
38 1 iap_bypointer = (IAP) 0x7FFFFFF1; //set IAP entry address in function pointer
39 1
40 1 Ram_Pointer = 0x40000100; //Set pointer to RAM
41 1 for (index = 0; index<0x0B; index++) //Copy data to be written to flash into the RAM
42 1 {
43 2 *Ram_Pointer = Ram_Arry[index];
44 2 Ram_Pointer++;
45 2 }
46 1
47 1 command[0] = 0x36; //command code for "Read part ID"
48 1 iap_byfunction(command,result,0x7FFFFFF0); //Call IAP functions by function method
49 1
50 1
51 1 command[0] = 50; //Prepare sector five for a write operayion
52 1 command[1] = 5;
53 1 command[2] = 5;
54 1 iap_bypointer(command,result);
55 1
56 1 command[0] = 52; //erase sector five
57 1 command[1] = 5;
58 1 command[2] = 5;
59 1 command[3] = 12000;
ARM COMPILER V2.00f, main 19/02/05 11:56:34 PAGE 2
60 1 iap_bypointer(command,result);
61 1
62 1 command[0] = 50; //Prepare sector five for a write operayion
63 1 command[1] = 5;
64 1 command[2] = 5;
65 1 iap_bypointer(command,result);
66 1
67 1 command[0] = 51; //write 512 bytes from address 0x40000100
68 1 command[1] = 0x0000A000; //to 0x0000A000 in flash memory;
69 1 command[2] = 0x40000100;
70 1 command[3] = 512;
71 1 command[4] = 12000;
72 1 iap_byfunction(command,result,0x7FFFFFF0);
73 1
74 1 while(1)
75 1 {
76 2 ;
77 2 }
78 1
79 1 }
80
81 void iap_byfunction (unsigned *cmd,unsigned *rslt,unsigned entry) __thumb //compile this in Thumb instru
-ction set
82 {
83 1 __asm { mov r15,r2; } //move entry address into PC
84 1
85 1
86 1
87 1 }
ARM COMPILER V2.00f, main 19/02/05 11:56:34 PAGE 3
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN NUMBER (__startup)
*** PUBLICS:
PUBLIC iap_byfunction?T
PUBLIC iap_byfunction?A
PUBLIC main
PUBLIC iap_bypointer
PUBLIC command
PUBLIC result
PUBLIC Ram_Arry
PUBLIC Ram_Pointer
*** DATA SEGMENT '?DT0?main':
00000000 iap_bypointer:
00000000 DS 4
00000004 command:
00000004 DS 20
00000018 result:
00000018 DS 20
0000002C Ram_Pointer:
0000002C DS 4
00000030 Ram_Arry:
00000030 BEGIN_INIT
00000030 DB 'Hello World',0x00
0000003C END_INIT
*** CODE SEGMENT '?PR?main?main':
34: void main (void) __arm //Compile this in ARM instruction set
00000000 E92D4000 STMDB R13!,{LR}
35: {
00000004 ; SCOPE-START
38: iap_bypointer = (IAP) 0x7FFFFFF1; //set IAP entry address in function pointer
00000004 E3E0113A MVN R1,#0x8000000F
00000008 E5100000 LDR R0,=iap_bypointer ; iap_bypointer
0000000C E5801000 STR R1,[R0,#0x0] ; iap_bypointer
40: Ram_Pointer = 0x40000100; //Set pointer to RAM
00000010 E5101000 LDR R1,=0x40000100
00000014 E5100000 LDR R0,=Ram_Pointer ; Ram_Pointer
00000018 E5801000 STR R1,[R0,#0x0] ; Ram_Pointer
41: for (index = 0; index<0x0B; index++) //Copy data to be written to flash into the RAM
0000001C E3A00000 MOV R0,#0x0
00000020 ---- Variable 'index' assigned to Register 'R0' ----
00000020 EA00000B B L_3 ; Targ=0x54
00000024 L_4:
43: *Ram_Pointer = Ram_Arry[index];
00000024 E1A02C00 MOV R2,R0,LSL #24 ; index
00000028 E1A02C22 MOV R2,R2,LSR #24 ; index
0000002C E5101000 LDR R1,=Ram_Arry ; Ram_Arry
00000030 E7D12002 LDRB R2,[R1,+R2]
00000034 E5101000 LDR R1,=Ram_Pointer ; Ram_Pointer
00000038 E5911000 LDR R1,[R1,#0x0] ; Ram_Pointer
0000003C E5C12000 STRB R2,[R1,#0x0]
44: Ram_Pointer++;
00000040 E5101000 LDR R1,=Ram_Pointer ; Ram_Pointer
00000044 E5912000 LDR R2,[R1,#0x0] ; Ram_Pointer
00000048 E2822001 ADD R2,R2,#0x0001
0000004C E5812000 STR R2,[R1,#0x0] ; Ram_Pointer
45: }
00000050 E2800001 ADD R0,R0,#0x0001 ; index
00000054 L_3:
00000054 E1A01C00 MOV R1,R0,LSL #24 ; index
00000058 E1A01C21 MOV R1,R1,LSR #24 ; index
ARM COMPILER V2.00f, main 19/02/05 11:56:34 PAGE 4
0000005C E351000B CMP R1,#0x000B ; index
00000060 BAFFFFEF BLT L_4 ; Targ=0x24
47: command[0] = 0x36; //command code for "Read part ID"
00000064 E3A01036 MOV R1,#0x36
00000068 E5100000 LDR R0,=command ; command
0000006C E5801000 STR R1,[R0,#0x0] ; command
48: iap_byfunction(command,result,0x7FFFFFF0); //Call IAP functions by function method
00000070 E5100000 LDR R0,=command ; command
00000074 E5101000 LDR R1,=result ; result
00000078 E3E0213E MVN R2,#0x80000010
0000007C EBFFFFDF BL iap_byfunction?A ; Targ=0x0
51: command[0] = 50; //Prepare sector five for a write operayion
00000080 E3A01032 MOV R1,#0x32
00000084 E5100000 LDR R0,=command ; command
00000088 E5801000 STR R1,[R0,#0x0] ; command
52: command[1] = 5;
0000008C E3A01005 MOV R1,#0x5
00000090 E5100000 LDR R0,=command + 0x4 ; command+4
00000094 E5801000 STR R1,[R0,#0x0] ; command+4
53: command[2] = 5;
00000098 E3A01005 MOV R1,#0x5
0000009C E5100000 LDR R0,=command + 0x8 ; command+8
000000A0 E5801000 STR R1,[R0,#0x0] ; command+8
54: iap_bypointer(command,result);
000000A4 E5100000 LDR R0,=command ; command
000000A8 E5101000 LDR R1,=result ; result
000000AC E5102000 LDR R2,=iap_bypointer ; iap_bypointer
000000B0 E5922000 LDR R2,[R2,#0x0] ; iap_bypointer
000000B4 EB000000 BL L_16 ; Targ=0xBC
000000B8 EA000000 B L_17 ; Targ=0xC0
000000BC L_16:
000000BC E12FFF12 BX R2
000000C0 L_17:
56: command[0] = 52; //erase sector five
000000C0 E3A01034 MOV R1,#0x34
000000C4 E5100000 LDR R0,=command ; command
000000C8 E5801000 STR R1,[R0,#0x0] ; command
57: command[1] = 5;
000000CC E3A01005 MOV R1,#0x5
000000D0 E5100000 LDR R0,=command + 0x4 ; command+4
000000D4 E5801000 STR R1,[R0,#0x0] ; command+4
58: command[2] = 5;
000000D8 E3A01005 MOV R1,#0x5
000000DC E5100000 LDR R0,=command + 0x8 ; command+8
000000E0 E5801000 STR R1,[R0,#0x0] ; command+8
59: command[3] = 12000;
000000E4 E5101000 LDR R1,=0x2EE0
000000E8 E5100000 LDR R0,=command + 0xC ; command+12
000000EC E5801000 STR R1,[R0,#0x0] ; command+12
60: iap_bypointer(command,result);
000000F0 E5100000 LDR R0,=command ; command
000000F4 E5101000 LDR R1,=result ; result
000000F8 E5102000 LDR R2,=iap_bypointer ; iap_bypointer
000000FC E5922000 LDR R2,[R2,#0x0] ; iap_bypointer
00000100 EB000000 BL L_18 ; Targ=0x108
00000104 EA000000 B L_19 ; Targ=0x10C
00000108 L_18:
00000108 E12FFF12 BX R2
0000010C L_19:
62: command[0] = 50; //Prepare sector five for a write operayion
0000010C E3A01032 MOV R1,#0x32
00000110 E5100000 LDR R0,=command ; command
00000114 E5801000 STR R1,[R0,#0x0] ; command
63: command[1] = 5;
00000118 E3A01005 MOV R1,#0x5
0000011C E5100000 LDR R0,=command + 0x4 ; command+4
ARM COMPILER V2.00f, main 19/02/05 11:56:34 PAGE 5
00000120 E5801000 STR R1,[R0,#0x0] ; command+4
64: command[2] = 5;
00000124 E3A01005 MOV R1,#0x5
00000128 E5100000 LDR R0,=command + 0x8 ; command+8
0000012C E5801000 STR R1,[R0,#0x0] ; command+8
65: iap_bypointer(command,result);
00000130 E5100000 LDR R0,=command ; command
00000134 E5101000 LDR R1,=result ; result
00000138 E5102000 LDR R2,=iap_bypointer ; iap_bypointer
0000013C E5922000 LDR R2,[R2,#0x0] ; iap_bypointer
00000140 EB000000 BL L_20 ; Targ=0x148
00000144 EA000000 B L_21 ; Targ=0x14C
00000148 L_20:
00000148 E12FFF12 BX R2
0000014C L_21:
67: command[0] = 51; //write 512 bytes from address 0x40000100
0000014C E3A01033 MOV R1,#0x33
00000150 E5100000 LDR R0,=command ; command
00000154 E5801000 STR R1,[R0,#0x0] ; command
68: command[1] = 0x0000A000; //to 0x0000A000 in flash memory;
00000158 E3A01A0A MOV R1,#0xA000
0000015C E5100000 LDR R0,=command + 0x4 ; command+4
00000160 E5801000 STR R1,[R0,#0x0] ; command+4
69: command[2] = 0x40000100;
00000164 E5101000 LDR R1,=0x40000100
00000168 E5100000 LDR R0,=command + 0x8 ; command+8
0000016C E5801000 STR R1,[R0,#0x0] ; command+8
70: command[3] = 512;
00000170 E3A01C02 MOV R1,#0x200
00000174 E5100000 LDR R0,=command + 0xC ; command+12
00000178 E5801000 STR R1,[R0,#0x0] ; command+12
71: command[4] = 12000;
0000017C E5101000 LDR R1,=0x2EE0
00000180 E5100000 LDR R0,=command + 0x10 ; command+16
00000184 E5801000 STR R1,[R0,#0x0] ; command+16
72: iap_byfunction(command,result,0x7FFFFFF0);
00000188 E5100000 LDR R0,=command ; command
0000018C E5101000 LDR R1,=result ; result
00000190 E3E0213E MVN R2,#0x80000010
00000194 EBFFFF99 BL iap_byfunction?A ; Targ=0x0
77: }
00000198 L_6:
00000198 EAFFFFFE B L_6 ; Targ=0x198
0000019C ; SCOPE-END
0000019C E8BD0008 LDMIA R13!,{R3}
000001A0 E12FFF13 BX R3
000001A4 ENDP ; 'main'
*** CODE SEGMENT '?PR?iap_byfunction?T?main':
83: __asm { mov r15,r2; } //move entry address into PC
00000000 4697 MOV R15,R2
87: }
00000002 4770 BX R14
00000004 ENDP ; 'iap_byfunction?T'
Module Information Static
----------------------------------
code size = ------
data size = 60
const size = ------
End of Module Information.
ARM COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -