aboutsummaryrefslogtreecommitdiff
path: root/vm.h
blob: c01a914abddb99ca5d36b513910aea2f4904260f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// synacor challenge ([email protected])
#include "memory.h"
#include "stack.h"
#include "util.h"

extern Stack s;
extern Memory m;

int parse(char const *filename);
int operate(u16 opcode, u8 *buffer);

int is_valid(u16 opcode);
int is_literal(u16 opcode);
int is_register(u16 opcode);
u16 *get_register(u16 opcode);
instruction_ptr get_instruction(u16 opcode);

int instruction_halt(u8 *buffer);
int instruction_set(u8 *buffer);
int instruction_push(u8 *buffer);
int instruction_pop(u8 *buffer);
int instruction_eq(u8 *buffer);
int instruction_gt(u8 *buffer);
int instruction_jmp(u8 *buffer);
int instruction_jt(u8 *buffer);
int instruction_jf(u8 *buffer);
int instruction_add(u8 *buffer);
int instruction_mult(u8 *buffer);
int instruction_mod(u8 *buffer);
int instruction_and(u8 *buffer);
int instruction_or(u8 *buffer);
int instruction_not(u8 *buffer);
int instruction_rmem(u8 *buffer);
int instruction_wmem(u8 *buffer);
int instruction_call(u8 *buffer);
int instruction_ret(u8 *buffer);
int instruction_out(u8 *buffer);
int instruction_in(u8 *buffer);
int instruction_noop(u8 *buffer);