Hello,
Code I am porting to the i.MX RT1010 includes an assembly function that is called from a C file. This assembly function finds the successor of an IEEE 754 double. I did this in TI’s Code Composer Studio like this:
C file (main.c):
//variables
double x;
double xplus;
//external functions
extern double successor(double);
//main
int main(void) {
xplus = successor(x);
}
Assembly file (successor.s):
.global successor
successor
VMOV R0,S0
VMOV R1,S1
ADDS R0,R0,#1
BCC noOF ;carry cleared if no overflow
ADD R1,#1
noOF VMOV S1,R1
VMOV S0,R0
BX lr
When I try to compile this in MCUXpresso I receive the following errors:
bad instruction ‘carry cleared if no overflow’
bad instruction ‘noof VMOV S1,R1
bad instruction ‘successor’
instruction not supported in Thumb16 mode – ‘ADDS R0,R0,#1’
Could someone please advise how to get this working in MCUXpresso?
Solved! Go to Solution.
I haven't tested it yet, but from what I've read the Thumb-16 ADD instruction always sets the flags. However ADDS can be used by selecting the new unified syntax using the ".syntax unified" directive:
.global successor
.syntax unified
successor:
VMOV R0,S0
VMOV R1,S1
ADDS R0,R0,#1
BCC noOF /*carry cleared if no overflow*/
ADD R1,#1
noOF: VMOV S1,R1
VMOV S0,R0
BX lr
I have changed the successor.s file to the following and it is compiling without errors, but I had to replace the ADDS instruction with ADD, so I don't know if any carries will now be set in the APSR register. I'll test it and report back.
.global successor
successor:
VMOV R0,S0
VMOV R1,S1
ADD R0,R0,#1
BCC noOF /*carry cleared if no overflow*/
ADD R1,#1
noOF: VMOV S1,R1
VMOV S0,R0
BX lr
I haven't tested it yet, but from what I've read the Thumb-16 ADD instruction always sets the flags. However ADDS can be used by selecting the new unified syntax using the ".syntax unified" directive:
.global successor
.syntax unified
successor:
VMOV R0,S0
VMOV R1,S1
ADDS R0,R0,#1
BCC noOF /*carry cleared if no overflow*/
ADD R1,#1
noOF: VMOV S1,R1
VMOV S0,R0
BX lr