Number conversion host to big endian

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

Number conversion host to big endian

ソリューションへジャンプ
2,719件の閲覧回数
jordi_becares
Contributor III

Hi,

I'm working on MKE1xF family over SDK2.5 and I'm looking for a solution for endian to host converter like htons().

My problem is that if I had a number and I want to convert to little/big endian, what is the method to use? The idea is use a common method for multiplatform, like htob (host to big endian) or htol (host to littel endian). In other platforms K60 MQX 4.1 there is support for this conversions


Is there any support for this family and SDK?

Thanks

Jordi

ラベル(1)
タグ(2)
1 解決策
2,623件の閲覧回数
jingpan
NXP TechSupport
NXP TechSupport

Hi Jordi,

There is some ARM function you can use.

__REV: Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.

For example:    A=__REV(B);     //A,B is 32bit variable

__REVSH: Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.

For example: C=__REVSH(D);   //C,D is 16bit variable

Regards,

Jing

元の投稿で解決策を見る

2 返答(返信)
2,624件の閲覧回数
jingpan
NXP TechSupport
NXP TechSupport

Hi Jordi,

There is some ARM function you can use.

__REV: Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.

For example:    A=__REV(B);     //A,B is 32bit variable

__REVSH: Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.

For example: C=__REVSH(D);   //C,D is 16bit variable

Regards,

Jing

2,623件の閲覧回数
jordi_becares
Contributor III

Hi Jing,

thanks for the feedback.

I didn't know this macros, and them are very useful.

Regards

Jordi

0 件の賞賛
返信