Structures

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Structures

跳至解决方案
2,015 次查看
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
 
 
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
834 次查看
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 项奖励
回复
1 回复
835 次查看
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 项奖励
回复