## macro define of S32R274 .spt file

cancel
Showing results for
Did you mean:
SOLVED

## macro define of S32R274 .spt file

236 Views
Contributor III
Hello,

My question background:
Compiler: GreenHills 7
SPT tool version: D:\NXP\S32DS_Power_v2.1\S32DS\build_tools\SPT2
Purpose: to define the macro in .spt file.
I tried 3 cases, as below:

case1(no error and no warnings. ) :
.macro __mod .mod24
.endm

case2( error ) :
.macro __mod .mod24
.endm
add.immed .noshift __mod WR_4, (OR_0_0_0), WR_19　　   //This line is with error

case3(no error and no warnings. ) :
add.immed .noshift .mod24 WR_4, (OR_0_0_0), WR_19

Primary conclusion: The macro define seems well, no error and no warning, but do not work.
I do not know why.
But finally, I replaced all the __mod with .mod24,  pass the compile, no warning.

My question:
Is my macro define code correct?
If yes, why do not work?

Thanks very much!
MF
1 Solution
194 Views
NXP Employee

Hello MF,

Thanks for your patience and sorry for delay. The SPT assembler is based on GNU assembler (GAS) which does not support macro expansion in operands. Luckily the SPT tools has support for preprocessor (same as GNU C preprocessor) so we can use #define to achieve what you need:

``````#define __mod .mod24
add.immed .noshift __mod WR_4, (OR_0_0_0), WR_19

-> Expands to after preprocessor stage ->

add.immed .noshift .mod24 WR_4, (OR_0_0_0), WR_19``````

The SPT assembly file needs to use .pspt extension. I assume you are using S32DS which automatically applies the preprocessor as part of the SPT build chain, so just make sure you are on the latest version of S32DS for PowerArch from NXP.com for the most up-to-date SPT tools.

Regards,

Gary

5 Replies
195 Views
NXP Employee

Hello MF,

Thanks for your patience and sorry for delay. The SPT assembler is based on GNU assembler (GAS) which does not support macro expansion in operands. Luckily the SPT tools has support for preprocessor (same as GNU C preprocessor) so we can use #define to achieve what you need:

``````#define __mod .mod24
add.immed .noshift __mod WR_4, (OR_0_0_0), WR_19

-> Expands to after preprocessor stage ->

add.immed .noshift .mod24 WR_4, (OR_0_0_0), WR_19``````

The SPT assembly file needs to use .pspt extension. I assume you are using S32DS which automatically applies the preprocessor as part of the SPT build chain, so just make sure you are on the latest version of S32DS for PowerArch from NXP.com for the most up-to-date SPT tools.

Regards,

Gary

180 Views
Contributor III

Thanks！

Now we are using the GreenHills compiler.

Now successfully pass the compile and link, next step is to do the test.

MF
170 Views
NXP Employee

You are welcome, thanks for the kudos.

Even when using GreenHills as the toolchain for PowerArch development the SPT assembler is still the same tool as integrated with S32DS and used with NXP GCC so the same technique should still work.

Granted there may be slight differences between the GCC C pre-processor and the GHS version but I don't expect the behaviour of basic macro definition to be different. Let us know if your test is successful.

- Gary

137 Views
Contributor III

Hello Gary,

My test is successful, the SPT can work under GHS compiler. (Just the primary test, I can see the object can be detected, and range changes. So I guess It works.)

MF
224 Views
NXP Employee

Hello,

Let me talk to application engineer first.

I will come back to you ASAP.

Best regards,

Peter