Friday, January 16, 2009

One Instruction Set Computers


The logical extreme of reduced instruction set computers, as previously briefly mentioned in this article, is the use of a single parametrized op-code. To properly put this into perspective, modern x86 architectures, like the computer you are likely using now, and other CISC (complex instruction set computers) use hundreds, if not thousands, of individual instructions. The use of so many different commands within the processor forces the design to be very complex and leads to an increased chance of glitches and ultimately reduces maximum clock speed.

On the other hand, a reduced instruction set computer architecture (RISC), especially the one instruction set version (OISC), involves minimal circuitry inside the actual processor, simplifying the design and allowing components to be placed in a smaller area to enhance the speed by reducing propogation delays and latencies.



The model under investigation here is known as "Subtract-and-Branch-If-Less-than-or-Equal-to-Zero", symbolized as "subleq", and coded with no opcodes - since with the use of a sinlge op-code, the computer will not require explicit knowledge of what is expected, the opcode is implied and memory space is saved. Subleq takes three parameters, also known as operands, marked a, b, and c. The basic, and only, function of this code is to set the value at b equal to b minus a. In otherwords, b = b-a. For those that are not familar with typical assignment operators used in computer programming, the way this statement is evaluated is by taking the current value of whatever b-a happens to be. This value is then stored in and overwrited to, "assigned to", the value of b... meanwhile no change is made to a. IF the new value at b is less than or equal to 0 then program execution is "jumped" to the location held by paramter c, or more simply, the processor's program counter is set to the value of c. If a jump is not required you can't simply say 0 for c, since that would cause the program to reset and start over, 0 is the starting point for a program counter (typically). It is generally accepted to leave the third parameter c blank in these cases, which informs the processor that regardless of the previous operation, just go to the next instruction. It's still a jump, but only by one unit. Alternatively, the user can simply write in the location of the next instruction, it's exactly the same.

There are many ways to implement this design and slight modifcations are possible to create new instruction sets. Since program lengths can become extraordinarily long in such an instruction set, it can also be beneficial to add specialized hardware to the processor to allow multiplication or other mathematical functions to be performed in a single cycle. However, for proof of concept, the OISC mentioned here, is capable of universal computation! All with only one instruction.

If you've never run across such a claim before, I don't expect you to immediately understand how to program in this machine language. It's interesting that, at this point, you know everything about this one instruction set computer and yet, at the same time, probably wouldn't have any idea where to begin creating a program to drive it.

Well, here's a start, to perform addition of two numbers on this computer, all you have to do is...
    ADD a, b == subleq a, Z
subleq Z, b
subleq Z, Z
Good luck OISC programmers!

No comments: