|
本帖最后由 linux_Ultra 于 2009-7-27 14:46 編輯
armcc 和 arm-elf-gcc 那個好些?
都是在win xp 平臺下,
arm出的編譯器(從 ads1.2 目錄里,弄出來的)---armcc。
gnu的編譯器--- arm-elf-gcc 。
對比了一下,gnu的編譯器產生的匯編代碼,語法雖然是不同平臺,但比較統一,arm上和x86上都差不多,偽指令基本都一樣,風格也一樣。
- 編譯一個 簡單的 c 代碼:
- --------------------------------------------------------------------------------------
- int a= 123;
- int b[] = {1, 2, 3, 4};
- char ch[] = "AAAAAA";
- int main(void)
- {
- int a = 456;
- int b[] = {5, 6, 7, 8};
- char ch[] = "aaaaaa";
-
- return 0;
- }
- --------------------------------------------------------------------------------------
- 先在debian5.0上用gcc4.3.2編:
- gcc -Wall -S -O0 1.c -o app_gcc.S
- --------------------------------------------------------------------------------------
- .file "1.c"
- .globl a
- .data
- .align 4
- .type a, @object
- .size a, 4
- a:
- .long 123
- .globl b
- .align 4
- .type b, @object
- .size b, 16
- b:
- .long 1
- .long 2
- .long 3
- .long 4
- .globl ch
- .type ch, @object
- .size ch, 7
- ch:
- .string "AAAAAA"
- .text
- .globl main
- .type main, @function
- main:
- leal 4(%esp), %ecx
- andl $-16, %esp
- pushl -4(%ecx)
- pushl %ebp
- movl %esp, %ebp
- pushl %ecx
- subl $32, %esp
- movl $456, -8(%ebp)
- movl $5, -24(%ebp)
- movl $6, -20(%ebp)
- movl $7, -16(%ebp)
- movl $8, -12(%ebp)
- movl $1633771873, -31(%ebp)
- movw $24929, -27(%ebp)
- movb $0, -25(%ebp)
- movl $0, %eax
- addl $32, %esp
- popl %ecx
- popl %ebp
- leal -4(%ecx), %esp
- ret
- .size main, .-main
- .ident "GCC: (Debian 4.3.2-1.1) 4.3.2"
- .section .note.GNU-stack,"",@progbits
- --------------------------------------------------------------------------------------
- 在win xp上用arm-elf-gcc編。
- arm-elf-gcc -Wall -S -O0 1.c -o app_armgcc.s
- --------------------------------------------------------------------------------------
- .file "1.c"
- .global a
- .data
- .align 2
- .type a, %object
- .size a, 4
- a:
- .word 123
- .global b
- .align 2
- .type b, %object
- .size b, 16
- b:
- .word 1
- .word 2
- .word 3
- .word 4
- .global ch
- .align 2
- .type ch, %object
- .size ch, 7
- ch:
- .ascii "AAAAAA\000"
- .section .rodata
- .align 2
- .type C.0.1181, %object
- .size C.0.1181, 16
- C.0.1181:
- .word 5
- .word 6
- .word 7
- .word 8
- .align 2
- .LC0:
- .ascii "aaaaaa\000"
- .text
- .align 2
- .global main
- .type main, %function
- main:
- @ args = 0, pretend = 0, frame = 28
- @ frame_needed = 1, uses_anonymous_args = 0
- mov ip, sp
- stmfd sp!, {fp, ip, lr, pc}
- sub fp, ip, #4
- sub sp, sp, #28
- mov r3, #456
- str r3, [fp, #-16]
- ldr r3, .L3
- sub ip, fp, #32
- ldmia r3, {r0, r1, r2, r3}
- stmia ip, {r0, r1, r2, r3}
- ldr r3, .L3+4
- sub r2, fp, #39
- mov ip, #7
- mov r0, r2
- mov r1, r3
- mov r2, ip
- bl memcpy
- mov r3, #0
- mov r0, r3
- sub sp, fp, #12
- ldmfd sp, {fp, sp, pc}
- .L4:
- .align 2
- .L3:
- .word C.0.1181
- .word .LC0
- .size main, .-main
- .ident "GCC: (GNU) 4.3.2"
- --------------------------------------------------------------------------------------
- 在win xp上用armcc編。
- armcc -S -O0 1.c -o app_armcc.s
- --------------------------------------------------------------------------------------
- ; generated by ARM C Compiler, ADS1.2 [Build 805]
- ; commandline [-O0 -S "-IC:\Program Files\ARM\ADSv1_2\INCLUDE"]
- CODE32
- AREA ||.text||, CODE, READONLY
- main PROC
- |L1.0|
- STR lr,[sp,#-4]!
- SUB sp,sp,#0x18
- MOV lr,#0x1c8
- LDR r1,|L1.60|
- ADD r0,sp,#8
- LDMIA r1,{r1-r3,r12}
- STMIA r0,{r1-r3,r12}
- LDR r0,|L1.64|
- LDR r1,[r0,#0] ; ,
- LDR r0,[r0,#4]
- STR r0,[sp,#4]
- STR r1,[sp,#0]
- MOV r0,#0
- ADD sp,sp,#0x18
- LDR pc,[sp],#4
- |L1.60|
- DCD ||.constdata$1||
- |L1.64|
- DCD ||.constdata$1|| + 16
- ENDP
- AREA ||.data||, DATA, ALIGN=2
- ||.data$0||
- a
- DCD 0x0000007b
- b
- DCD 0x00000001
- DCD 0x00000002
- DCD 0x00000003
- DCD 0x00000004
- ||ch||
- DCB 0x41,0x41,0x41,0x41
- DCB 0x41,0x41,0x00
- DCB 0x00
- AREA ||.constdata||, DATA, READONLY, ALIGN=2
- ||.constdata$1||
- DCD 0x00000005
- DCD 0x00000006
- DCD 0x00000007
- DCD 0x00000008
- DCB 0x61,0x61,0x61,0x61
- DCB 0x61,0x61,0x00
- DCB 0x00
- EXPORT main
- EXPORT ||ch||
- EXPORT b
- EXPORT a
- IMPORT _main
- IMPORT __main
- IMPORT ||Lib$Request$armlib||, WEAK
- KEEP ||BuildAttributes$ARM_ISAv4$M$PE$A:L22$X:L11$S22$~IW$USESV6$~STKCKD$USESV7$~SHL$OSPACE$PRES8||
- ||BuildAttributes$ARM_ISAv4$M$PE$A:L22$X:L11$S22$~IW$USESV6$~STKCKD$USESV7$~SHL$OSPACE$PRES8|| EQU 0
- ASSERT {ENDIAN} = "little"
- ASSERT {SWST} = {FALSE}
- ASSERT {NOSWST} = {TRUE}
- ASSERT {INTER} = {FALSE}
- ASSERT {ROPI} = {FALSE}
- ASSERT {RWPI} = {FALSE}
- ASSERT {NOT_SHL} = {TRUE}
- ASSERT {FULL_IEEE} = {FALSE}
- ASSERT {SHL1} = {FALSE}
- ASSERT {SHL2} = {FALSE}
- END
- --------------------------------------------------------------------------------------
復制代碼 |
|