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
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.
Yes I know that PUSH and POP are THUMB instructions...I have given BX R12 and if I am correct this will change the compiler to THUMB mode. looking for help.
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.