Mixed C/assembly programs for i.MX RT1010

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Mixed C/assembly programs for i.MX RT1010

ソリューションへジャンプ
1,834件の閲覧回数
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,734件の閲覧回数
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,734件の閲覧回数
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,735件の閲覧回数
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 件の賞賛
返信