Mixed C/assembly programs for i.MX RT1010

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Mixed C/assembly programs for i.MX RT1010

跳至解决方案
1,337 次查看
danielmilutinov
Contributor III

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?

标签 (1)
0 项奖励
1 解答
1,237 次查看
danielmilutinov
Contributor III

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

在原帖中查看解决方案

0 项奖励
2 回复数
1,237 次查看
danielmilutinov
Contributor III

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

0 项奖励
1,238 次查看
danielmilutinov
Contributor III

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

0 项奖励