2 * opcodes - opcode execution module definition
4 * Copyright (C) 1999-2007 David I. Bell
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.1 $
21 * @(#) $Id: opcodes.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/RCS/opcodes.h,v $
24 * Under source code control: 1990/02/15 01:48:35
25 * File existed as early as: before 1990
27 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
31 #if !defined(__OPCODES_H__)
35 #if defined(CALC_SRC) /* if we are building from the calc source tree */
38 # include <calc/decl.h>
45 #define OP_NOP 0L /* no operation */
46 #define OP_LOCALADDR 1L /* load address of local variable */
47 #define OP_GLOBALADDR 2L /* load address of global variable */
48 #define OP_PARAMADDR 3L /* load address of paramater variable */
49 #define OP_LOCALVALUE 4L /* load value of local variable */
50 #define OP_GLOBALVALUE 5L /* load value of global variable */
51 #define OP_PARAMVALUE 6L /* load value of paramater variable */
52 #define OP_NUMBER 7L /* load constant real numeric value */
53 #define OP_INDEXADDR 8L /* load array index address */
54 #define OP_PRINTRESULT 9L /* print result of top-level expression */
55 #define OP_ASSIGN 10L /* assign value to variable */
56 #define OP_ADD 11L /* add top two values */
57 #define OP_SUB 12L /* subtract top two values */
58 #define OP_MUL 13L /* multiply top two values */
59 #define OP_DIV 14L /* divide top two values */
60 #define OP_MOD 15L /* take mod of top two values */
61 #define OP_SAVE 16L /* save value for later use */
62 #define OP_NEGATE 17L /* negate top value */
63 #define OP_INVERT 18L /* invert top value */
64 #define OP_INT 19L /* take integer part of top value */
65 #define OP_FRAC 20L /* take fraction part of top value */
66 #define OP_NUMERATOR 21L /* take numerator of top value */
67 #define OP_DENOMINATOR 22L /* take denominator of top value */
68 #define OP_DUPLICATE 23L /* duplicate top value on stack */
69 #define OP_POP 24L /* pop top value from stack */
70 #define OP_RETURN 25L /* return value of function */
71 #define OP_JUMPZ 26L /* jump if top value is zero */
72 #define OP_JUMPNZ 27L /* jump if top value is nonzero */
73 #define OP_JUMP 28L /* jump unconditionally */
74 #define OP_USERCALL 29L /* call a user-defined function */
75 #define OP_GETVALUE 30L /* convert address to value */
76 #define OP_EQ 31L /* test top two elements for equality */
77 #define OP_NE 32L /* test top two elements for inequality */
78 #define OP_LE 33L /* test top two elements for <= */
79 #define OP_GE 34L /* test top two elements for >= */
80 #define OP_LT 35L /* test top two elements for < */
81 #define OP_GT 36L /* test top two elements for > */
82 #define OP_PREINC 37L /* add one to variable (++x) */
83 #define OP_PREDEC 38L /* subtract one from variable (--x) */
84 #define OP_POSTINC 39L /* add one to variable (x++) */
85 #define OP_POSTDEC 40L /* subtract one from variable (x--) */
86 #define OP_DEBUG 41L /* debugging point */
87 #define OP_PRINT 42L /* print value */
88 #define OP_ASSIGNPOP 43L /* assign to variable and remove it */
89 #define OP_ZERO 44L /* put zero on the stack */
90 #define OP_ONE 45L /* put one on the stack */
91 #define OP_PRINTEOL 46L /* print end of line */
92 #define OP_PRINTSPACE 47L /* print a space */
93 #define OP_PRINTSTRING 48L /* print constant string */
94 #define OP_DUPVALUE 49L /* duplicate value of top value */
95 #define OP_OLDVALUE 50L /* old calculation value */
96 #define OP_QUO 51L /* integer quotient of top two values */
97 #define OP_POWER 52L /* number raised to a power */
98 #define OP_QUIT 53L /* quit program */
99 #define OP_CALL 54L /* call built-in routine */
100 #define OP_GETEPSILON 55L /* get allowed error for calculations */
101 #define OP_AND 56L /* arithmetic and */
102 #define OP_OR 57L /* arithmetic or */
103 #define OP_NOT 58L /* logical not */
104 #define OP_ABS 59L /* absolute value */
105 #define OP_SGN 60L /* sign of number */
106 #define OP_ISINT 61L /* whether top value is integer */
107 #define OP_CONDORJUMP 62L /* conditional or jump */
108 #define OP_CONDANDJUMP 63L /* conditional and jump */
109 #define OP_SQUARE 64L /* square top value */
110 #define OP_STRING 65L /* load constant string value */
111 #define OP_ISNUM 66L /* whether top value is a number */
112 #define OP_UNDEF 67L /* load undefined value on stack */
113 #define OP_ISNULL 68L /* whether variable is the null value */
114 #define OP_ARGVALUE 69L /* load value of argument (parameter) n */
115 #define OP_MATCREATE 70L /* create matrix */
116 #define OP_ISMAT 71L /* whether variable is a matrix */
117 #define OP_ISSTR 72L /* whether variable is a string */
118 #define OP_GETCONFIG 73L /* get value of configuration parameter */
119 #define OP_LEFTSHIFT 74L /* left shift of integer */
120 #define OP_RIGHTSHIFT 75L /* right shift of integer */
121 #define OP_CASEJUMP 76L /* test case and jump if not matched */
122 #define OP_ISODD 77L /* whether value is an odd integer */
123 #define OP_ISEVEN 78L /* whether value is even integer */
124 #define OP_FIADDR 79L /* 'fast index' matrix value address */
125 #define OP_FIVALUE 80L /* 'fast index' matrix value */
126 #define OP_ISREAL 81L /* test value for real number */
127 #define OP_IMAGINARY 82L /* load imaginary numeric constant */
128 #define OP_RE 83L /* real part of complex number */
129 #define OP_IM 84L /* imaginary part of complex number */
130 #define OP_CONJUGATE 85L /* complex conjugate of complex number */
131 #define OP_OBJCREATE 86L /* create object */
132 #define OP_ISOBJ 87L /* whether value is an object */
133 #define OP_NORM 88L /* norm of value (square of abs) */
134 #define OP_ELEMADDR 89L /* address of element of object */
135 #define OP_ELEMVALUE 90L /* value of element of object */
136 #define OP_ISTYPE 91L /* whether two values are the same type */
137 #define OP_SCALE 92L /* scale value by a power of two */
138 #define OP_ISLIST 93L /* whether value is a list */
139 #define OP_SWAP 94L /* swap values of two variables */
140 #define OP_ISSIMPLE 95L /* whether value is a simple type */
141 #define OP_CMP 96L /* compare values returning -1, 0, or 1 */
142 #define OP_SETCONFIG 97L /* set configuration parameter */
143 #define OP_SETEPSILON 98L /* set allowed error for calculations */
144 #define OP_ISFILE 99L /* whether value is a file */
145 #define OP_ISASSOC 100L /* whether value is an association */
146 #define OP_INITSTATIC 101L /* once only code for static initialization */
147 #define OP_ELEMINIT 102L /* assign element of matrix or object */
148 #define OP_ISCONFIG 103L /* whether value is a configuration state */
149 #define OP_ISHASH 104L /* whether value is a hash state */
150 #define OP_ISRAND 105L /* whether value is additive 55 random state */
151 #define OP_ISRANDOM 106L /* whether value is a Blum random state */
152 #define OP_SHOW 107L /* show data about current state */
153 #define OP_INITFILL 108L /* fill new matrix with copies of a value */
154 #define OP_ASSIGNBACK 109L /* assign in reverse order */
155 #define OP_TEST 110L /* test whether value is "nonzero" */
156 #define OP_ISDEFINED 111L /* whether string names a function */
157 #define OP_ISOBJTYPE 112L /* whether string names an object type */
158 #define OP_ISBLK 113L /* whether value is a block */
159 #define OP_PTR 114L /* octet pointer */
160 #define OP_DEREF 115L /* dereference an octet pointer */
161 #define OP_ISOCTET 116L /* whether value is an octet */
162 #define OP_ISPTR 117L /* whether value is a pointer */
163 #define OP_SAVEVAL 118L /* activate updating */
164 #define OP_LINKS 119L /* return links for numbers and strings */
165 #define OP_BIT 120L /* whether specified bit is set */
166 #define OP_COMP 121L /* complement value */
167 #define OP_XOR 122L /* xor (~) of values */
168 #define OP_HIGHBIT 123L /* index of high bit of value */
169 #define OP_LOWBIT 124L /* index of low bit of value */
170 #define OP_CONTENT 125L /* value returned by unary # */
171 #define OP_HASHOP 126L /* binary # */
172 #define OP_BACKSLASH 127L /* unary backslash */
173 #define OP_SETMINUS 128L /* binary backslash */
174 #define OP_PLUS 129L /* unary + */
175 #define OP_JUMPNN 130L /* jump if top value is non-null */
176 #define OP_ABORT 131L /* abort operation */
177 #define MAX_OPCODE 131L /* highest legal opcode */
181 * external declarations
183 EXTERN
char *funcname
; /* function being executed */
184 EXTERN
long funcline
; /* function line being executed */
187 #endif /* !__OPCODES_H__ */