This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BX instruction in ARM mode

Hello all,

I want to run a part of the program in ARM mode and the remaining part of the program in THUMB mode.In the code that is below i want to run the main code in ARM mode and the Check_val part code in THUMB mode.When i compile the program I am getting system

error A9: SYNTAX ERROR which points to PUSH and POP instructions in the code.
Whats the problem in my code?

Looking for your help.


;ARM mode code

main
	ADD       R0,R13,#0x00000008
	LDR R12,=Check_val
	BX       r12
	ADD       R1,R13,#0x0000000C
	LDR       R4,[R1]
	MOV       R1,R4
	BHI       Check_flag
	MOV       R1,#0x00000001
	ADD       R0,R13,#0x00000014
	STR       R1,[R0]

;thumb mode execution program
Check_val

	PUSH      {R4,LR}
	ADD       R2,R0,#0
	MOV       R4,#0x07
 	ADD       R1,R2,#04
	Beq         main
        POP       {R4}
        POP       {R3}
        BX        R3

Parents Reply Children
  • BX R12 will potentially change the processor mode depending on R12.0 but that is nothing to do with the assembler mode.

    For example for GNU, the following directives are used to switch mode
    .code [16|32]
    .thumb
    .arm
    .force_thumb
    .thumb_func

    For RealView
    ARM
    THUMB
    THUMBX
    CODE16
    CODE32

    Again, check your manual for the correct directive for your assembler.