plxvm/src/ops.h

52 lines
1.3 KiB
C

#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