Files
ants/farm/program.h
2026-03-26 18:43:01 +01:00

71 lines
2.5 KiB
C

#define INS_NOOP 0
#define INS_ID 1
#define INS_TAG 2
#define INS_MOVE 3
#define INS_SENSE 4
#define INS_PROBE 5
#define INS_PICKUP 6
#define INS_CARRYING 7
#define INS_DROP 8
#define INS_SMELL 9
#define INS_SNIFF 0xa
#define INS_MARK 0xb
#define INS_SET 0x10
#define INS_AND 0x11
#define INS_OR 0x12
#define INS_XOR 0x13
#define INS_LSHIFT 0x14
#define INS_RSHIFT 0x15
#define INS_ADD 0x16
#define INS_SUB 0x17
#define INS_MUL 0x18
#define INS_DIV 0x19
#define INS_MOD 0x1a
#define INS_RANDOM 0x1b
#define INS_SJR 0x20
#define INS_MJR 0x21
#define INS_JMP 0x22
#define INS_CALL 0x23
#define INS_JEQ 0x24
#define INS_JNE 0x25
#define INS_JGT 0x26
#define INS_JLT 0x27
static char* instruction_names[256] = {
/* 0x00 */ "NOOP", "ID ", "TAG ", "MOVE", "SENS", "PROB", "PICK", "CARY", "DROP", "SMEL", "SNIF", "MARK", "?", "?", "?", "?",
/* 0x10 */ "SET ", "AND ", "OR ", "XOR ", "SHL ", "SHR ", "ADD ", "SUB ", "MUL ", "DIV ", "MOD", "RAND", "?", "?", "?", "?",
/* 0x20 */ "SJR ", "MJR ", "JMP ", "CALL", "JEQ", "JNE ", "JGT ", "JLT ", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0x30 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0x40 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0x50 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0x60 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0x70 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0x80 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0x90 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0xa0 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0xb0 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0xc0 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0xd0 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0xe0 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
/* 0xf0 */ "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?", "?",
};
struct Instruction {
unsigned char op;
unsigned char arg1;
unsigned char arg2;
unsigned char arg3;
};
struct Program {
unsigned int num_instructions;
struct Instruction instructions;
};
struct Program* load_program(char* filename);