16 bit in CW

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

16 bit in CW

3,113 次查看
ernestsnaith
Contributor I
How do you access only the high and low byte in CW?
 
Cheers
标签 (1)
0 项奖励
回复
3 回复数

979 次查看
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 项奖励
回复

979 次查看
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 项奖励
回复

979 次查看
CrasyCat
Specialist III

Hello

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

CrasyCat

0 项奖励
回复