aboutsummaryrefslogtreecommitdiff
path: root/pu2/pu2.out.c
diff options
context:
space:
mode:
authorGravatar Moon Flower <moon@coffin.ir> 2025-08-13 19:33:41 +0330
committerGravatar Moon Flower <moon@coffin.ir> 2025-08-13 19:33:41 +0330
commit8d072d8dc0d22ffd716f53f40893644b8e748fc2 (patch)
treeca73a83f5ffdcea61199f74130257045856ccc6b /pu2/pu2.out.c
parentdeleted binaries (diff)
arithmetics unit in emu
Diffstat (limited to 'pu2/pu2.out.c')
-rw-r--r--pu2/pu2.out.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/pu2/pu2.out.c b/pu2/pu2.out.c
index e13c983..63c41f1 100644
--- a/pu2/pu2.out.c
+++ b/pu2/pu2.out.c
@@ -9,16 +9,19 @@
// maybe compacter? idk
// last cpu: 167 chars
-// NOTE: if you want the cpu to
-// crash or do something when an invalid opcode is met,
-// replace the `8` in the code with whatever behavior you desire.
-// you can use ({...}) to insert normal code, or use __builtin_trap() for a SIGTRAP
+#define A 8
+// change this for error reporting on unknown instructions!
+// examples:
+// #define A __builtin_trap()
+// ^ does SIGTRAP
+// #define A my_custom_cpu_error_trap()
+// ^ calls my_custom_cpu_error_trap()
// clang-format off
#define S 1<<20
#define H !--c
#define J while
-m[S],c,v,a,b,u;pu2(){J(c=m[m[7]++],v=m[m[7]++],c){H?a=v:H?a=m[b]:H?u?m[a]=b:0:H?v=a,a=b,b=v:H?a+=b:H?a-=b:H?a&=b:H?a=!a:H?u=1:8;u=v;}}
+m[S],c,v,a,b,u;pu2(){J(c=m[m[7]++],v=m[m[7]++],c){H?a=v:H?a=m[b]:H?u?m[a]=b:0:H?v=a,a=b,b=v:H?a+=b:H?a-=b:H?a&=b:H?a=!a:H?u=1:A;u=v;}}
// clang-format on
// there's just memory. no, really
@@ -54,4 +57,5 @@ char*C="hltimmlodstrswpaddsubandnotacc",*Y[1<<10],*E,*L,i;*K;as2(char*I){J(c=*I+
#undef S
#undef H
-#undef J \ No newline at end of file
+#undef J
+#undef E \ No newline at end of file