From 62fcfd66be73925a21c86696a2238cab1d2d5df2 Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 16 Mar 2026 11:10:23 +0100 Subject: [PATCH] Mon 16 Mar 11:09:06 CET 2026 --- src/ops.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/ops.h diff --git a/src/ops.h b/src/ops.h new file mode 100644 index 0000000..7947000 --- /dev/null +++ b/src/ops.h @@ -0,0 +1,51 @@ +#ifndef _OPS_H +#define _OPS_H +/* + XP-Code Operations + + [command][[arguments]] +*/ +typedef enum { + ADD=1, DIV, MUL, SUB, NEG, MOD, + AND, OR, NOT, + EQ, NEQ, LT, GT, LE, GE, CMPS, + DROPD, DROPF, + PUSHD, PUSHF, NTHD, NTHF, TOF, SETF, SETSP, INCSP, + INCHAR, INNUMBER, INSTRING, INARRAY, + OUTCHAR, OUTNUMBER, OUTSTRING, OUTARRAY, + STRING, + JMP, JZ, JNZ, TESTRANGE, LOOP, + READ, WRITE, READS, WRITES, DATA, EVENT, ERR, EMIT, + INTERRUPT, RESUME, CALL, CCALL, PROC, FUNC, RETURN, FORK, YIELD, +#if HAS_LOCK > 0 + LOCK, UNLOCK, +#endif + END, ENV +} ops_t; + +/* + Variable XP operand sizes +*/ +extern const index_t ops_s[]; + +typedef unsigned char opcmd_t; // code only + +typedef struct { + index_t length; // real length in bytes + char data; // first character, dynamic memory +} string_t; + +typedef struct __attribute__((packed)) { + opcmd_t command ; + union { + index_t ix ; + address_t ax ; + number_t nx ; + string_t sx ; + }; +} op_t; + +#define OPT(M,addr) ((op_t*)&M->data[addr]) + +#endif +