mirror of https://git.cro.wtf/kip.git
kmm32:cuter K flag implementation & cleanup
This commit is contained in:
parent
62453d6377
commit
bc23878497
9
kmm32.c
9
kmm32.c
|
@ -4,12 +4,10 @@
|
|||
#define DS ((W*)(mem+(MEMSZ-0x800)))
|
||||
#define RS ((W*)(mem+(MEMSZ-0x400)))
|
||||
#define SD (RS-DS)
|
||||
#include<stdio.h>
|
||||
|
||||
B mem[MEMSZ];
|
||||
W*dp=DS,*rp=RS,ip;
|
||||
|
||||
//_ W pop(V){R*--dp;}
|
||||
_ V put(W i){*dp++=i;}
|
||||
_ V pur(W i){*rp++=i;}
|
||||
_ V swp(V){W*t;t=dp,dp=rp,rp=t;}
|
||||
|
@ -68,11 +66,6 @@ _ V(*ops[])(V)=
|
|||
_ B arity[]=
|
||||
{ 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 2};
|
||||
|
||||
_ V op(B n){B k,f,c,o;o=n&0x3f,f=n>>6&1,k=n>>7,c=arity[o];
|
||||
Q(f,swp())
|
||||
Q(0==c, ops[o]())OR
|
||||
Q(1==c,a=dp[-1], dp-= !k,ops[o]())OR
|
||||
Q(2==c,a=dp[-2],b=dp[-1],dp-=2*!k,ops[o]())
|
||||
Q(f,swp())}
|
||||
_ V op(B n){B k,f,c,o;o=n&0x3f,f=n>>6&1,k=n>>7,c=arity[o];Q(f,swp())a=dp[0-c],b=dp[1-c],dp-=c*!k,ops[o]();Q(f,swp())}
|
||||
V emu(V){while(ip<0x40000){op(mem[ip++]);}}
|
||||
V lod(B*c,W l){for(ip=0;ip<l;++ip)mem[ip+0x100]=c[ip];ip=0x100;}
|
||||
|
|
Loading…
Reference in New Issue