低字节高字节顺序 [英] Low-byte High-byte order

查看:210
本文介绍了低字节高字节顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的..所以我使用winsock2 Windows Socket API制作了基于服务器套接字的俄罗斯方块游戏。我完成了程序,它工作正常,我实际上没有设置套接字或WSA的问题。但是我从winsock2 API中无法理解。功能MAKEWORD(BYTE bLow,BYTE bHigh)。

这是什么意思?任何人都可以给我一个很好的例子来说明这个函数意味着什么。

我已经查找了宏,我没有任何理解它的问题。唯一的问题是我不明白MAKEWORD的概念或者是什么。

有人可以帮助我吗?

任何帮助都会非常感激。

Ok.. so I made a server-socket based tetris game using the winsock2 Windows Socket API. I finished the program, it works fine, and i actually have no problem in setting up the socket or the WSA. But there''s something i don''t understand from the winsock2 API. The function MAKEWORD(BYTE bLow,BYTE bHigh).
What does it mean? Can anyone give me a good example of what does this function mean.
I''ve looked up for the macro, i don''t have any problem understanding it. the only problem is i don''t understand the concept of MAKEWORD or what is it for.
can anyone help me?
Any help would be really appreciated.

推荐答案

文档 [ ^ ]说明一切:通过连接指定的(字节)值创建一个WORD值。

它只是一个辅助宏,如果你有两个字节并且需要在一个单词中粘合它们就很有用。一个类似的宏(其用处很明显)是 RGB [ ^ ]。
The documentation [^] says it all: "Creates a WORD value by concatenating the specified (byte) values".
It is just an auxiliary macro, useful if you have two bytes and need to ''glue'' them in a word. A similar macro (whose usefulness is apparent) is RGB[^].


BYTE包含8个(可用)位。在此上下文中,WORD包含16位或2个BYTE。这些可以表示为



A BYTE contains 8 (usable) bits. In this context, a WORD contains 16 bits or 2 BYTEs. These can be represented as

           +--------+--------+
2 BYTEs    |bbbbbbbb|bbbbbbbb|
           +--------+--------+
1 WORD     +wwwwwwww wwwwwwww|
           +--------+--------+



你可以用2个BYTE构建一个WORD。有一个上部BYTE和下部BYTE。您描述的宏就是这样做的。


You can build a WORD out of 2 BYTEs. There is an upper BYTE and lower BYTE. The macro you describe does exactly that.


这篇关于低字节高字节顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆