diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-15 20:56:02 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-15 20:59:26 +0100 |
commit | 7a820290f945f94bc38732d989746155883e151a (patch) | |
tree | 3b79072d6d1f6b3f51c0fc62d90125d804ebc1aa /src/inst.h | |
parent | 40dfa5c25584a38566380229b016e8d5e495507e (diff) | |
download | ovm-7a820290f945f94bc38732d989746155883e151a.tar.gz ovm-7a820290f945f94bc38732d989746155883e151a.tar.bz2 ovm-7a820290f945f94bc38732d989746155883e151a.zip |
Make push opcodes a specific bit set and add a NOOP opcode
By default, a zero initialised set of instructions are NOOPs, which is
great.
Last two bits of a push opcode is always 01. Rest of the bits are
used to distinguish between differing types of push. This makes it
easier to inspect on the byte level what type of opcode we have.
Diffstat (limited to 'src/inst.h')
-rw-r--r-- | src/inst.h | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -17,14 +17,20 @@ typedef enum { - OP_PUSH_BYTE = 1, - OP_PUSH_WORD, - OP_PUSH_FLOAT, -} op_t; + OP_NOOP = 0, + + OP_PUSH_BYTE = 0b0001, + OP_PUSH_WORD = 0b0101, + OP_PUSH_FLOAT = 0b1001, + + OP_HALT, +} opcode_t; + +#define OPCODE_IS_PUSH(OPCODE) (((OPCODE)&1) == 1) typedef struct { - op_t opcode; + opcode_t opcode; data_t operand; } inst_t; |