We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello evreybody,
I have met a confusiong issue while working with the RVMDK assembly: when I have written this statement:
ADD r1, r1, r2
It has been coded in Thumb2. But when I have changed the ADD instruction to ADDS, it become a Thumb instruction! Could any one explain to me why the add of the S, which indicates if the stauts register has to be modified or not, changes the mode in wich the instruction is coded.
Thanks to all
The Thumb-2 instruction set includes all of the Thumb instructions plus some additions.
There is not thumb instruction
"ADD Rd, Rd, Rm that allows using 2 low registers"
You can use 1 low and 1 hi, 1 hi and 1 low, or 2 high registers but not 2 low registers.
"ADD Rd, Rd, Rm using ANY registers is thumb-2 instruction"
ADDS Rd, Rn, Rm is a Thumb instruction if all registers a low.
So it is not really that adding the S makes it a Thumb instruction, it is removing the S makes it a Thumb-2 only instruction.
Hi Robert,
Thank you for the response. Could you please tell me where I can found this kind of information? In fact, to write a speed optimized assembly code, it is more efficient to use Thumb instructions instead of Thumb2. Unless, the Thumb2 are used to reduce the number of the instructions. So, the user who intends to write an assembly program must know in which mode their instructions will be coded.
Thank you again
Thank You again
infocenter.arm.com/.../QRC0006_UAL16.pdf
infocenter.arm.com/.../QRC0001_UAL.pdf
www.simplemachines.it/.../QRC0001H_rvct_v2.1_arm.pdf
I am not sure about your statement that using Thumb code instead of Thumb2 is better. The ADD Rd, Rd, Rm is a Thumb-2 instruction, but it is only 16-bits in size.
Hello,
Thank you for the links. This a code from the disassembly window of my RVMDK toolchain:
EB000102 ADD r1, r0, r2 1881 ADDS r1, r0, r2
You can remark that ADD r1, r0, r2 has been coded into 32bits, while ADDS r1, r0, r2 has been coded into 16bit.
Best regards Seif
Notice the difference
ADD R1, R1, R2 (this was your original statement)
and
Add R1, R0, R2
The first one will be encoded in 16-bit thumb-2 code
The second (as you have shown) will be encoded in 32-bit thumb-2 code.
Ok! Thanks a lot.
best regards Seif