How to let the compiler choose the register using the inline-assembler on S32DS with MPC5744P

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to let the compiler choose the register using the inline-assembler on S32DS with MPC5744P

1,302 Views
yoshitaka_abe_j
Contributor II

I want to reduce the instruction codes using the inline-assembler for more faster operation because the S32DS compiler repeatedly generates the same codes shown in the below Figure-1.

( Note: The Figure-1 shows a part of  init_edma_tcd_15() function in edma.c in the sample program 'SPI_DMA_MPC5744P'. )

Therefore I am trying the inline-assembler coding, but I can not compile it shown in the below Figure-2.
I could not find the inline assembler example like this situation for MPC5744P although I found the ARM GCC Inline Assembler Cookbook which is different to the Power-Architecture.

Does someone teach me how to use the inline-assembler ?

Fig1_NXP_Community.png

Fig2_NXP_Community.png

0 Kudos
4 Replies

1,137 Views
yoshitaka_abe_j
Contributor II

Thank you for your reply.

I have confirmed the adding % character in shown the below the figure.

In addition, could you teach me the followings ?

Question-1 : Do I have to save & restore the value of the registers when I choose the register using the "%r" at inline-assembler ?

                     I am afraid of the destroying the values of the register coded with C-source.

                    Because I don't know the role of the other resisters although I guess the r1 is used to the stack-pointer.

                    ( I would use this coding way if I know the role of resisters under the S32DS Power-architecture. )

Question-2 : When I coded the following,

                     __asm__ volatile ( "e_lis %0, %1" : "=r" ( v_arg ) : "r" (64522) );

                    the S32DS compiler choosed the r7 register in shown the bottom of below figure.

                    Can I code it such as like I let the compiler to choose the register?

Fig3_assembler.png

0 Kudos

1,137 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

this is given by EABI spec - attached.

In short - there are volatile and nonvolatile registers:

pastedImage_1.png

pastedImage_2.png

Easiest option to use asm instructions in C code is to use pure asm functions and them call them from C code.

Regards,

Lukas

1,137 Views
yoshitaka_abe_j
Contributor II

Thank you for your information.

I understood.

0 Kudos

1,137 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

please take a look at this thread:

https://community.nxp.com/thread/395621 

It's necessary to add % character before the register name like: %r3

Or change the compiler settings as mentioned in the last post.

Regards,

Lukas

0 Kudos