The 80x86 is an Octal Machine

Programming, for all ages and all languages.
Post Reply
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: The 80x86 is an Octal Machine

Post 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.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: The 80x86 is an Octal Machine

Post 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.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: The 80x86 is an Octal Machine

Post 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.
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: The 80x86 is an Octal Machine

Post by kzinti »

There is no copyright issues with linking.
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: The 80x86 is an Octal Machine

Post 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.
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: The 80x86 is an Octal Machine

Post 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.
Post Reply