how to write asm for stm32f103 using GNU ARM Embedded Toolchain

Asked by fanus on 2017-05-05

here is my code:
 PUBLIC hal_enter_critical
 PUBLIC hal_exit_critical
 PUBLIC hal_app_jump

 RSEG CODE:CODE:NOROOT(2)

hal_enter_critical
        PUSH {R1,R2}
        MRS R1, PRIMASK
        MOV R2, #0x01
        TST R0, #0xFF
        ITE EQ
        MSREQ PRIMASK, R2
        MSRNE BASEPRI, R0
        MOV R0, R1
        POP {R1,R2}
        BX LR

hal_exit_critical
        MSR PRIMASK, R0
        MOV R0, #0x00
        MSR BASEPRI, R0
        BX LR

hal_app_jump
    CPSID I
    LDR R1, =0xE000ED08
    STR R0, [R1]

    MOV R2, #0x00
    MSR CONTROL, R2

    LDR R1, [R0]
    MOV SP, R1

    LDR R0, [R0, #4]
    BX R0

 END

it is fine when I am using IAR, but now I have to use contiki , which means I must use GNU ARM Embedded Toolchain ,and I dont know how to CC that file, and so confuse about the rules, could you please help me about that? I dont know where to start, and how to fix that bad instruction problem
./../cpu/arm/stm32f103/core/hal_io_asm.S: Assembler messages:
../../cpu/arm/stm32f103/core/hal_io_asm.S:1: Error: bad instruction `public hal_enter_critical'
../../cpu/arm/stm32f103/core/hal_io_asm.S:2: Error: bad instruction `public hal_exit_critical'
../../cpu/arm/stm32f103/core/hal_io_asm.S:3: Error: bad instruction `public hal_app_jump'
../../cpu/arm/stm32f103/core/hal_io_asm.S:5: Error: bad instruction `rseg CODE:CODE:NOROOT(2)'
../../cpu/arm/stm32f103/core/hal_io_asm.S:8: Error: bad instruction `hal_enter_critical'
../../cpu/arm/stm32f103/core/hal_io_asm.S:12: Error: unshifted register required -- `tst R0,#0xFF'
../../cpu/arm/stm32f103/core/hal_io_asm.S:14: Error: Thumb does not support conditional execution
../../cpu/arm/stm32f103/core/hal_io_asm.S:15: Error: Thumb does not support conditional execution

Question information

Language:
English Edit question
Status:
Answered
For:
GNU ARM Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2017-05-05
Last reply:
2017-05-05
Tejas Belagod (belagod-tejas) said : #1

This does not look like GAS syntax.

Hi Fanus,

I'd suggest you to start by compiling with -S a simple C file and you'll see what assembly is generated. For the function, you want to replace the public FOO by something like:

.align 2
.global foo
.type foo, %function
foo:
  //code
.size foo, .-foo

Best regards.

Can you help with this problem?

Provide an answer of your own, or ask fanus for more information if necessary.

To post a message you must log in.