16 bit in CW

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

16 bit in CW

3,178件の閲覧回数
ernestsnaith
Contributor I
How do you access only the high and low byte in CW?
 
Cheers
ラベル(1)
0 件の賞賛
返信
3 返答(返信)

1,044件の閲覧回数
CrasyCat
Specialist III

Hello

Which processor are you targeting (MPC, Coldfire, HC12, ...)?

What are you trying to do exactly?

Are you trying to access MSByte and LSByte from an address in assembler?
Are you trying to do that in ANSI C?

I need more information to provide an answer.

CrasyCat

0 件の賞賛
返信

1,044件の閲覧回数
rhinoceroshead
Contributor I

Try this:

int a16bitNumber = 0x1122;
char* ptr;
char lowByte, highByte;
ptr = (char*)&a16bitNumber;
highByte = *ptr++;
lowByte = *ptr;

Now highByte will hold 0x11 and lowByte will hold 0x22.

0 件の賞賛
返信

1,044件の閲覧回数
CrasyCat
Specialist III

Hello

I still need to know the processor you are targeting (HC08, HC12, Coldfire, EPPC5xx, .....)

CrasyCat

0 件の賞賛
返信