aboutsummaryrefslogtreecommitdiff
path: root/pu2/pu2.out.c
diff options
context:
space:
mode:
Diffstat (limited to 'pu2/pu2.out.c')
-rw-r--r--pu2/pu2.out.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/pu2/pu2.out.c b/pu2/pu2.out.c
index 63c41f1..05d96c3 100644
--- a/pu2/pu2.out.c
+++ b/pu2/pu2.out.c
@@ -18,24 +18,28 @@
// ^ calls my_custom_cpu_error_trap()
// clang-format off
-#define S 1<<20
-#define H !--c
+#define S 1<<25
#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:A;u=v;}}
+#define H !--c
+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=v:H?u=a:H?a=u:H?u=b:H?b=u:A;}}
// clang-format on
// there's just memory. no, really
// ok actually there's two registers called a and b
-// 0 HLT: halt
-// 1 IMM: a = imm
-// 2 LOD: a = m[b]
-// 3 STR: m[a] = b (only happens if acc != 0)
-// 4 SWP: swap a and b
-// 5 ADD: a += b
-// 6 SUB: a -= b
-// 7 AND: a &= b
-// 8 NOT: a = !a
-// 9 ACC: u = imm
+// 0 HLT: halt
+// 1 IMM: a = imm
+// 2 LOD: a = m[b]
+// 3 STR: m[a] = b (only happens if acc != 0)
+// 4 SWP: swap a and b
+// 5 ADD: a += b
+// 6 SUB: a -= b
+// 7 AND: a &= b
+// 8 NOT: a = !a
+// 9 ACC: u = imm
+// 10 A2U: u = a
+// 11 U2A: a = u
+// 12 B2U: u = b
+// 13 U2B: b = u
// NOTE: Memory indexes less than 1024 should be considered as temporary/compute memory, and
// programs should be written at index 1024 and upwards.
@@ -52,10 +56,10 @@ 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?
// therefore, i recommend you store a copy somewhere!
// clang-format off
-char*C="hltimmlodstrswpaddsubandnotacc",*Y[1<<10],*E,*L,i;*K;as2(char*I){J(c=*I++){if(c==35){J(*++I-10);c=*I++;}L=C;(!isspace(c)?c-39?c-125?c-123?c-64?({i=0,I--;J(i++,*L)strncmp(L,I,3)?L+=3:({I+=3;*K++=i-1;*K++=(i-2&&i-9)?0:strtol(I,&I,10);goto Q;});E=I;return 1;Q:;}):as2(Y[strtol(I,&I,10)]):({Y[strtol(I,&I,10)]=I+1;J(*I++-125);}):({break;}):({*K++=1;*K++=*I++;}):0);}}
+char*C="hltimmlodstrswpaddsubandnotacca2uu2ab2uu2b",*Y[1<<10],*E,*L,i;*K;as2(char*I){J(c=*I++){if(c==35){J(*++I-10);c=*I++;}L=C;(!isspace(c)?c-39?c-125?c-123?c-64?({i=0,I--;J(i++,*L)strncmp(L,I,3)?L+=3:({I+=3;*K++=i-1;*K++=(i-2&&i-9)?0:strtol(I,&I,10);goto Q;});E=I;return 1;Q:;}):as2(Y[strtol(I,&I,10)]):({Y[strtol(I,&I,10)]=I+1;J(*I++-125);}):({break;}):({*K++=1;*K++=*I++;}):0);}}
// clang-format on
-#undef S
+// #undef S
#undef H
#undef J
#undef E \ No newline at end of file