Page 1 of 1

The 80x86 is an Octal Machine

Posted: Wed Sep 23, 2015 2:24 pm
by kzinti

Re: The 80x86 is an Octal Machine

Posted: Wed Sep 23, 2015 2:44 pm
by SpyderTL
Interesting.

I went through the entire instruction set, starting with the 8086 and moving all the way up to the 80386, defining all of the instructions in a name/value pair in XML, and I've used that XML file to generate XSLT transforms to convert these names into their hex values. I definitely notice some of these repeating patterns when creating these XML enumerations, but a) they didn't seem quite stable enough to rely on (for instance, one value occasionally would not be needed, and would be replaced with something completely unrelated), and b) knowing these patterns wasn't terribly helpful, as defining 255 instructions at a time was easier than trying to break them up into 8-instruction chunks (ADD, ADC, SUB, SBB, CMP, OR, AND, XOR), and then ORing those values with 9 operand values (Eb-Rb, Ew-Rw, Rb-Eb, Rw-Ew, AL-Db, AX-Dw, Eb-Db, Ew-Dw, Ew-Dc).

I just decided to create one set of 255 values for the first byte, and then several sets of 255 values for the second byte, and so on.

<cpu:CopyRegisterToOperand/>
<op:AX-DIAddress/>

But I'd be interested if someone could figure out how to use the octal values to simplify this approach.

Re: The 80x86 is an Octal Machine

Posted: Thu Sep 24, 2015 1:59 pm
by onlyonemac
Didn't read the whole document but while I don't really know that much about the x86 opcodes it certainly sounds interesting.

Re: The 80x86 is an Octal Machine

Posted: Thu Sep 24, 2015 5:53 pm
by Nable
This is my favorite guide to x86 opcodes (especially because of C-like pseudocode that is very easy to understand). Btw, it was posted on osdev earlier (maybe even several times) but then it was removed due to uncertain situation with copyrights.

Re: The 80x86 is an Octal Machine

Posted: Thu Sep 24, 2015 6:05 pm
by kzinti
There is no copyright issues with linking.

Re: The 80x86 is an Octal Machine

Posted: Fri Sep 25, 2015 6:01 am
by embryo2
SpyderTL wrote:But I'd be interested if someone could figure out how to use the octal values to simplify this approach.
There's a mix of high level knowledge (the command groups) with the knowledge about instruction encoding. The encoding part can be used for binary code representation generation, but the complexity of the octal picture is not anywhere less than the complexity of the Intel's manual instruction encoding description. May be because of this the octal encoding is not used actively (is it used anywhere at all?) and represents some kind of esoteric knowledge about 8086.

Re: The 80x86 is an Octal Machine

Posted: Fri Sep 25, 2015 10:29 am
by kzinti
In the last year of my computer engineering degree, I had to come up with a project. I chose to do an x86 assembler that would generate .com executables directly (think 486 / MSDOS 5-6 days).

I remember noticing this octal pattern and using it to generate the binary code. The code required was much shorter / efficient, even after taking into account the few exceptions in the pattern.