Figuring out the TD4 4-bit DIY CPU made from logic chips...
https://emalliab.wordpress.com/2025/09/18/td4-4-bit-diy-cpu/
Figuring out the TD4 4-bit DIY CPU made from logic chips...
https://emalliab.wordpress.com/2025/09/18/td4-4-bit-diy-cpu/
It works! That was a great build :)
Details here: https://emalliab.wordpress.com/2025/09/28/td4-4-bit-diy-cpu-part-2/
A simple 4-bit "Larson Scanner" - just a sequence of OUT instructions and a jump.
And now with some notes on programming and some example programs.
BTW - Anyone think of a way to multiply two numbers given only two registers and no other storage...?
https://emalliab.wordpress.com/2025/10/01/td4-4-bit-diy-cpu-part-3/
@Segebodo I'd guess that would need some kind of look up table to do?
To be honest, my solution so far is a look up table for the only four sums I'm actually able to process anyway on a 4-bit computer with a single input :)
@emalliab Here's a program that sums the log 2 of any amount of consecutive inputs.
It uses
IN A, x (which is A = IN + data)
JNC label
to implement
if A <= (15-x) goto label
@emalliab
//multiply any amount of numbers
//returns the sum of the approximate log 2 values (log2 of the product)
//any input that's zero is ignored
next_number:
OUT B //show result
OUT 15 //signal for next input
IN A 14
JNC next_number //if x<=1 -> log2(x)=0
ADD B 1
IN A 12
JNC next_number //if x<=3 -> log2(x)=1
ADD B 1
IN A 9
JNC next_number //if x<=6 -> log2(x)=2
ADD B 1
IN A 3
JNC next_number //if x<=12 -> log2(x)=3
ADD B 1
JMP next_number //else log2=4
@emalliab
I used the assembler compiler and simulator from https://www.philipzucker.com/td4-4bit-cpu/
and made a lot of changes (added compiler errors, added label functionality).
Here's the python code:
https://www.onlineide.pro/playground/share/9e52afd6-ab3f-4f06-946a-e9eb05cc307d
(Link expires after 1 month)
I don't have the full or claim any copyright for the code.