-
Notifications
You must be signed in to change notification settings - Fork 0
/
pseudo_code.c
60 lines (53 loc) · 1 KB
/
pseudo_code.c
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
#include "pseudo_code.h"
char *MNEMONIQUESNAMES[21] = {
"NOP",
"ADD", "SUB",
"MUL", "DIV",
"EQL", "NEQ",
"GTR", "LSS",
"GEQ", "LEQ",
"LDA", "LDI",
"PRN", "INT",
"HLT", "INN",
"STO", "LDV",
"BZE", "BRN"
};
void init_pseudo_code(){
PC = -1;
offset = -1;
PH = -1;
adresse_offset = 0;
PCode[0].mne = NOP;
}
void generer(MNEMONIQUES M)
{
PC = PC + 1;
PCode[PC].mne = M;
}
void generer_val(MNEMONIQUES M, int val)
{
PC = PC + 1;
PCode[PC].mne = M;
PCode[PC].suite = val;
}
void PH_generer(MNEMONIQUES M)
{
PH = PH + 1;
PileHisto[PH].mne = M;
}
void PH_generer_val(MNEMONIQUES M, int val)
{
PH = PH + 1;
PileHisto[PH].mne = M;
PileHisto[PH].suite = val;
}
instruction SommetPileHisto()
{
if (PH == -1)
{
printf("ERREUR PILE VIDE");
EXIT_FAILURE;
}
PH--;
return PileHisto[PH + 1];
}