home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1999 February
/
MACPOWER-1999-02.ISO.7z
/
MACPOWER-1999-02.ISO
/
9902⁄AMUG
/
UTILITY
/
mac06-0.95.sit
/
mac06-0.95
/
include
/
ucode.h
< prev
next >
Wrap
Text File
|
1998-08-23
|
4KB
|
157 lines
/* mac06ゥ1998 by HNS/DSITRI hns@computer.org
** universal code (ucode)
*/
#pragma once
typedef char *uaddress;
typedef unsigned long uopcode;
typedef union udata
{ /* entry in data stack */
unsigned long i;
uaddress p;
/* double d; */
} udata;
typedef union ustack
{ /* entry in procedure stack */
unsigned long i; /* data value */
uopcode *p; /* return address */
} ustack;
struct ucode
{
uaddress text, data, bss, stack, exstack; /* code segments */
uaddress textend, dataend, bssend, stackend, exend; /* end of segments */
uopcode *pc; /* program pointer */
ustack *sp; /* call, args, auto stack pointer */
udata *dsp; /* expression stack */
};
typedef struct longjmp
{ /* longjump frame */
uopcode *pc;
ustack *sp;
udata *dsp;
long value;
};
enum { /* opcodes in upper 8 bits of command */
/* constants */
OPC_CONST=0, /* 24 bit positive constant */
OPC_NCONST, /* 24 bit negative constant */
OPC_HCONST, /* 24 bit high part of constant added to tos */
OPC_FCONST,
OPC_DCONST,
OPC_TEXT=8, /* 24 bit offset into text segment */
OPC_DATA, /* 24 bit offset into data segment */
OPC_BSS, /* 24 bit offset into bss segment */
/* program flow */
OPC_CALL=0x10, /* call tos */
OPC_JMP, /* jmp to tos */
OPC_JTRUE, /* jump to tos if nos true */
OPC_JFALSE, /* jump to tos if nos false */
OPC_RET, /* return */
OPC_SETJMP, /* set jump (tos=addr of jmpbuf) */
OPC_LONGJMP, /* long jump (tos=addr of jmpbuf) */
/* switch/case program flow */
OPC_SWITCHSRCH, /* search table for switch */
OPC_SWITCHJMP, /* jmp table for switch */
/* stack manipulation */
OPC_PUSH=0x20, /* push tos on stack */
OPC_POP, /* pop from stack */
OPC_ALLOC, /* allocate/deallocate space stack */
OPC_AUTO, /* make stack offset */
/* binary arithmetic and logical operations */
OPC_ADD=0x30,
OPC_SUB,
OPC_MUL,
OPC_UMUL,
OPC_DIV,
OPC_UDIV,
OPC_MOD,
OPC_UMOD,
OPC_AND,
OPC_OR,
OPC_XOR,
/* binary shift operations */
OPC_SHL=0x40,
OPC_USHL,
OPC_SHR,
OPC_USHR,
/* binary compare operations */
OPC_LT=0x50,
OPC_ULT,
OPC_GT,
OPC_UGT,
OPC_LE,
OPC_ULE,
OPC_GE,
OPC_UGE,
OPC_EQ,
OPC_NEQ,
/* unary operations */
OPC_EQZ=0x60,
OPC_NZ,
OPC_NEG,
OPC_NOT,
OPC_CHS,
OPC_SHIFT, /* multiply by 2 - for fast index calculations */
OPC_SEXTB, /* sign extend byte -> long */
OPC_SEXTW, /* sign extend word -> long */
/* working stack manipulation */
OPC_DUP=0x70, /* duplicate value */
OPC_SWAP, /* swap tos and nos */
OPC_DROP, /* throw away value */
OPC_NDUP, /* duplicate n-th value */
/* store to memory */
OPC_STOREB=0x80,
OPC_STOREW,
OPC_STOREL,
OPC_STOREF,
OPC_STORED,
/* fetch from memory */
OPC_FETCHB=0x90,
OPC_FETCHW,
OPC_FETCHL,
OPC_FETCHF,
OPC_FETCHD,
OPC_UFETCHB,
OPC_UFETCHW,
OPC_UFETCHL,
/* floating point operations */
OPC_FADD=0xa0, /* dyadic */
OPC_FSUB,
OPC_FMUL,
OPC_FDIV,
OPC_FLT,
OPC_FULT,
OPC_FGT,
OPC_FUGT,
OPC_FLE,
OPC_FULE,
OPC_FGE,
OPC_FUGE,
OPC_FEQ,
OPC_FNEQ,
OPC_FCHS=0xb0, /* monadic */
OPC_FEQZ,
OPC_FNZ,
OPC_LTOF, /* long to double */
OPC_ULTOF, /* unsigned long to double */
OPC_FTOL, /* double to integer */
OPC_ROUND, /* double to float truncation */
/* system call */
OPC_SVC=0xc0, /* supervisor call */
/* builtin functions */
OPC_CPYINC, /* block copy with inc mode */
OPC_CPYDEC, /* block copy with dec mode */
OPC_SET, /* set block */
OPC_SRCH /* search in block */
};
void run(struct ucode *c, register long n);
/* EOF */