x86程序集以编程方式确定endianess(x86 assembly to programmatically determine endianess)
据我所知,英特尔x86是小端。 但是,如何编写汇编以编程方式确定处理器的字节顺序?
I understand that Intel x86 is little endian. However, how would I write assembly to programmatically determine the endianess of a processor?
最满意答案
存储一个具有不同值的单词,每个单词的两个字节(例如0x0001 )。 从同一地址加载一个字节,并检查它匹配的原始字的哪个字节。
Store a word that has different values for each of it’s two bytes (0x0001, for example). Load a byte from the same address and check to see which byte of the original word it matches.
更多推荐
发布评论