This file provides macros for FASM that disallow the inadvertent
use of non-existent instructions for older CPU architectures.

Both invalidation and revalidation are implemented

The intended use is something like this:

	include 'compatibility.inc'
  .386					;<-- stop us from accidentally using SSE instructions
	format etc.
	;put code to test for "cpuid" existence here
	jxx	sse_not_allowed
  .486					;<-- if cpuid exists then we have at least a 486
	mov	eax,1
	cpuid
	bt	edx,25
	jnc	sse_not_allowed
	;put code to check OS support for SSE here
	jxx	sse_not_allowed
     sse_allowed:
  .pentium3				;<-- SSE code okay in here, but SSE2 not allowed
	;SSE code goes here
  .386					;<-- switch back to non-SSE code
	jmp	done
     sse_not_allowed:
	;non-SSE code goes here
     done:

You can also use like this:

  .086					;<-- Now only 8086 instructions are valid
	xor	ax,ax
	;shl	bx,2			;<-- Error, only immediate shifts by one allowed
	;mov	ecx,edx			;<-- Error, 32 bit not allowed
  .286f				;<-- Now 80286 with FPU
	shl	bx,2			;<-- Okay with 80286
	;fsin				;<-- Error, 80287 doesn't have fsin
  .486f				;<-- Now 80486dx or 80486sx with 80487sx
	bswap	edx
	fsin				;<-- Okay with 80387+
  .EM64T				;<-- Now all instructions available
	addsubpd xmm0,xmm1
	use64
	mov	r14,rsi
  .286					;<-- 80286 without FPU (implicit use16 generated)
	jz	somelabel		;<-- generates 2 or 5 byte jumps for 16 bit CPU
	;use32				;<-- Error, 32 bit not allowed
  .386
	jz	somelabel		;<-- generates 2 or 4 byte jumps for 32 bit CPU
	use32
	jz	somelabel		;<-- generates 2 or 6 byte jumps for 32 bit CPU


All instruction macros assume lower case names only, this means you can get access to
the original instruction at any time by using one or more upper case letters.
eg. Use32  moV [r],4  puSh EAX  etc. will bypass these macros.


There are probably lots of ways to upset this code, it might not be bullet-proof,
so be careful and aware. I tested it as much as I could but you never know
about those sneaky little bugs and oversights that seem to pop up at the most
inconvenient times. As usual, it's your responsibility, use at your own risk.


If you find a problem or can improve on this code contact "revolution" at:
http://board.flatassembler.net