Structures

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

Structures

Jump to solution
1,580 Views
Timur
Contributor I
1)Why in assembler code I can't do this:
 
C Header file:
typedef struct tag_SomeBitfield
{
unsigned int bf:1;
} SomeBitfield;
 
C file:
...
SomeBitfield bfObj;
 
asm
{
 bfset bfObj.bf
}
 
I should do this:
 
asm
{
 bfset #$1,bfObj
}
 
 
2) Initialisation of structures
Why I can't initialise structure immideatly. Is will be so useful, when I have only one object.
 
struct OneObject
{
 int a=0;
 int b:1=1;
.....
}
 
struct OneObject Object1 - Default initialisation already defined!;
 
Stupid way:
 
struct Name
{
....
...
} Object=
{
...
Big Object! Screen is not latex!
...
}
 
or
 
struct a
{
int x;
int y;
...
}
#define init\
2,\
4,\
...
struct a b={init};
...
 
 
CodeWarrior 7.3, 56F8323
 
 
Labels (1)
Tags (1)
0 Kudos
1 Solution
399 Views
CrasyCat
Specialist III

Hello

I assume you are using a HC08 MCU. AM I right?

1- Inline Assembler does not support "bfset bfObj.bf"
     That is right. This notation is not supported by the inline assembler.
     You actually have to write it as "bfset #$1,bfObj".
      I will submit that as a possible improvement in the compiler.

2- Initializing a structure
The CodeWarrior compiler supports the standard ANSI C notation to initialize a structure.  ANSI C standard specifies that a structure must be initialized as follows:

struct Name
{
....
...
} Object=
{
...
...
}
 
This is not something we can change.

CrasyCat

View solution in original post

0 Kudos
1 Reply
400 Views
CrasyCat
Specialist III

Hello

I assume you are using a HC08 MCU. AM I right?

1- Inline Assembler does not support "bfset bfObj.bf"
     That is right. This notation is not supported by the inline assembler.
     You actually have to write it as "bfset #$1,bfObj".
      I will submit that as a possible improvement in the compiler.

2- Initializing a structure
The CodeWarrior compiler supports the standard ANSI C notation to initialize a structure.  ANSI C standard specifies that a structure must be initialized as follows:

struct Name
{
....
...
} Object=
{
...
...
}
 
This is not something we can change.

CrasyCat

0 Kudos