From 99ddb408233dceb6e67771e67d1df29feb68e522 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Sat, 16 Aug 2025 20:04:21 +0330 Subject: i cant stop making cpus... here's a parallelized one --- README.md | 25 ++++++++++++++++++++----- ppu/ppu.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 ppu/ppu.c diff --git a/README.md b/README.md index e2bfa42..7deb686 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,31 @@ -# pu2! +# pu2 + ppu! smaller, better, faster, compact-er! let's gooooo -## how does this workkk +## pu2 + +### how does this workkk to be humble, pretty clever stuff. (i forgor) -## WHAT IS PU2 +### WHAT IS PU2 - CPU Emulator - Assembler - Test Suite -## instruction set -pu2 has less instructions than pu (aka pu1), +### instruction set +pu2 has less instructions than pu (aka pu1), [moon's note: wow it seems like i forgor to complete this sentence...] + +## ppu + +### what the hell +yeah i know! it's a parallel cpu. so much cool stuff you can do with openmp. just make sure to compile with `-fopenmp` + +### WHAT IS THIS +- CPU +- Assembler +- A full day of pain and suffering (now that i think about it, a day isn't really that much time) + +### instruction set +RTFM (in ppu/ppu.c ofc) # ~~moonvm~~ ~~i have no idea what to name this. gimme names if you got any.~~ diff --git a/ppu/ppu.c b/ppu/ppu.c new file mode 100644 index 0000000..9b4fc5a --- /dev/null +++ b/ppu/ppu.c @@ -0,0 +1,57 @@ +#define inline + +#include +#include +#include +#include + +#pragma clang diagnostic ignored "-Wreturn-type" + +typedef char* string; + +// opcodes! +// 0: halt +// 1: nop +// 2: mov +// 3: movi +// 4: add +// 5: addi +// 6: sub +// 7: subi +// 8: moveq -> moves m[B] to m[A] if m[Q] == 0 +// program counter is m[0] +// Q is set to the previous A in memory + +// error handling for unknown ops +#define W 0 + +// clang-format off +#define J while +#define S 1<<20 +#define H !K-- +m[S]={0},c,N,Q,E; +ppu(){E=1;_Pragma("omp parallel")J(E){_Pragma("omp single")N=m[m[0]],c=m[0],m[0]+=++N*4;int i;_Pragma("omp for")for(i=0;i