1 /* bytecodes.h -- Constant definitions of lispmach byte-codes 2 Copyright (C) 1993, 1994 John Harper <john@dcs.warwick.ac.uk> 3 $Id$ 4 5 This file is part of Jade. 6 7 Jade is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2, or (at your option) 10 any later version. 11 12 Jade is distributed in the hope that it will be useful, but 13 WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Jade; see the file COPYING. If not, write to 19 the Free Software Foundation, 51 Franklin Street, Fifth Floor, 20 Boston, MA 02110-1301 USA */ 21 22 #ifndef BYTECODES_H 23 #define BYTECODES_H 24 25 /* Don't forget to update the version number 26 * in lisp/rep/vm/bytecode-defs.jl, too. */ 27 #define BYTECODE_MAJOR_VERSION 11 28 #define BYTECODE_MINOR_VERSION 1 29 30 /* Number of bits encoded in each extra opcode forming the argument. */ 31 #define ARG_SHIFT 8 32 33 /* The bits in the opcode used to encode the argument. */ 34 #define OP_ARG_MASK 0x07 35 36 /* The inverse of the above. */ 37 #define OP_OP_MASK 0xf8 38 39 /* Special arg specifying that the next opcode is actually an 8-bit 40 argument. */ 41 #define OP_ARG_1BYTE 6 42 43 /* Special arg meaning following two opcodes are a 16-bit argument. The 44 first opcode is the high bits, the second the low bits. */ 45 #define OP_ARG_2BYTE 7 46 47 48 /* Opcodes which have an argument encoded in them */ 49 50 #define OP_SLOT_REF 0x00 51 52 #define OP_SLOT_REF_0 0x00 53 #define OP_SLOT_REF_1 0x01 54 #define OP_SLOT_REF_2 0x02 55 #define OP_SLOT_REF_3 0x03 56 #define OP_SLOT_REF_4 0x04 57 #define OP_SLOT_REF_5 0x05 58 #define OP_SLOT_REF_6 0x06 59 #define OP_SLOT_REF_7 0x07 60 61 /* Call function on top of stack with following ARG parameters. Leave 62 result on stack. */ 63 #define OP_CALL 0x08 64 65 /* Push const[ARG] onto the stack. */ 66 #define OP_PUSH 0x10 67 68 /* Push the value of the symbol const[ARG] onto the stack. */ 69 #define OP_REFG 0x18 70 71 /* Set the value of symbol const[ARG] to the value on the 72 stack. Pops the value off the stack. */ 73 #define OP_SETG 0x20 74 75 /* Sets the ARG'th value in the lexical environment. Pops value */ 76 #define OP_SETN 0x28 77 78 #define OP_SLOT_SET 0x30 79 80 #define OP_SLOT_SET_0 0x30 81 #define OP_SLOT_SET_1 0x31 82 #define OP_SLOT_SET_2 0x32 83 #define OP_SLOT_SET_3 0x33 84 #define OP_SLOT_SET_4 0x34 85 #define OP_SLOT_SET_5 0x35 86 #define OP_SLOT_SET_6 0x36 87 #define OP_SLOT_SET_7 0x37 88 89 /* Pushes the ARG'th value in the lexical environment */ 90 #define OP_REFN 0x38 91 92 #define OP_REFN_0 0x38 93 #define OP_REFN_1 0x39 94 #define OP_REFN_2 0x3a 95 #define OP_REFN_3 0x3b 96 #define OP_REFN_4 0x3c 97 #define OP_REFN_5 0x3d 98 #define OP_REFN_6 0x3e 99 #define OP_REFN_7 0x3f 100 101 #define OP_LAST_WITH_ARGS 0x3f 102 103 104 /* Opcodes without arguments. */ 105 106 #define OP_REF 0x40 /* push (symbol-value pop) */ 107 #define OP__SET 0x41 /* (set stk[1] stk[0]); pop; pop */ 108 #define OP_FLUID_REF 0x42 /* call-1 fluid-ref */ 109 #define OP_ENCLOSE 0x43 /* push (make-closure pop[1] nil) */ 110 #define OP_INIT_BIND 0x44 /* new-binding-set */ 111 #define OP_UNBIND 0x45 /* rewind-binding-set */ 112 #define OP_DUP 0x46 /* push stk[0] */ 113 #define OP_SWAP 0x47 /* stk[0] = stk[1], stk[1] = stk[0] */ 114 #define OP_POP 0x48 /* pop[1] */ 115 116 #define OP_NIL 0x49 /* push nil */ 117 #define OP_T 0x4a /* push t */ 118 #define OP_CONS 0x4b /* push (cons pop[1] pop[2]) */ 119 #define OP_CAR 0x4c /* push (car pop[1]) */ 120 #define OP_CDR 0x4d /* push (cdr pop[2]) */ 121 #define OP_RPLACA 0x4e /* call-2 rplaca */ 122 #define OP_RPLACD 0x4f /* call-2 rplacd */ 123 #define OP_NTH 0x50 /* call-2 nth */ 124 #define OP_NTHCDR 0x51 /* call-2 nthcdr */ 125 #define OP_ASET 0x52 /* call-3 aset */ 126 #define OP_AREF 0x53 /* call-2 aref */ 127 #define OP_LENGTH 0x54 /* call-1 length */ 128 #define OP_BIND 0x55 129 #define OP_ADD 0x56 /* push (+ pop[1] pop[2]) */ 130 #define OP_NEG 0x57 /* push (- pop[1]) */ 131 #define OP_SUB 0x58 /* push (- pop[1] pop[2]) */ 132 #define OP_MUL 0x59 /* push (* pop[1] pop[2]) */ 133 #define OP_DIV 0x5a /* push (/ pop[1] pop[2]) */ 134 #define OP_REM 0x5b /* push (% pop[1] pop[2]) */ 135 #define OP_LNOT 0x5c /* push (lognot pop[1]) */ 136 #define OP_NOT 0x5d /* push (not pop[1]) */ 137 #define OP_LOR 0x5e /* push (logior pop[1] pop[2]) */ 138 #define OP_LAND 0x5f /* push (logand pop[1] pop[2]) */ 139 #define OP_EQUAL 0x60 /* push (equal pop[1] pop[2]) */ 140 #define OP_EQ 0x61 /* push (eq pop[1] pop[2]) */ 141 #define OP_STRUCT_REF 0x62 /* push (structure-ref pop[1] pop[2])*/ 142 #define OP_SCM_TEST 0x63 143 #define OP_GT 0x64 /* push (> pop[1] pop[2]) */ 144 #define OP_GE 0x65 /* push (>= pop[1] pop[2]) */ 145 #define OP_LT 0x66 /* push (< pop[1] pop[2]) */ 146 #define OP_LE 0x67 /* push (<= pop[1] pop[2]) */ 147 #define OP_INC 0x68 /* push (1+ pop[1]) */ 148 #define OP_DEC 0x69 /* push (1- pop[1]) */ 149 #define OP_ASH 0x6a /* push (ash pop[1] pop[2]) */ 150 #define OP_ZEROP 0x6b /* push (zerop pop[1]) */ 151 #define OP_NULL 0x6c /* push (null pop[1]) */ 152 #define OP_ATOM 0x6d /* push (atom pop[1]) */ 153 #define OP_CONSP 0x6e /* push (consp pop[1]) */ 154 #define OP_LISTP 0x6f /* push (listp pop[1]) */ 155 #define OP_NUMBERP 0x70 /* push (numberp pop[1]) */ 156 #define OP_STRINGP 0x71 /* push (stringp pop[1]) */ 157 #define OP_VECTORP 0x72 /* push (vectorp pop[1]) */ 158 #define OP_CATCH 0x73 /* if stk[0] == (car stk[1]) 159 then stk[0] := nil, 160 stk[1] = (cdr stk[1]) */ 161 #define OP_THROW 0x74 /* throw_val = (cons pop[1] pop[2]), 162 goto error-handler */ 163 #define OP_BINDERR 0x75 /* bind (cons pop[1] SP) */ 164 #define OP_RETURN 0x76 165 #define OP_UNBINDALL 0x77 166 #define OP_BOUNDP 0x78 /* call-1 boundp */ 167 #define OP_SYMBOLP 0x79 /* push (symbolp pop[1]) */ 168 #define OP_GET 0x7a /* call-2 get */ 169 #define OP_PUT 0x7b /* call-3 put */ 170 #define OP_ERRORPRO 0x7c /* cond = pop[1]; 171 if match_error(stk[0], cond) 172 then bindsym (stk[1], cdr stk[0]), 173 stk[0] = nil */ 174 #define OP_SIGNAL 0x7d /* call-2 signal */ 175 #define OP_QUOTIENT 0x7e 176 #define OP_REVERSE 0x7f /* call-1 reverse */ 177 #define OP_NREVERSE 0x80 /* call-1 nreverse */ 178 #define OP_ASSOC 0x81 /* call-2 assoc */ 179 #define OP_ASSQ 0x82 /* call-2 assq */ 180 #define OP_RASSOC 0x83 /* call-2 rassoc */ 181 #define OP_RASSQ 0x84 /* call-2 rassq */ 182 #define OP_LAST 0x85 /* call-1 last */ 183 #define OP_MAPCAR 0x86 /* call-2 mapcar */ 184 #define OP_MAPC 0x87 /* call-1 mapc */ 185 #define OP_MEMBER 0x88 /* call-2 member */ 186 #define OP_MEMQ 0x89 /* call-2 memq */ 187 #define OP_DELETE 0x8a /* call-2 delete */ 188 #define OP_DELQ 0x8b /* call-2 delq */ 189 #define OP_DELETE_IF 0x8c /* call-2 delete-if */ 190 #define OP_DELETE_IF_NOT 0x8d /* call-2 delete-if-not */ 191 #define OP_COPY_SEQUENCE 0x8e /* call-1 copy-sequence */ 192 #define OP_SEQUENCEP 0x8f /* call-1 sequencep */ 193 #define OP_FUNCTIONP 0x90 /* call-1 functionp */ 194 #define OP_SPECIAL_FORM_P 0x91 /* call-1 special-form-p */ 195 #define OP_SUBRP 0x92 /* call-1 subrp */ 196 #define OP_EQL 0x93 /* push (eql pop[1] pop[2]) */ 197 #define OP_LXOR 0x94 /* push (logxor pop[1] pop[2] */ 198 #define OP_MAX 0x95 /* push (max pop[1] pop[2]) */ 199 #define OP_MIN 0x96 /* push (min pop[1] pop[2]) */ 200 #define OP_FILTER 0x97 /* call-2 filter */ 201 #define OP_MACROP 0x98 /* call-1 macrop */ 202 #define OP_BYTECODEP 0x99 /* call-1 bytecodep */ 203 204 #define OP_PUSHI0 0x9a /* push #0 */ 205 #define OP_PUSHI1 0x9b /* push #1 */ 206 #define OP_PUSHI2 0x9c /* push #2 */ 207 #define OP_PUSHIM1 0x9d /* push #-1 */ 208 #define OP_PUSHIM2 0x9e /* push #-2 */ 209 #define OP_PUSHI 0x9f /* push (signed) pc[0] */ 210 #define OP_PUSHIWN 0xa0 /* push (- pc[0,1]) */ 211 #define OP_PUSHIWP 0xa1 /* push (+ pc[0,1]) */ 212 213 #define OP_CAAR 0xa2 /* push (car (car pop[1])) */ 214 #define OP_CADR 0xa3 /* push (car (cdr pop[1])) */ 215 #define OP_CDAR 0xa4 /* push (cdr (car pop[1])) */ 216 #define OP_CDDR 0xa5 /* push (cdr (cdr pop[1])) */ 217 218 #define OP_CADDR 0xa6 219 #define OP_CADDDR 0xa7 220 #define OP_CADDDDR 0xa8 221 #define OP_CADDDDDR 0xa9 222 #define OP_CADDDDDDR 0xaa 223 #define OP_CADDDDDDDR 0xab 224 225 #define OP_FLOOR 0xac 226 #define OP_CEILING 0xad 227 #define OP_TRUNCATE 0xae 228 #define OP_ROUND 0xaf 229 230 #define OP_APPLY 0xb0 231 #define OP_FORBID 0xb1 232 #define OP_PERMIT 0xb2 233 234 #define OP_EXP 0xb3 235 #define OP_LOG 0xb4 236 #define OP_SIN 0xb5 237 #define OP_COS 0xb6 238 #define OP_TAN 0xb7 239 #define OP_SQRT 0xb8 240 #define OP_EXPT 0xb9 241 242 #define OP_SWAP2 0xba /* stk[0] = stk[1], stk[1] = stk[2], 243 stk[2] = stk[0]. */ 244 245 #define OP_MOD 0xbb /* push (mod pop[1] pop[2]) */ 246 247 #define OP_MAKE_CLOSURE 0xbc /* push (make-closure pop[1] pop[2]) */ 248 #define OP_UNBINDALL_0 0xbd 249 #define OP_CLOSUREP 0xbe /* push (closurep pop[1]) */ 250 #define OP_POP_ALL 0xbf 251 252 #define OP_FLUID_SET 0xc0 253 #define OP_FLUID_BIND 0xc1 254 255 #define OP_MEMQL 0xc2 /* call-2 memql */ 256 #define OP_NUM_EQ 0xc3 257 #define OP_TEST_SCM 0xc4 258 #define OP_TEST_SCM_F 0xc5 259 #define OP__DEFINE 0xc6 260 #define OP_SPEC_BIND 0xc7 261 #define OP_SET 0xc8 262 263 #define OP_REQUIRED_ARG 0xc9 264 #define OP_OPTIONAL_ARG 0xca 265 #define OP_REST_ARG 0xcb 266 267 #define OP_NOT_ZERO_P 0xcc 268 269 #define OP_KEYWORD_ARG 0xcd 270 #define OP_OPTIONAL_ARG_ 0xce 271 #define OP_KEYWORD_ARG_ 0xcf 272 273 274 /* Jump opcodes */ 275 276 #define OP_LAST_BEFORE_JMPS 0xf7 277 278 #define OP_EJMP 0xf8 /* if (not pop[1]) jmp pc[0,1] 279 else throw_val = arg, 280 goto error-handler */ 281 #define OP_JPN 0xf9 /* if (not stk[0]) pop; jmp pc[0,1] */ 282 #define OP_JPT 0xfa /* if stk[0] pop; jmp pc[0,1] */ 283 #define OP_JMP 0xfb /* jmp pc[0,1] */ 284 #define OP_JN 0xfc /* if (not pop[1]) jmp pc[0,1] */ 285 #define OP_JT 0xfd /* if pop[1] jmp pc[0,1] */ 286 #define OP_JNP 0xfe /* if (not stk[0]) jmp else pop */ 287 #define OP_JTP 0xff /* if stk[0] jmp else pop */ 288 289 #endif /* BYTECODES_H */ 290