Next: Control-Related Instructions Up: Primitive Instructions Previous: Primitive Instructions

### Basic Data Stack-Related Instructions

1. ARITHMETIC. c0(),c1(), c2(), ..., c5() return constants 0, 1, 2, 3, 4, 5, respectively; inc(x) returns ; dec(x) returns ; by2(x) returns ; add(x,y) returns ; sub(x,y) returns ; mul(x,y) returns ; div(x,y) returns the smallest integer ; powr(x,y) returns (and costs unit time steps).

2. BOOLEAN. Operand eq(x,y) returns 1 if , otherwise 0. Analogously for geq(x,y) (greater or equal), grt(x,y) (greater). Operand and(x,y) returns 1 if and , otherwise 0. Analogously for or(x,y). Operand not(x) returns 1 if , otherwise 0.

3. SIMPLE STACK MANIPULATORS. del() decrements dp; clear() sets ; dp2ds() returns dp; setdp(x) sets ; ip2ds() returns ; base() returns ; fromD() returns ; toD() pushes onto Ds; delD() decrements Dp; topf() returns the integer name of the most recent self-made function; intopf() and outopf() return its number of requested inputs and outputs, respectively; popf() decrements fnp, returning its old value; xmn(m,n) exchanges the -th and the -th elements of ds, measured from the stack's top; ex() works like xmn(1,2); xmnb(m,n) exchanges the -th and the -th elements above the current base ; outn(n) returns ; outb(n) returns (the -th element above the base pointer); inn(n) copies onto ; innb(n) copies onto .

4. PUSHING CODE. Instruction getq(n) pushes onto ds the sequence beginning at the start address of the -th frozen program (either user-defined or frozen by OOPS) and ending with the program's final token. insq(n,a) inserts the -th frozen program above , then increases dp by the program size. Useful for copying previously frozen code into modifiable memory, to later edit the copy.

5. EDITING STRINGS ON STACK. Instruction cpn(n) copies the n topmost ds entries onto the top of ds, increasing dp by ; up() works like cpn(1); cpnb(n) copies ds entries above onto the top of ds, increasing dp by ; mvn(a,b,n) copies the ds entries starting with to and following cells, appropriately increasing dp if necessary; ins(a,b,n) inserts the ds entries above after , appropriately increasing dp; deln(a,n) deletes the ds entries above , appropriately decreasing dp; find(x) returns the stack index of the topmost entry in ds matching ; findb(x) the index of the first ds entry above base matching . Many of the above instructions can be used to edit stack contents that may later be interpreted as executable code.

Next: Control-Related Instructions Up: Primitive Instructions Previous: Primitive Instructions
Juergen Schmidhuber 2004-04-15

Back to OOPS main page