Keil Logo

Conditional Includes in Assembler

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Geoff Field
Posted
20-Jun-2018 05:55 GMT
Toolset
C51
New! Conditional Includes in Assembler

Hi all,

I'm working on a project using the Keil C51 assembler on a Silicon Labs EFM8BB2 project. We're trying to port it to a BB1 (now that we have most of the features coded and the code is undergoing compression to fit), but I'd like it to conditionally build for either platform.

What I currently have in an assembly file (the RAM test function) is the following:

$IF (BB2 == 1)
;$include (SI_EFM8BB2_Defs.inc) ; SFR declarations
$ELSE
$include (SI_EFM8BB1_Defs.inc) ; SFR declarations
$ENDIF

"BB2" or "BB1" is defined for the specific build. For the Debug version, I'd like to leave it as BB2, because the debug code adds a bunch of extra functionality: mostly putting strings out through the UART port. (Most of the extra is actually storage of the strings themselves.)

My problem is that if I uncomment the "BB2" include, the "BB1" build fails because it can't find the SFR file. (I also set the include paths according to the BB1/BB2 status.)
I should add that vice-versa applies.

I have just done an apparently successful build with both uncommented by adding include paths for both SFR files. This builds from the SiLabs IDE, but the command line build by our CI system fails. I'm still trying to track that failure mode down.

Question: Is there a way to do the conditional include in the C51 assembler without having to add both include paths?

Thanks,

Geoff

Read-Only
Author
Geoff Field
Posted
20-Jun-2018 06:36 GMT
Toolset
C51
New! RE: Conditional Includes in Assembler

And yes, I have done a search for "conditional includes assembler" with nothing particularly useful for this platform.

I've also considered modifying my include paths to be one level up from there and then specifying the subdirectory for the platform. This did not, unfortunately, fix the issue with the CI build.

The CI is GitLab.

Read-Only
Author
Andrew Neil
Posted
20-Jun-2018 07:59 GMT
Toolset
C51
New! RE: Keil C51 assembler

Note that C51 is the Compiler;

The Assembler is called A51.

The A51 manual says you should be able to use the 'C' prepreocessor:

http://www.keil.com/support/man/docs/a51/a51_mp_c.htm

Have you tried that?

Read-Only
Author
joe blow
Posted
20-Jun-2018 14:22 GMT
Toolset
C51
New! RE: Keil C51 assembler

re the above
you do as you want, I ALWAYs do it this way

if a
.....
else if b
......
else
OOPS
endif

Read-Only
Author
Geoff Field
Posted
21-Jun-2018 00:36 GMT
Toolset
C51
New! RE: Keil C51 assembler

Hi Joe Blow,

The else OOPS clause is elsewhere in my build: I don't feel the need to put it everywhere.

Probably wouldn't hurt, though.

Geoff

Read-Only
Author
Geoff Field
Posted
21-Jun-2018 00:34 GMT
Toolset
C51
New! RE: Keil C51 assembler

You're quite right Andrew, it's not C51 for the assembler at all.
When I look at the settings, the command is actually AX51.

I have now changed the inclusion to this format:
#ifdef BB2
#include "SI_EFM8BB2_Defs.inc" ; SFR declarations
#else
#include "SI_EFM8BB1_Defs.inc" ; SFR declarations
#endif

It seems to work very nicely, thank you.

I'm still having issues with the CI build, but I think that's a slightly different problem.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.