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
  • PUSH and POP are THUMB instructions.

    You need to switch the mode of the assembler before assembling the second section.

    The syntax error is because the assembler is trying to assemble these instructions as ARM instructions.

    Your assembler manual will tell you how to switch the mode.

Reply
  • PUSH and POP are THUMB instructions.

    You need to switch the mode of the assembler before assembling the second section.

    The syntax error is because the assembler is trying to assemble these instructions as ARM instructions.

    Your assembler manual will tell you how to switch the mode.

Children