what's wrong with asm(gun gcc) on stm32?

Status
Not open for further replies.

chxgzl4862

Member level 1
Joined
Aug 6, 2008
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,581
/*test.S*/
.equ STACK_TOP, 0x20000800
.equ BIT1, 0x00000002
.equ BIT2, 0x00000004
.equ BIT5, 0x00000020
.equ BIT6, 0x00000040
.equ BIT8, 0x00000100
.equ BIT9, 0x00000200

.equ LED1, BIT1
.equ LED2, BIT6
.equ LED3, BIT8

.equ GPIOA, 0X40010800
.equ GPIOA_CRL, 0X40010800
.equ GPIOA_CRH, 0X40010804
.equ GPIOA_IDR, 0X40010808
.equ GPIOA_ODR, 0X4001080C
.equ GPIOA_BSRR, 0X40010810
.equ GPIOA_BRR, 0X40010814
.equ IOPAEN, BIT2
.equ RCC_APB2ENR, 0X40021018

.equ __initial_sp, 0x20000400

.text
.global _start

.code 16
.syntax unified

.type start, function

_start:
.word STACK_TOP
.word 0x08000000 + 0x09
b reset

.globl _TEXT_BASE
_TEXT_BASE:
.word 0x08000000

.globl _armboot_start
_armboot_start:
.word _start

reset:
/*.word STACK_TOP
.word 0x08000000 + 0x09*/
ldr r1,=RCC_APB2ENR
ldr r0,[r1]
ldr r2,=IOPAEN
orr r0,r2
str r0,[r1]

ldr r1,=GPIOA_CRL
ldr r2,=0x33333333
str r2,[r1]
loop:
mov r0,#0x00000002
ldr r1,=GPIOA_BRR
str r0,[r1]

bl delay

mov r0,#0x00000040
ldr r1,=GPIOA_BSRR
str r0,[r1]

bl delay

mov r0,#0x00000002
ldr r1,=GPIOA_BSRR
str r0,[r1]

bl delay

mov r0,#0x00000040
ldr r1,=GPIOA_BRR
str r0,[r1]

bl delay

b loop


#delay.S#
.globl delay
delay:
push {r1}

delay_loop0:
sub r0,#1
movw r1,#2240
delay_loop1:
sub r1,#1
nop
cmp r1,#0
bne delay_loop1
cmp r0,#0
bne delay_loop0

pop {r1}
bx lr

#test.ld
/**/
SECTIONS
{
. = 0x0;
.text : {
test.o (.text)
*(.text) }

. = 0x20000000; .data : {
*(.data) }

.bss : {
*(.bss) }
}

#makefile
PRO_NAME = test

SRCS = test.S delay.S

OBJS = test.o

LDS = test.ld



COMPILE_CROSS = arm-none-eabi-



PRO_OUT = $(PRO_NAME).out

PRO_BIN = $(PRO_NAME).bin

PRO_LIST = $(PRO_NAME).list



AS = $(COMPILE_CROSS)as

ASFLAGS = -mcpu=cortex-m3 -mthumb



LD = $(COMPILE_CROSS)ld

LDFLAGS = -T $(LDS)



OBJCP = $(COMPILE_CROSS)objcopy

OBJCPFLAGS = -O binary



OBJDUMP = $(COMPILE_CROSS)objdump

DUMPFLAGS = -S



all: $(PRO_BIN) $(PRO_LIST) $(PRO_OUT)



$(PRO_BIN): $(PRO_OUT)

$(OBJCP) $(OBJCPFLAGS) $< $@



$(PRO_LIST): $(PRO_OUT)

$(OBJDUMP) $(DUMPFLAGS) $< > $@



$(PRO_OUT): $(OBJS)

$(LD) $(LDFLAGS) -o $@ $<

readelf -S $@



$(OBJS): $(SRCS)

$(AS) $(ASFLAGS) $? -o $@



.PHONY : clean

clean:

-rm -rf *.o *out *bin *.list

#######################################################
test.out: file format elf32-littlearm


Disassembly of section .text:

00000000 <_start>:
0: 0800 .short 0x0800
2: 2000 .short 0x2000
4: 08000009 .word 0x08000009
8: e003 b.n 12 <reset>

0000000a <_TEXT_BASE>:
a: 0000 .short 0x0000
c: 0800 .short 0x0800

0000000e <_armboot_start>:
e: 0000 .short 0x0000
...

00000012 <reset>:
12: 4911 ldr r1, [pc, #68] (58 <BIT6+0x18>)
14: 6808 ldr r0, [r1, #0]
16: 4a11 ldr r2, [pc, #68] (5c <BIT6+0x1c>)
18: ea40 0002 orr.w r0, r0, r2
1c: 6008 str r0, [r1, #0]
1e: 4910 ldr r1, [pc, #64] (60 <BIT6+0x20>)
20: 4a10 ldr r2, [pc, #64] (64 <BIT6+0x24>)
22: 600a str r2, [r1, #0]

00000024 <loop>:
24: f04f 0002 mov.w r0, #2 ; 0x2
28: 490f ldr r1, [pc, #60] (68 <BIT6+0x28>)
2a: 6008 str r0, [r1, #0]
2c: f000 e820 blx 70 <delay>
30: f04f 0040 mov.w r0, #64 ; 0x40
34: 490d ldr r1, [pc, #52] (6c <BIT6+0x2c>)
36: 6008 str r0, [r1, #0]
38: f000 e81a blx 70 <delay>
3c: f04f 0002 mov.w r0, #2 ; 0x2
40: 490a ldr r1, [pc, #40] (6c <BIT6+0x2c>)
42: 6008 str r0, [r1, #0]
44: f000 e814 blx 70 <delay>
48: f04f 0040 mov.w r0, #64 ; 0x40
4c: 4906 ldr r1, [pc, #24] (68 <BIT6+0x28>)
4e: 6008 str r0, [r1, #0]
50: f000 e80e blx 70 <delay>
54: e7e6 b.n 24 <loop>
56: 0000 .short 0x0000
58: 40021018 .word 0x40021018
5c: 00000004 .word 0x00000004
60: 40010800 .word 0x40010800
64: 33333333 .word 0x33333333
68: 40010814 .word 0x40010814
6c: 40010810 .word 0x40010810

00000070 <delay>:
70: b402 push {r1}

00000072 <delay_loop0>:
72: f1a0 0001 sub.w r0, r0, #1 ; 0x1
76: f640 01c0 movw r1, #2240 ; 0x8c0

0000007a <delay_loop1>:
7a: f1a1 0101 sub.w r1, r1, #1 ; 0x1
7e: bf00 nop
80: 2900 cmp r1, #0
82: d1fa bne.n 7a <delay_loop1>
84: 2800 cmp r0, #0
86: d1f4 bne.n 72 <delay_loop0>
88: bc02 pop {r1}
8a: 4770 bx lr

###################################
the code is not run i delay?
i don't konow what's wrong wit it?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…