Determine 32/64 bit architecture in assembly

后端 未结 2 1529
广开言路
广开言路 2021-01-12 17:08

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 sta

2条回答
  •  孤独总比滥情好
    2021-01-12 18:00

    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.

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

提交回复
热议问题