News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Chipset directives ...

Started by James Ladd, May 04, 2005, 07:58:47 AM

Previous topic - Next topic

James Ladd

At the top of my code I can put

.386

What are the supported values and do they have any effect on the code generated ?


thomasantony

Hi,
   I think this specifies the instruction set you use. With .386 you can use 386 instructions and 32-bit registers etc. But you cannot use some instructions like BSWAP which is available only in 486.

Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free


Mirno

The directive changes available instructions, so MASM will throw an error if you use later instructions.
You can specify several processor directives in the same bit of code, so you may find that you get code that does the initial processor detection under .386, then moves to .586 & .MMX when it's detected an appropriate processor. It's for safety really.

It also changes the instruction timings if you generate a list file "ml /Fl<name.txt> <asmfile.asm>". Although note that .686 does not generate instruction timings because it's out of order execution does not lend itself to easy clock cycle numbers.

AFAIK the directive won't change instructions generated... Although I could be wrong (work arounds may be in place on a specific generation for instance).

Mirno

AeroASM

Quote from: Mirno on May 04, 2005, 10:42:01 AM
AFAIK the directive won't change instructions generated...

With .286 it puts a 66 prefix on 32-bit registers (eax)

With .686 it puts a 66 prefix on 16-bit registers (ax)

MichaelW

Quote from: AeroASM on May 04, 2005, 01:18:59 PM
Quote from: Mirno on May 04, 2005, 10:42:01 AM
AFAIK the directive won't change instructions generated...

With .286 it puts a 66 prefix on 32-bit registers (eax)

With .686 it puts a 66 prefix on 16-bit registers (ax)

Although this would not be obvious looking at a disassembled listing, there is no direct connection between the processor directive and the default operand size, and for any processor selection below .386 MASM will refuse to assemble 32-bit instructions. The operand size prefix (66h) overrides the default operand size. For 32-bit protected mode the default operand size is 32 bits (determined by the D bit in the executable segment descriptors). For real or V86 mode the default operand size is 16 bits.
eschew obfuscation