blob: 73f02c3115c53a1d066cd151d7ef8b9659d4bc5c [file] [log] [blame]
Gavin Howard5715b042018-02-12 16:11:42 -07001/*
Gavin Howardb5904bf2018-02-20 13:28:18 -07002 * *****************************************************************************
Gavin Howard5715b042018-02-12 16:11:42 -07003 *
Gavin Howardb5904bf2018-02-20 13:28:18 -07004 * Copyright 2018 Gavin D. Howard
Gavin Howard5715b042018-02-12 16:11:42 -07005 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
16 *
Gavin Howardb5904bf2018-02-20 13:28:18 -070017 * *****************************************************************************
Gavin Howard5715b042018-02-12 16:11:42 -070018 *
19 * Definitions of bc instructions.
20 *
21 */
22
Gavin Howard5a8949e2018-02-05 16:46:06 -070023#ifndef BC_INSTRUCTIONS_H
24#define BC_INSTRUCTIONS_H
25
26#include <stdint.h>
27
28#define BC_INST_CALL ((uint8_t) 'C')
Gavin Howardd96bcae2018-02-07 19:16:19 -070029#define BC_INST_RETURN ((uint8_t) 'R')
30#define BC_INST_RETURN_ZERO ((uint8_t) '$')
31
Gavin Howarde46c6822018-02-08 20:05:39 -070032#define BC_INST_READ ((uint8_t) 'r')
33
34#define BC_INST_JUMP ((uint8_t) 'J')
35#define BC_INST_JUMP_NOT_ZERO ((uint8_t) 'n')
36#define BC_INST_JUMP_ZERO ((uint8_t) 'z')
37
38#define BC_INST_PUSH_VAR ((uint8_t) 'V')
39#define BC_INST_PUSH_ARRAY ((uint8_t) 'A')
40
Gavin Howardd96bcae2018-02-07 19:16:19 -070041#define BC_INST_PUSH_LAST ((uint8_t) 'L')
42#define BC_INST_PUSH_SCALE ((uint8_t) '.')
43#define BC_INST_PUSH_IBASE ((uint8_t) 'I')
44#define BC_INST_PUSH_OBASE ((uint8_t) 'O')
45
Gavin Howarde46c6822018-02-08 20:05:39 -070046#define BC_INST_SCALE_FUNC ((uint8_t) 'a')
47#define BC_INST_LENGTH ((uint8_t) 'l')
48#define BC_INST_SQRT ((uint8_t) 'q')
49
Gavin Howardd96bcae2018-02-07 19:16:19 -070050#define BC_INST_PUSH_NUM ((uint8_t) 'N')
Gavin Howard5c222e32018-02-28 13:06:41 -070051#define BC_INST_POP ((uint8_t) 'P')
Gavin Howarde0936172018-02-26 17:44:37 -070052#define BC_INST_INC_DUP ((uint8_t) 'E')
53#define BC_INST_DEC_DUP ((uint8_t) 'D')
Gavin Howarde46c6822018-02-08 20:05:39 -070054
Gavin Howarde0936172018-02-26 17:44:37 -070055#define BC_INST_INC ((uint8_t) 'e')
Gavin Howarde46c6822018-02-08 20:05:39 -070056#define BC_INST_DEC ((uint8_t) 'd')
Gavin Howardd96bcae2018-02-07 19:16:19 -070057
58#define BC_INST_HALT ((uint8_t) 'H')
59
Gavin Howard5c222e32018-02-28 13:06:41 -070060#define BC_INST_PRINT ((uint8_t) 'p')
Gavin Howard152f3e82018-03-07 12:33:15 -070061#define BC_INST_PRINT_EXPR ((uint8_t) 'Q')
Gavin Howard5c222e32018-02-28 13:06:41 -070062#define BC_INST_STR ((uint8_t) 's')
63#define BC_INST_PRINT_STR ((uint8_t) 'S')
Gavin Howard5a8949e2018-02-05 16:46:06 -070064
Gavin Howarde46c6822018-02-08 20:05:39 -070065#define BC_INST_OP_POWER ((uint8_t) '^')
66#define BC_INST_OP_MULTIPLY ((uint8_t) '*')
67#define BC_INST_OP_DIVIDE ((uint8_t) '/')
68#define BC_INST_OP_MODULUS ((uint8_t) '%')
69#define BC_INST_OP_PLUS ((uint8_t) '+')
70#define BC_INST_OP_MINUS ((uint8_t) '-')
71
72#define BC_INST_OP_REL_EQUAL ((uint8_t) '=')
73#define BC_INST_OP_REL_LESS_EQ ((uint8_t) ';')
74#define BC_INST_OP_REL_GREATER_EQ ((uint8_t) '?')
Gavin Howard869ee062018-02-15 16:30:54 -070075#define BC_INST_OP_REL_NOT_EQ ((uint8_t) '~')
Gavin Howarde46c6822018-02-08 20:05:39 -070076#define BC_INST_OP_REL_LESS ((uint8_t) '<')
77#define BC_INST_OP_REL_GREATER ((uint8_t) '>')
78
79#define BC_INST_OP_BOOL_NOT ((uint8_t) '!')
80
81#define BC_INST_OP_BOOL_OR ((uint8_t) '|')
82#define BC_INST_OP_BOOL_AND ((uint8_t) '&')
83
84#define BC_INST_OP_NEGATE ((uint8_t) '_')
85
86#define BC_INST_OP_ASSIGN_POWER ((uint8_t) '`')
87#define BC_INST_OP_ASSIGN_MULTIPLY ((uint8_t) '{')
88#define BC_INST_OP_ASSIGN_DIVIDE ((uint8_t) '}')
Gavin Howard869ee062018-02-15 16:30:54 -070089#define BC_INST_OP_ASSIGN_MODULUS ((uint8_t) '@')
Gavin Howarde46c6822018-02-08 20:05:39 -070090#define BC_INST_OP_ASSIGN_PLUS ((uint8_t) '[')
91#define BC_INST_OP_ASSIGN_MINUS ((uint8_t) ']')
92#define BC_INST_OP_ASSIGN ((uint8_t) ',')
93
Gavin Howard5a8949e2018-02-05 16:46:06 -070094#endif // BC_INSTRUCTIONS_H