Find the answer to your Linux question:
Results 1 to 3 of 3
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    2

    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?
    Thanks.

  2. #2
    Linux Engineer rcgreen's Avatar
    Join Date
    May 2006
    Location
    the hills
    Posts
    1,134
    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.

  3. #3
    Just Joined!
    Join Date
    Dec 2011
    Posts
    2
    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.

    #ifdef CONFIG_THUMB2_KERNEL

    #if __GNUC__ < 4
    #error Thumb-2 kernel requires gcc >= 4
    #endif

    /* The CPSR bit describing the instruction set (Thumb) */
    #define PSR_ISETSTATE PSR_T_BIT

    #define ARM(x...)
    #define THUMB(x...) x
    #ifdef __ASSEMBLY__
    #define W(instr) instr.w
    #endif
    #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 THUMB(x...)
    #ifdef __ASSEMBLY__
    #define W(instr) instr
    #endif
    #define BSYM(sym) sym

    #endif /* CONFIG_THUMB2_KERNEL */

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •