ARM Cortex-R: ldrbne and ldrbeq give "Error: bad instruction" despite being valid

Asked by Kit Sczudlo on 2015-10-06

When I attempt to use gcc to compile a *.S file containing the instructions ldrbne or ldrbeq it will not compile.

As an example:
tst.S:
------------------------------------------------
.text
.arm

.global _start
_start:
    ldrbne r12, [lr, #-4]
    ldrbeq r12, [lr, #-8]
------------------------------------------------
$ arm-none-eabi-gcc -march=armv7-r -mfpu=vfpv3-d16 -mfloat-abi=hard -Wall -Werror -Wextra -g -c -o tst.o tst.S
tst.S: Assembler messages:
tst.S:6: Error: bad instruction `ldrbne r12,[lr,#-4]'
tst.S:7: Error: bad instruction `ldrbeq r12,[lr,#-8]'
------------------------------------------------
$ arm-none-eabi-gcc -mcpu=cortex-r5 -Wall -Werror -Wextra -g -o tst.o -c tst.S
tst.S: Assembler messages:
tst.S:6: Error: bad instruction `ldrbne r12,[lr,#-4]'
tst.S:7: Error: bad instruction `ldrbeq r12,[lr,#-8]'
------------------------------------------------
The unconditional version: ldrb r12,[lr,#-4] compiles as expected.

As far as I can tell (looking at the arm documentation) this appears to be a valid use of the instruction. Is there some reason this shouldn't work?

Thank you in advanced!
--Kit

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Tejas Belagod
Solved:
Last query:
Last reply:
Best Tejas Belagod (belagod-tejas) said : #1

You need a '.syntax unified' in your code. If you don't specify this, it assumes you're giving the assembler pre-UAL syntax which is

        .text
        .arm
        .global _start
_start:
    ldrneb r12, [lr, #-4]
    ldreqb r12, [lr, #-8]

Kit Sczudlo (sczudlow) said : #2

Excellent, I was kind of shocked to think you guys might have missed a conditional operation. And now I know that there's a whole weird slice of assembler I should go dig into and understand.

Thank you for the quick response!

Kit Sczudlo (sczudlow) said : #3

Thanks Tejas Belagod, that solved my question.