Ask a simple question
I'm reading arch/arm/boot/compressed/head.s, and have a question about the following codes:
ARM( mov r0, r0 )
ARM( b 1f )
THUMB( adr r12, BSYM(1f) )
THUMB( bx r12 )
what do "ARM()" and "THUMB()" mean? Are they ARM directives or macro? where can I find the definition of them?
This has to do with the fact that the ARM chip has two
modes, one is the normal ARM mode and one is THUMB
mode. My guess is that those instructions are macros
to make the mode switch.
Thanks for your reply. I know ".arm" and ".thumb" are assembly directives for ARM and THUMB mode, but they are capital letters.
according to your remind, I searched all .h file, and I found where they are:
In arch/arm/include/asm/unified.h, there are several declaration. In short, if the cpu is Thumb2, use THUMB, otherwise ARM.
#if __GNUC__ < 4
#error Thumb-2 kernel requires gcc >= 4
/* The CPSR bit describing the instruction set (Thumb) */
#define PSR_ISETSTATE PSR_T_BIT
#define THUMB(x...) x
#define W(instr) instr.w
#define BSYM(sym) sym + 1
#else /* !CONFIG_THUMB2_KERNEL */
/* The CPSR bit describing the instruction set (ARM) */
#define PSR_ISETSTATE 0
#define ARM(x...) x
#define W(instr) instr
#define BSYM(sym) sym
#endif /* CONFIG_THUMB2_KERNEL */