views:

286

answers:

1

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 of 4 means 32 bit
Diff of 8 means 64 bit

Am I correct in this thinking?

+5  A: 

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.

Jeff B
Okay...that makes sense.
dboarman