Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 1 | /* |
Gavin Howard | b5904bf | 2018-02-20 13:28:18 -0700 | [diff] [blame] | 2 | * ***************************************************************************** |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 3 | * |
Gavin Howard | b5904bf | 2018-02-20 13:28:18 -0700 | [diff] [blame] | 4 | * Copyright 2018 Gavin D. Howard |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 5 | * |
| 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 Howard | b5904bf | 2018-02-20 13:28:18 -0700 | [diff] [blame] | 17 | * ***************************************************************************** |
Gavin Howard | 5715b04 | 2018-02-12 16:11:42 -0700 | [diff] [blame] | 18 | * |
| 19 | * Definitions of bc instructions. |
| 20 | * |
| 21 | */ |
| 22 | |
Gavin Howard | 5a8949e | 2018-02-05 16:46:06 -0700 | [diff] [blame] | 23 | #ifndef BC_INSTRUCTIONS_H |
| 24 | #define BC_INSTRUCTIONS_H |
| 25 | |
| 26 | #include <stdint.h> |
| 27 | |
| 28 | #define BC_INST_CALL ((uint8_t) 'C') |
Gavin Howard | d96bcae | 2018-02-07 19:16:19 -0700 | [diff] [blame] | 29 | #define BC_INST_RETURN ((uint8_t) 'R') |
| 30 | #define BC_INST_RETURN_ZERO ((uint8_t) '$') |
| 31 | |
Gavin Howard | e46c682 | 2018-02-08 20:05:39 -0700 | [diff] [blame] | 32 | #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 Howard | d96bcae | 2018-02-07 19:16:19 -0700 | [diff] [blame] | 41 | #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 Howard | e46c682 | 2018-02-08 20:05:39 -0700 | [diff] [blame] | 46 | #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 Howard | d96bcae | 2018-02-07 19:16:19 -0700 | [diff] [blame] | 50 | #define BC_INST_PUSH_NUM ((uint8_t) 'N') |
Gavin Howard | 5c222e3 | 2018-02-28 13:06:41 -0700 | [diff] [blame] | 51 | #define BC_INST_POP ((uint8_t) 'P') |
Gavin Howard | e093617 | 2018-02-26 17:44:37 -0700 | [diff] [blame] | 52 | #define BC_INST_INC_DUP ((uint8_t) 'E') |
| 53 | #define BC_INST_DEC_DUP ((uint8_t) 'D') |
Gavin Howard | e46c682 | 2018-02-08 20:05:39 -0700 | [diff] [blame] | 54 | |
Gavin Howard | e093617 | 2018-02-26 17:44:37 -0700 | [diff] [blame] | 55 | #define BC_INST_INC ((uint8_t) 'e') |
Gavin Howard | e46c682 | 2018-02-08 20:05:39 -0700 | [diff] [blame] | 56 | #define BC_INST_DEC ((uint8_t) 'd') |
Gavin Howard | d96bcae | 2018-02-07 19:16:19 -0700 | [diff] [blame] | 57 | |
| 58 | #define BC_INST_HALT ((uint8_t) 'H') |
| 59 | |
Gavin Howard | 5c222e3 | 2018-02-28 13:06:41 -0700 | [diff] [blame] | 60 | #define BC_INST_PRINT ((uint8_t) 'p') |
Gavin Howard | 152f3e8 | 2018-03-07 12:33:15 -0700 | [diff] [blame^] | 61 | #define BC_INST_PRINT_EXPR ((uint8_t) 'Q') |
Gavin Howard | 5c222e3 | 2018-02-28 13:06:41 -0700 | [diff] [blame] | 62 | #define BC_INST_STR ((uint8_t) 's') |
| 63 | #define BC_INST_PRINT_STR ((uint8_t) 'S') |
Gavin Howard | 5a8949e | 2018-02-05 16:46:06 -0700 | [diff] [blame] | 64 | |
Gavin Howard | e46c682 | 2018-02-08 20:05:39 -0700 | [diff] [blame] | 65 | #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 Howard | 869ee06 | 2018-02-15 16:30:54 -0700 | [diff] [blame] | 75 | #define BC_INST_OP_REL_NOT_EQ ((uint8_t) '~') |
Gavin Howard | e46c682 | 2018-02-08 20:05:39 -0700 | [diff] [blame] | 76 | #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 Howard | 869ee06 | 2018-02-15 16:30:54 -0700 | [diff] [blame] | 89 | #define BC_INST_OP_ASSIGN_MODULUS ((uint8_t) '@') |
Gavin Howard | e46c682 | 2018-02-08 20:05:39 -0700 | [diff] [blame] | 90 | #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 Howard | 5a8949e | 2018-02-05 16:46:06 -0700 | [diff] [blame] | 94 | #endif // BC_INSTRUCTIONS_H |