请问我基于AMD的机器使用的小端或大端? [英] Does my AMD-based machine use little endian or big endian?

查看:1180
本文介绍了请问我基于AMD的机器使用的小端或大端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要去虽然计算机系统课程,我试图建立,的肯定的,如果我的基于AMD处理器的电脑是一个小endian机器?我相信这是因为这将是Intel兼容。

I'm going though a computers system course and I'm trying to establish, for sure, if my AMD based computer is a little endian machine? I believe it is because it would be Intel-compatible.

具体来说,我的处理器是AMD的Athlon 64 X2。

Specifically, my processor is an AMD 64 Athlon x2.

据我所知,这可以在C编程重要。我正在写C程序和我使用的方法将受此影响。我试图找出如果我能得到相同的结果,如果我运行该程序基于Intel的机器上(假设的小尾数机)。

I understand that this can matter in C programming. I'm writing C programs and a method I'm using would be affected by this. I'm trying to figure out if I'd get the same results if I ran the program on an Intel based machine (assuming that is little endian machine).

最后,让我问这个:是否有任何和所有的机器能够运行Windows(XP,Vista中,2000,Server 2003中,等),并说,的 Ubuntu Linux操作系统的桌面是小端?

Finally, let me ask this: Would any and all machines capable of running Windows (XP, Vista, 2000, Server 2003, etc) and, say, Ubuntu Linux desktop be little endian?

感谢你,结果
弗兰克

Thank You,
Frank

推荐答案

所有的x86和x86-64机(这只是一个扩展的x86)的小端。

All x86 and x86-64 machines (which is just an extension to x86) are little-endian.

您可以用这样的确认:

#include <stdio.h>
int main() {
    int a = 0x12345678;
    unsigned char *c = (unsigned char*)(&a);
    if (*c == 0x78) {
       printf("little-endian\n");
    } else {
       printf("big-endian\n");
    }
    return 0;
}

这篇关于请问我基于AMD的机器使用的小端或大端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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