gcc是否提供内置读取大端内存?(Does gcc provide builtin to read big endian memory?)

编程入门 行业动态 更新时间:2024-10-28 05:25:59
gcc是否提供内置读取大端内存?(Does gcc provide builtin to read big endian memory?)

我需要从两个小端核(例如arm)读/写设备寄存器(在我的情况下是在大端地址空间中)。 我不想使用中间端转换例程(例如htonl)。 我的理解是现代核心具有指令,使用它们可以直接读取/写入大端存储器。

gcc是否为上述内容提供了自动生成正确汇编指令的内置函数?

I need to read/write device registers (which in my case are in big endian address space) from both little endian cores (e.g. arm). I do not want to use intermediate endian conversion routines (e.g. htonl). My understanding is that modern cores have instructions using which they can do reads/writes to big endian memory directly.

Does gcc offer any builtin for the above which automatically generates right assembly instruction(s)?

最满意答案

GCC 4.3.0提供内置功能:

内置函数:int32_t __builtin_bswap32(int32_t x),它返回逆转的顺序。 例如。 11223344将是0x44332211 内置函数:int64_t __builtin_bswap64(int64_t x)也类似于__builtin_bswap32,但它返回64位。

请参阅内置的小心 。

There are built-in functions available from GCC 4.3.0:

Built-in Function: int32_t __builtin_bswap32 (int32_t x), it returns the order of byes reversed. for eg. 11223344 will be 0x44332211 Built-in Function: int64_t __builtin_bswap64 (int64_t x) is also similar to __builtin_bswap32, except that it returns 64 bits.

Please refer to the Beware the builtins.

更多推荐

本文发布于:2023-08-06 12:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1450070.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大端   内存   provide   gcc   builtin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!