Changeset e3d98a3e5f26a50eabeb6eaa559aa3f396ae02ce
Commiter: Charles Childers
Author: Charles Childers
Parent: d0b60129b7
(2010/04/23 00:29) Almost 2 years ago
shrink it a bit more
Commiter: Charles Childers
Author: Charles Childers
Parent: d0b60129b7
(2010/04/23 00:29) Almost 2 years ago
shrink it a bit more
switch(opcode) {switch(opcode) {/***************************************************//* NOP Does Nothing. Used for padding *//* Opcode: 0 Stack: - Address: - *//***************************************************//* LIT Push the value in the following cell to *//* the stack *//* Opcode: 1 n Stack: -n Address: - *//***************************************************//* DUP Duplicate the value on the top of the *//* stack *//* Opcode: 2 Stack: n-nn Address: - *//***************************************************//* DROP Drop the value on the top of the stack *//* Opcode: 3 Stack: n- Address: - *//***************************************************//* SWAP Exchange the top two values on the stack *//* Opcode: 4 Stack: xy-yx Address: - *//***************************************************//* PUSH Move the top value on the stack to the *//* address stack. Remove it from the data *//* stack. *//* Opcode: 5 Stack: n- Address: -n *//***************************************************//* POP Move the top value from the address *//* stack to the data stack. Remove it from *//* the address stack. *//* Opcode: 6 Stack: -n Address: n- *//***************************************************//* CALL Call a subroutine whose address is given *//* in the following cell. Push the address *//* following this instruction to the address*//* stack. *//* Opcode: 7 a Stack: - Address: -a *//***************************************************//* JUMP Unconditional jump to the address given *//* in the following cell. *//* Opcode: 8 a Stack: - Address: - *//***************************************************//* ; Return from a subroutine. Control is *//* passed to the address on the top of the *//* address stack. *//* Opcode: 9 Stack: - Address: a- *//***************************************************//* >JUMP Jump to the address in the following *//* cell if NOS > TOS. *//* Opcode: 10 a Stack: xy- Address: - *//***************************************************//* <JUMP Jump to the address in the following *//* cell if NOS < TOS. *//* Opcode: 11 a Stack: xy- Address: - *//***************************************************//* !JUMP Jump to the address in the following *//* cell if NOS <> TOS. *//* Opcode: 12 a Stack: xy- Address: - *//***************************************************//* =JUMP Jump to the address in the following *//* cell if NOS = TOS. *//* Opcode: 13 a Stack: xy- Address: - *//***************************************************//* @ Fetch a value from a memory location *//* Opcode: 14 Stack: a-n Address: - *//***************************************************//* ! Store a value to a memory location *//* Opcode: 15 Stack: na- Address: - *//***************************************************//* + Add TOS and NOS, leaving the result *//* Opcode: 16 Stack: xy-z Address: - *//***************************************************//* - Subtract TOS from NOS, leaving the result*//* Opcode: 17 Stack: xy-z Address: - *//***************************************************//* * Multiply TOS by NOS, leaving the result *//* Opcode: 18 Stack: xy-z Address: - *//***************************************************//* /MOD Divide NOS by TOS, leaving the quotient *//* and remainder. *//* Opcode: 19 Stack: xy-qr Address: - *//***************************************************//* AND Perform a bitwise and operation on TOS *//* and NOS. *//* Opcode: 20 Stack: xy-z Address: - *//***************************************************//* OR Perform a bitwise or operation on TOS *//* and NOS. *//* Opcode: 21 Stack: xy-z Address: - *//***************************************************//* XOR Perform a bitwise xor operation on TOS *//* and NOS. *//* Opcode: 22 Stack: xy-z Address: - *//***************************************************//* << Shift NOS left by TOS bits. *//* Opcode: 23 Stack: xy-z Address: - *//***************************************************//* >> Shift NOS right by TOS bits. *//* Opcode: 24 Stack: xy-z Address: - *//***************************************************//* 0; Return from a subroutine if TOS = 0. *//* If TOS = 0, DROP TOS. *//* If TOS <> 0, do nothing *//* Opcode: 25 Stack: n- Address: a- *//* Stack: n-n Address: - */if (TOS == 0) {if (TOS == 0) {/***************************************************//* 1+ Increase TOS by 1 *//* Opcode: 26 Stack: x-y Address: - *//***************************************************//* 1- Decrease TOS by 1 *//* Opcode: 27 Stack: x-y Address: - *//***************************************************//* IN Read a value from an I/O port *//* Opcode: 28 Stack: p-n Address: - *//***************************************************//* OUT Send a value to an I/O port *//* Opcode: 29 Stack: np- Address: - *//***************************************************//* WAIT Wait for an I/O event to occur. *//* Opcode: 30 Stack: - Address: - *//***************************************************//* IMPLICIT CALL *//* If we don't recognize the opcode, treat it as a *//* subroutine address and CALL it. *//* Opcode: * a Stack: - Address: -a *//* Once done, cleanup */