/************************************************************************ * * * The SB-Prolog System * * Copyright SUNY at Stony Brook, 1986 * * * ************************************************************************/ /*----------------------------------------------------------------- SB-Prolog is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the SB-Prolog General Public License for full details. Everyone is granted permission to copy, modify and redistribute SB-Prolog, but only under the conditions described in the SB-Prolog General Public License. A copy of this license is supposed to have been given to you along with SB-Prolog so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. ------------------------------------------------------------------ */ /* inst.h */ /* The followings are operand types of instructions. After these will be the set of all instructions. */ #define E 0 #define PBB 1 #define BW 2 #define BC 3 #define B 4 #define PW 5 #define PC 6 #define PL 7 #define BA 8 #define BAA 9 #define PA 10 #define BL 11 #define P 12 #define BBB 13 #define PWW 14 /* these are macros to use lpcreg as the instruction pointer and to parse instruction operands into oprnd1, 2, and 3 */ #define parse_opPBB {lpcreg++; oprnd1 = (word)*lpcreg++; oprnd2 = (word)*lpcreg++;} #define parse_opBW {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;} #define parse_opBC {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;} #define parse_opB {oprnd1 = (word)*lpcreg++;} #define parse_opPW {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;} #define parse_opPC {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;} #define parse_opPL {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;} #define parse_opBA {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;} #define parse_opBAA {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4; oprnd3 = *(pw)lpcreg; lpcreg+=4;} #define parse_opPA {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;} #define parse_opBL {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;} #define parse_opP {oprnd1 = (word)*lpcreg++;} #define parse_opBBB {oprnd1 = (word)*lpcreg++; oprnd2 = (word)*lpcreg++; oprnd3 = (word)*lpcreg++;} extern int (*p_routine[])(); /* extern int (*print_routine[])(); */ extern int parse_table[]; extern char *inst_name[]; /* extern int (*jump_table[256])(); */ /**************************************************************************/ /* The followings are the set of all instructions. */ /**************************************************************************/ /* Basic term instructions (only those with a 00 annotation are now used) */ #define getpvar00 0x00 #define getpval00 0x01 #define getstrv00 0x02 #define gettval00 0x03 #define getcon00 0x04 #define getnil00 0x05 #define getstr00 0x06 #define getlist00 0x07 #define unipvar00 0x08 #define unipval00 0x09 #define unitvar00 0x0a #define unitval00 0x0b #define unicon00 0x0c #define uninil00 0x0d #define getnumcon 0x0e #define putnumcon 0x0f #define putpvar00 0x10 #define putpval00 0x11 #define puttvar00 0x12 #define putstrv00 0x13 #define putcon00 0x14 #define putnil00 0x15 #define putstr00 0x16 #define putlist00 0x17 #define bldpvar00 0x18 #define bldpval00 0x19 #define bldtvar00 0x1a #define bldtval00 0x1b #define bldcon00 0x1c #define bldnil00 0x1d #define uninumcon 0x1e #define bldnumcon 0x1f #define getfloatcon 0x20 #define putfloatcon 0x21 #define unifloatcon 0x22 #define bldfloatcon 0x23 #define getcon01 0x24 #define getnil01 0x25 #define getstr01 0x26 #define getlist01 0x27 #define unipvar01 0x28 #define unipval01 0x29 #define unitvar01 0x2a #define unitval01 0x2b #define unicon01 0x2c #define uninil01 0x2d #define putpvar01 0x30 #define putpval01 0x31 #define puttvar01 0x32 #define putcon01 0x34 #define putnil01 0x35 #define putstr01 0x36 #define putlist01 0x37 #define bldpvar01 0x38 #define bldpval01 0x39 #define bldtvar01 0x3a #define bldtval01 0x3b #define bldcon01 0x3c #define bldnil01 0x3d #define getpvar10 0x40 #define getpval10 0x41 #define gettval10 0x43 #define getcon10 0x44 #define getnil10 0x45 #define getstr10 0x46 #define getlist10 0x47 #define getlist_tvar_tvar 0x48 #define getcomma 0x49 #define getcomma_tvar_tvar 0x4a #define unicon10 0x4c #define uninil10 0x4d #define putpvar10 0x50 #define putpval10 0x51 #define puttvar10 0x52 #define putcon10 0x54 #define putnil10 0x55 #define putstr10 0x56 #define putlist10 0x57 #define bldpvar10 0x58 #define bldpval10 0x59 #define bldtvar10 0x5a #define bldtval10 0x5b #define bldcon10 0x5c #define bldnil10 0x5d #define getpvar11 0x60 #define getpval11 0x61 #define gettval11 0x63 #define getcon11 0x64 #define getnil11 0x65 #define getstr11 0x66 #define getlist11 0x67 #define unipvar11 0x68 #define unipval11 0x69 #define unitvar11 0x6a #define unitval11 0x6b #define unicon11 0x6c #define uninil11 0x6d #define putpvar11 0x70 #define putpval11 0x71 #define puttvar11 0x72 #define putcon11 0x74 #define putnil11 0x75 #define putstr11 0x76 #define putlist11 0x77 #define bldpvar11 0x78 #define bldpval11 0x79 #define bldtvar11 0x7a #define bldtval11 0x7b #define bldcon11 0x7c #define bldnil11 0x7d /* Non-determinism instructions */ #define trymeelse 0xa0 #define retrymeelse 0xa1 #define trustmeelsefail 0xa2 #define try 0xa3 #define retry 0xa4 #define trust 0xa5 #define getpbreg 0xa6 #define gettbreg 0xa7 #define putpbreg 0xa8 #define puttbreg 0xa9 #define jumptbreg 0xaa /* Indexing instructions */ #define switchonterm 0xb0 #define switchoncon 0xb1 #define switchonstr 0xb2 #define switchonbound 0xb3 /* Numeric instructions */ #define movreg 0xd1 #define negate 0xd2 #define and 0xd3 #define or 0xd4 #define lshiftl 0xd5 #define lshiftr 0xd6 #define addreg 0xd7 #define subreg 0xd8 #define mulreg 0xd9 #define divreg 0xda /* Unsafe term instructions (only those with a 00 annotation are now used) */ #define putdval00 0xe0 #define putuval00 0xe1 #define getival 0xe2 #define putuval01 0xe3 #define putdval10 0xe4 #define putuval10 0xe5 #define putdval11 0xe6 /* Procedure instructions */ #define unexec 0xe7 #define call 0xe8 #define allocate 0xe9 #define deallocate 0xea #define proceed 0xeb #define execute 0xec #define unexeci 0xed #define executev 0xee #define calld 0xef /* Branching instructions */ #define jump 0xf0 #define jumpz 0xf1 #define jumpnz 0xf2 #define jumplt 0xf3 #define jumple 0xf4 #define jumpgt 0xf5 #define jumpge 0xf6 /* Miscellaneous instructions */ #define fail 0xf8 #define noop 0xf9 #define halt 0xfa #define builtin 0xfb #define hash 0xfe /* only used for disassembling */ #define endfile 0xff /* virtual instruction, used for disassembler to link different segs */ extern int Switchoncon(); extern int Switchonstr(); extern int Switchonbound(); extern int Builtin(); /* extern int Getpval01(); extern int Gettval01(); extern int Getcon01(); extern int Getnil01(); extern int Getstr01(); extern int Getlist01(); extern int Bldpval01(); extern int Bldtval01(); extern int Unipvar01(); extern int Unitvar01(); extern int Unipval01(); extern int Unitval01(); extern int Unicon01(); extern int Uninil01(); extern int Getpval11(); extern int Gettval11(); extern int Getcon11(); extern int Getnil11(); extern int Getstr11(); extern int Getlist11(); extern int Bldpval11(); extern int Bldtval11(); */