1

My arm assembly code is:

mov r1, #5
UBFX    r0, r1, #1, #1

When I try to compile it with arm-elf-gcc file.s It gives following error:

ass2_sample.s: Assembler messages:
ass2_sample.s:42: Error: bad instruction `ubfx r0,r1,#1,#1'

I am using GCC-3.4 toolchain. I can't understand where is the error.

Harshveer Singh
  • 4,037
  • 7
  • 37
  • 45

1 Answers1

3

What target are you compiling for? The documentation states:

These ARM instructions are available in ARMv6T2 and above.

These 32-bit Thumb instructions are available in ARMv6T2 and above.

There are no 16-bit Thumb versions of these instructions.

Community
  • 1
  • 1
unwind
  • 391,730
  • 64
  • 469
  • 606
  • I am using GNU Arm toolchain on 32 bit windows machine. – Harshveer Singh Oct 03 '12 at 10:28
  • And what does it mean, Can I use this instruction in my code (compiling on windows) or not? – Harshveer Singh Oct 03 '12 at 10:31
  • 1
    It means if your target is an ARM7-TDMI having v4T architecture you can't use this instruction, your arm-elf-gcc compiler also wouldn't recognize it. Target in this case is the embedded device that's going to run your code. – auselen Oct 03 '12 at 11:45
  • Reading from here http://stackoverflow.com/questions/8366625/arm-bit-field-extract, it should just set r0 to 0. which isn't very logical to me. – auselen Oct 03 '12 at 14:02
  • Its no different than trying to run a mips or x86 instruction on an arm, if the processor doesnt support it it doesnt support it. there are many arm processors just like there are many x86 processors. Like x86 they have evolved to add more features and instructions. When you are looking at the instruction set reference the arm manuals state which architecture supports that instruction or not. If the processor you are using does not support an instruction you will get an undefined instruction exception. – old_timer Oct 03 '12 at 18:02