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 --- ppu/ppu.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ppu/ppu.c (limited to 'ppu') 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