-
Notifications
You must be signed in to change notification settings - Fork 0
/
njvm.h
91 lines (71 loc) · 1.37 KB
/
njvm.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <stdbool.h>
#include <stdio.h>
#include "include/support.h"
#ifndef __NJVM_H_
#define __NJVM_H_
typedef struct {
bool isObjRef;
union {
ObjRef objRef; /* used if isObjRef=TRUE */
int number; /* used if isObjRef=FALSE */
} u;
} StackSlot;
extern unsigned int pc;
extern ObjRef *stack_G;
extern unsigned int stackS_G;
extern unsigned int ir;
extern bool debug;
extern FILE *f;
extern unsigned int numberOfInstructions;
extern unsigned int version;
extern unsigned int versionBin;
extern char format[4];
extern int *memory;
#define IMMEDIATE(x) ((x) & 0x00FFFFFF)
#define SIGN_EXTEND(i) ((i) & 0x00800000 ? (i) | 0xFF000000 : (i))
#define STACK 0
#define GLOBAL_STACK 1
#define LOCAL_STACK 2
#define HALT 0
#define PUSHC 1
#define ADD 2
#define SUB 3
#define MUL 4
#define DIV 5
#define MOD 6
#define RDINT 7
#define WRINT 8
#define RDCHR 9
#define WRCHR 10
#define PUSHG 11
#define POPG 12
#define ASF 13
#define RSF 14
#define PUSHL 15
#define POPL 16
#define EQ 17
#define NE 18
#define LT 19
#define LE 20
#define GT 21
#define GE 22
#define JMP 23
#define BRF 24
#define BRT 25
#define CALL 26
#define RET 27
#define DROP 28
#define PUSHR 29
#define POPR 30
#define DUP 31
#define NEW 32
#define GETF 33
#define PUTF 34
#define NEWA 35
#define GETFA 36
#define PUTFA 37
#define GETSZ 38
#define PUSHN 39
#define REFEQ 40
#define REFNE 41
#endif