确定组装中的32/64位架构 [英] Determine 32/64 bit architecture in assembly

查看:86
本文介绍了确定组装中的32/64位架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读这个问题,想知道接受的答案是否也可能是确定体系结构的一种方法。例如,在asm中,我可以将WORD推入堆栈,然后检查SP。比较新的SP与旧的SP:

I was reading over this question and wondered if the accepted answer might also be a way to determine the architecture. For instance, in asm could I push a WORD onto the stack and then check SP. Compare the new SP to the old SP:

Diff为4表示32位

Diff为8表示64位

Diff of 4 means 32 bit
Diff of 8 means 64 bit

我在这个想法上纠正吗?

Am I correct in this thinking?

推荐答案

否,因为堆栈的大小基于以哪种模式运行(真实,受保护,long / 64,vm86,smm等),而不是体系结构。例如,如果程序集以保护模式运行,则即使处理器是x86-64,堆栈也将是32位(如果操作数是16位,则堆栈为16)。

No, because the size of your stack is based on what mode you are running in (real, protected, long/64, vm86, smm, etc), not on the architecture. If your assembly is running in protected mode for instance, your stack will be 32 bits (or 16 if your operands are 16 bits), even if your processor is x86-64.

就像提到的评论中的某人一样,CPUID是判断您的体系结构是唯一可靠的方法。

Like someone in the comments mentioned, CPUID is the only reliable way to tell what your architecture is.

这篇关于确定组装中的32/64位架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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