views:

250

answers:

2

I'm just touching the surface of the x86 instruction set after a long period of high level programming. It's been about 20 years I had my first read on x86 assembly programming and from my googlings I get just lost with the myriad of instruction set references; from ones that mix new generations of processors (286, 386, 486...) to others that add newer x86 instructions. Not to mention the AMD variations.

Since I'm planning on building a boot loader, my first thought was to be fully compliant with 'standard x86' but I can't figure out where in time it is or even if it exists anywhere.

Even Intel documentation seems follow the same path and like another one said, 'we need a x86 instruction set standardisation, the evolution of opcodes is chaotic'.

It's not my idea to hold the standardization banner. I just want to see the road and understand where is the safe place to walk. If anyone could help I'd appreciate a lot!

+5  A: 

Historically, x86 has been very backward compatible. x86-64 has thrown away some very old instructions (like BCD instructions) but it's unlikely that these kind of changes are going to happen again (at least not until something huge as 64 bit address space transition happens).

If you want to ensure your code works on virtually all x86 processors out there, stick to the 386 instruction set (if your code is 32-bit) or early x86-64 instruction set (if it's 64-bit).

Mehrdad Afshari
I've noticed a recent trend to build Linux Kernels in various distros for 586 (Pentium) or better these days... although they still can't default to the 686 (Pentium II/III/IV/Pro) kernels because of differences between those and the k7 (AMD Athlon) instructions.
R. Bemrose
R. Bemrose: That's a logical way to go eventually. IMO, the beauty of x86-64 is not just being 64 bit, but establishing a reasonable minimum for instructions supported by the processors (e.g. SSE)
Mehrdad Afshari
https://fedoraproject.org/wiki/Features/F12X86Support Fedora 12 now builds for i686, dropping support for many older processors out there. My poor Via C3... :-(
ephemient
thanks for replying! ok, 386 is the choice. I saw other trends saying the same. But it will not fall in the same question again? who is the egg and who is the chicken? Where's the universal 386?
Ruben Trancoso
@Ruben: (if I understand your question correctly...) I believe Intel processor software development manuals http://www.intel.com/products/processor/manuals/ describe 386 pretty well. Besides, assemblers usually support directives to specify the minimum processor that the code is written for so that they prevent you from accidentally using a newer, possibly unsupported instruction.
Mehrdad Afshari
thak you Mehrad, I will look on it with care.
Ruben Trancoso
Basically, that document mentions the processor in which each instruction first appeared.
Mehrdad Afshari
+1  A: 

Boot loader executes in 16-bit real mode (although you do have access to 32-bit registers via the operand size prefix). Get a 386 instruction reference, and you'll be safe.

zvrba