-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathopcode.h
More file actions
85 lines (78 loc) · 2.1 KB
/
opcode.h
File metadata and controls
85 lines (78 loc) · 2.1 KB
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
/* ***************************************************************************
* This file is part of virtual_mlv.
*
* virtual_mlv is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* virtual_mlv is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with virtual_mlv. If not, see
* <http://www.gnu.org/licenses/>.
*
*
* Authors: S. Lombardy, N. Bedon, C. Morvan, W. Hay, Q. Campos, J. Mangue,
* C. Noël.
*
*************************************************************************** */
#ifndef OPCODE_H
#define OPCODE_H
#include <limits.h>
/**
* Opcodes are now first-class type rather than macros.
*/
typedef enum Opcode {
/* Without argument. */
VM_NOP,
VM_NEG,
VM_ADD,
VM_SUB,
VM_MUL,
VM_DIV,
VM_MOD,
VM_EQUAL,
VM_NOTEQ,
VM_LESS,
VM_LEQ,
VM_GREATER,
VM_GEQ,
VM_PUSH,
VM_POP,
VM_SWAP,
VM_READ,
VM_WRITE,
VM_HALT,
VM_RETURN,
VM_LOAD,
VM_LOADR,
VM_SAVE,
VM_SAVER,
VM_READCH,
VM_WRITECH,
VM_TOPST,
VM_BASER,
/* With one argument. */
VM_SET,
VM_JUMP,
VM_JUMPF,
VM_LABEL,
VM_CALL,
VM_ALLOC,
VM_FREE,
/*
* The sole purpose of the following opcode is to maintain backward
* compatibility with old code. Former opcodes were defined using macros
* which expanded to an `int'. Our new opcode enum starts by 0 and the
* absence of negative value could have lead the compiler to choose an
* unsigned integral type and/or another integral with a smaller width.
*/
__VM_RESERVED = INT_MIN
} Opcode;
const char *opcode_to_string(Opcode);
void print_code_segment(const int *, int);
#endif /* OPCODE_H */