|
Project Information
Members
Featured
Wiki pages
Links
|
The system is being developed for Java SE/ME and Android by component reuse and specific machine classes. Using Jarvar. The class library for multi-platform applications. The script language of Jarvar will be so close to ACE forth, with extra benefits for protection against random stack ! crashes and other forth problems for beginners. Well I needed a simple forth so I started this project. The application is a simple Jupiter Ace clone with a few added features, and some words removed as they are not relevant or there are better ones. The emphasis on small application size, and ease of use are front most.
Most of the language is written in a pseudo forth dialect, and is compiled on loading the application. The source strings remain available to rebuild words when damaged by user experimentation. There are 28 basic primitives ! 0=* @ BEEP BYE D+ XOR EXIT INKEY INURL MEDIA NATIVE R> VIDOUT U* U/ >R (EDIT) (COMP) DROP PICK (SP) SWAP (R+) J (SKIP) (REP) (ALT) and everything else is defined in forth. This does not lead to the most efficient forth, but it is a fine compromise. The NATIVE primitive can be used to create a virtual machine code. This is included as bootstrapping is one of the purposes that Ace B Forth is put. The optimized VM method is shown below. Further vocabularies will be made available, they should easily integrate into Ace B Forth. Visit http://jupiter-ace.co.uk for more information on this machine that inspired this project. The Primitives Set private static void p(int p) {
char t = m[sp];
char s = m[sp+1];
char r = m[rp++];
int z;
long x;
switch(p) {
//!
case 0: m[t]=s; sp+=2; break;
//0=*
case 1: m[++sp] = s==0?t:0;
break;
//@
case 2: m[sp]=m[t]; break;
//BEEP
case 3: sp+=2;
beep(s, t); break;
//BYE
case 4: bye(); break;
//D+
case 5: x=(t<<16)+s;
sp+=2;
t = m[sp];
s = m[sp+1];
z = (t<<16)+s;
x+=z;
m[sp]=(char)(x>>16);
m[sp+1]=(char)x; break;
//XOR
case 6: t ^= s;
m[++sp] = t; break;
//EXIT
case 7: r = m[rp++]; //does not go back to caller of EXIT
break;
//INKEY
case 8: m[--sp]=(char)inkey(); break;
//INURL
case 9: m[sp]=(char)inurl(t);
break;
//MEDIA
case 10: sp++;
media(t); break;
//NATIVE
case 11: sp++; nativ(t); break;
//R>
case 12: m[--sp] = m[rp++];
break;
//VIDOUT
case 13: m[sp]=(char)vidout(t);
break;
//U*
case 14: x = t*s;
m[sp]=(char)(x>>16);
m[sp+1]=(char)x; break;
//U/ - returns a double
case 15: z=m[sp+2];
x = (s<<16)+z;
if(t==0) x = 0; //raphson convergence with overflow
else x /= t;
m[sp+2]=(char)x;
m[++sp]=(char)(x>>16);
break;
//>R
case 16: m[--rp] = m[sp++]; break;
//(EDIT)
case 17: edit(m[sp++]); break;
//(COMP)
case 18: z = m[--sp] = m[rp];//params
m[rp] += (m[r+1]==(char)(-1))?m[z]+1:m[r+1];//return ip after params
//the m[z]+1 is for counted strings etc.
r += m[r];//link RUNS>
break;
//DROP
case 19: sp++; break;
//PICK
case 20: m[sp] = m[(char)(sp+t)]; break;
//(SP)
case 21: m[--sp] = sp; break;//effects (sp+1) as top
//SWAP
case 22: m[sp+1] = t; m[sp] = s; break;
//(R+)
case 23: m[rp] += t; sp++; break;
//J
case 24: m[--sp] = m[rp+2]; break;
//(SKIP)
case 25: r+=(m[sp++]==0)?0:1; break;
//(REP)
case 26: r-=(m[sp++]==0)?0:2; break;
//(ALT)
case 27: r=(m[sp++]==0)?m[r]:(char)(r+1);
}
ip=r;
}
|