|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
# «.test:prims» (to "test:prims")
#%%%%
#
# Tests, part 1: defining the C primitives
#
#%%%%
# «test:prims» (to ".test:prims")
SFprims EXIT \; { RS--; goto forth;
} PLUS + { DS[-1]+=DS[0]; DS--; goto forth;
} DUP { DS[1]=DS[0]; DS++; goto forth;
} 2DUP { DS[1]=DS[-1]; DS[2]=DS[0]; DS+=2; goto forth;
} SWAP { itmp=DS[-1]; DS[-1]=DS[0]; DS[0]=itmp; goto forth;
} DROP { DS--; goto forth;
} SBRANCH { SS[0]=(int)_f0+*((ushort *)(SS[0])); goto forth;
} S0BRANCH { tmp=*((ushort *)(SS[0]))++; if(DS[0]==0) SS[0]=(int)_f0+tmp;
DS--; goto forth;
}
Fprims 1 { DS[1]=1; DS++; goto forth;
} TIMES * { DS[-1]*=DS[0]; DS--; goto forth;
} COUNT { DS[1]=*((uchar *)(DS[0]))++; DS++; goto forth;
} TYPE { fwrite((void *)(DS[-1]), 1, DS[0], stdout); DS-=2; goto forth;
} CR { printf("\n"); goto forth;
} STO S> { DS[1]=SS[0]; DS++; SS--; goto forth;
} TOS >S { SS[1]=DS[0]; SS++; DS--; goto forth;
} SGOBBLE1 { DS[1]=*((uchar *)(SS[0]))++; DS++; goto forth;
} SGOBBLE2 { DS[1]=*((ushort *)(SS[0]))++; DS++; goto forth;
} WSTORE W! { *((ushort *)(DS[0]))=DS[1]; DS-=2; goto forth;
} WFETCH W@ { DS[0]=*((ushort *)(DS[0])); goto forth;
}
FIPprims RETURN { RS--; return;
} RSREXIT { RS[0]=SS[0]-((int)_f0); SS--; goto forth;
}
Hprims COL : { goto forth;
} CON { DS[1]=*(int *)(_f0+RS[0]); DS++; RS--; goto forth;
} TO { *(int *)(_f0+RS[0]+1)=DS[0]; DS--; RS--; goto forth;
} AT { DS[1]=((int)_f0)+RS[0]+2; DS++; RS--; goto forth;
} RSR { SS[1]=((int)_f0)+RS[-1]; SS++; RS[-1]=FIP_RSREXIT; goto head;
} C1 { fun=*(funptr *)(_f0+RS[0]); DS[0]=(*fun)(DS[0]); RS--; goto forth;
} C2 { fun=*(funptr *)(_f0+RS[0]); DS[-1]=(*fun)(DS[-1], DS[0]);
DS--; RS--; goto forth;
} C3 { fun=*(funptr *)(_f0+RS[0]); DS[-2]=(*fun)(DS[-2], DS[-1], DS[0]);
DS-=2; RS--; goto forth;
}