Initial revision
[LeanCalc.git] / calc / calc / opcodes.h
1 /*
2  * opcodes - opcode execution module definition
3  *
4  * Copyright (C) 1999  David I. Bell
5  *
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.
9  *
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.
14  *
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  * 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * @(#) $Revision$
21  * @(#) $Id$
22  * @(#) $Source$
23  *
24  * Under source code control:   1990/02/15 01:48:35
25  * File existed as early as:    before 1990
26  *
27  * Share and enjoy!  :-)        http://www.isthe.com/chongo/tech/comp/calc/
28  */
29
30
31 #if !defined(__OPCODES_H__)
32 #define __OPCODES_H__
33
34
35 #if defined(CALC_SRC)   /* if we are building from the calc source tree */
36 # include "calc/win32dll.h"
37 #else
38 # include <calc/win32dll.h>
39 #endif
40
41
42 /*
43  * Opcodes
44  */
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_QUOMOD       97L     /* calculate quotient and remainder */
143 #define OP_SETCONFIG    98L     /* set configuration parameter */
144 #define OP_SETEPSILON   99L     /* set allowed error for calculations */
145 #define OP_ISFILE       100L    /* whether value is a file */
146 #define OP_ISASSOC      101L    /* whether value is an association */
147 #define OP_INITSTATIC   102L    /* once only code for static initialization */
148 #define OP_ELEMINIT     103L    /* assign element of matrix or object */
149 #define OP_ISCONFIG     104L    /* whether value is a configuration state */
150 #define OP_ISHASH       105L    /* whether value is a hash state */
151 #define OP_ISRAND       106L    /* whether value is additive 55 random state */
152 #define OP_ISRANDOM     107L    /* whether value is a Blum random state */
153 #define OP_SHOW         108L    /* show data about current state */
154 #define OP_INITFILL     109L    /* fill new matrix with copies of a value */
155 #define OP_ASSIGNBACK   110L    /* assign in reverse order */
156 #define OP_TEST         111L    /* test whether value is "nonzero" */
157 #define OP_ISDEFINED    112L    /* whether string names a function */
158 #define OP_ISOBJTYPE    113L    /* whether string names an object type */
159 #define OP_ISBLK        114L    /* whether value is a block */
160 #define OP_PTR          115L    /* octet pointer */
161 #define OP_DEREF        116L    /* dereference an octet pointer */
162 #define OP_ISOCTET      117L    /* whether value is an octet */
163 #define OP_ISPTR        118L    /* whether value is a pointer */
164 #define OP_SAVEVAL      119L    /* activate updating */
165 #define OP_LINKS        120L    /* return links for numbers and strings */
166 #define OP_BIT          121L    /* whether specified bit is set */
167 #define OP_COMP         122L    /* complement value */
168 #define OP_XOR          123L    /* xor (~) of values */
169 #define OP_HIGHBIT      124L    /* index of high bit of value */
170 #define OP_LOWBIT       125L    /* index of low bit of value */
171 #define OP_CONTENT      126L    /* value returned by unary # */
172 #define OP_HASHOP       127L    /* binary # */
173 #define OP_BACKSLASH    128L    /* unary backslash */
174 #define OP_SETMINUS     129L    /* binary backslash */
175 #define OP_PLUS         130L    /* unary + */
176 #define OP_JUMPNN       131L    /* jump if top value is non-null */
177 #define OP_ABORT        132L    /* abort operation */
178 #define MAX_OPCODE      132L    /* highest legal opcode */
179
180
181 /*
182  * external declarations
183  */
184 extern DLL char *funcname;              /* function being executed */
185 extern DLL long funcline;               /* function line being executed */
186
187
188 #endif /* !__OPCODES_H__ */