A CPU With Just One Instruction!!!

preview_player
Показать описание
Can you make a general purpose CPU with just one instruction? Sure! SUBLEQ is an example of a One Instruction Set Computer (OISC). The ultimate RISC machine where the number of instructions has been reduced to 1!

#garyexplains
Рекомендации по теме
Комментарии
Автор

I bought a CPU on ebay that had only one instruction implemented. I believe it was Halt and Catch Fire.

SyBernot
Автор

I've seen a talk where a guy built a compiler which compiled C to just mov instructions. He called it the movfuscator.

Автор

I learned this 50 years ago in a computer class. The instruction was subtract and store.

Viewpoint
Автор

I'm reminded of an old saying that, every piece of software has inefficiencies, meaning some instructions can be taken out without changing the functionality. And every piece of software has bugs in it, bits and parts that don't function as required. So by inference one can conclude that every piece of software can ultimately be reduced to a single instruction that doesn't work.

uncaboat
Автор

This brings me back down memory lane, where I was writting code *on paper* for educational purposes. I took computer classes and for like a whole semester we didn't even touched a computer!

DunnickFayuro
Автор

I remember many years ago someone saying you could implement a cpu with just a subtract instruction. Thanks for finally completing my knowledge! I can now die happy :)

ianworthington
Автор

The earliest 6800 chips (not 68000 they were way later) were sort of 1 instruction in that if you executed it, it would never execute another instruction again. The assembler mnemonic was HCF . Halt and Catch Fire (and some really sarcastic developer really did put that in their assembler software). Basically there was a screw up where it set one accumulator, reset the other, and then dumped them both simultaneously onto the internal data bus. All in one clock cycle too. Quite efficient.

gordonlawrence
Автор

The instruction set is bloat
-Luke Smith, probably

AexisRai
Автор

This only works because the instruction itself is doing multiple things at the same time: loading from two different addresses, storing into another, and branching. It's kind of like saying "this knife can open wine bottles and also provide light" and learning that it's a Swiss Army knife with a bottle opener and a mini-flashlight as part of its base.

stevemaurer
Автор

Next we need to build this CPU with just NAND gates. :D <3

yorgle
Автор

One instruction with a complex inner instruction set ;)

AdvanRossum
Автор

A friend in college actually built a one-instruction computer (not sure if it completely worked) as an electronics project that he did somewhere around late high school (I think). He described that one instruction as "subtract, and branch if negative." Somehow that sounds similar to what I think "SUBLEQ" stands for.

derekkonigsberg
Автор

Machine code: Wtf
"On the other hand there is an assembler"...
Assembler: Wtf

mexykanu
Автор

... and now build this CPU with only NAND gates ;-)

jawtheshark
Автор

11:20 Doing some figuring on paper leads me to believe that maybe address -1 is the output. This is what I wrote when trying to decode this:

a=0
Z=0-p (p=[H])
a=0-(0-p)
a:0 (-1)

If H==100 then
a=0
Z=0-100=-100
a=0-(-100)=100
a:100 (-1)

This shows me that (if im interpreting this right) the value at address 100 which is the letter H is being subtracted from the value at address -1. So that leads me to beleve the address -1 is reserved for screen output.

Thanks for taking the 30 sec to explain that.

JacobP
Автор

Because you always change the sign (due to using subtract), if you need to add you just subtract from 0. This means addition takes 2 operations and 1 extra memory location (to store the 0) compared to also having an addition operator.

Because you need extra entropy in the form of data storage to pull this off, the subtraction-only computer is actually an addition and subtraction computer, but one of the ops is stored with the data itself (assuming Two's Compliment). You can't pull this off without the second operation being in the data itself, because ultimately negative values don't really exist in binary. Negative numbers are simply positive numbers (or rather, vectors - and positive and negative are the direction of the vector) with a yet-to-be-executed operator encoded along with them. -2 is "subtract 2's worth of value". +2 is "add 2's worth of value". 2 is a number. -2 is nearly a number, but convention says if the second value isn't supplied, use 0. Fractions are the same, two numbers yet to be divided. They aren't values in their own right yet. It's a beautiful example of how the line between operations and data is way more blurred than one might think.

The addition of 1 needs also needs a "1" to be stored somewhere. This requires another bit of memory to store, and so in totality the is as entropy dense as a computer that has three op codes, addXY, addXY (but sign flip Y), and add1. They are the same amount of "complex", it is only that the former has more constants, and the latter more operations.

TL;DR: It's only a single operation computer because of how the term "operation" is defined, and really when one says "special subtraction" one really means "the default is subtraction but constants stored in data can also modify it's behaviour". I'm not trying to nit-pick or be a dick or anything, i'm just trying to explain how you can't actually get Turin Completeness with 1 operation, you have to be a little crafty with the definition of operation.

JohnJones
Автор

you should be able to design a cpu with only one instruction and two registers. one register contains the set of bits to be changed, the other register contains a set of bits that defines which bits are to be flipped. it would be a nightmare to try design the rest of the computer around the cpu, and I wouldn't want program for it, but you could do it. it would be up to the programmer to decide which bits needed to flip for any particular situation, making it not fun to program, but you could do it and it would be a very fast cpu. because it's just the one instruction it would be relatively simple to design the system for as many bits as you wanted. you could design the machine to use 256 bit registers, 1024 bit registers, whatever. actually getting it to accomplish anything would be a nightmare, but if someone were willing to tackle making a usable programming language for it, it would be very very fast.

baneblackguard
Автор

I cannot believe the quality of your channel content. You are AWESOME!

mahyar
Автор

Substract and Check value and Conditional Jump in a single instruction!

hunglekhanh
Автор

This is supreme!!! ♥ Waiting for the next one in the series!!!

arkoprovo