-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assembler.h
112 lines (58 loc) · 1.88 KB
/
Assembler.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef main_h
#define main_h
/*-------------------------------------------Defining Structs----------------------------------------------*/
typedef struct
{
void * order;
unsigned int type_order: 2;
}Instruction;
typedef struct
{
unsigned int type_coding: 2;
unsigned int dest_addressing: 2;
unsigned int origin_addressing: 2;
unsigned int opcode: 4;
}InstructOrder;
typedef struct
{
char value;
unsigned int type_coding: 2;
}InstructData;
typedef struct
{
unsigned int reg1: 4;
unsigned int reg2: 4;
}InstructRegisters;
typedef enum {MOV,CMP,ADD,SUB,NOT,CLR,LEA,INC,DEC,JMP,BNE,RED,PRN,JSR,RTS,STOP,DATA,STRING,MAT,ENTRY,EXTERN}func;
typedef struct
{
char * label_name;
unsigned dec_value;
func type; /*boolean variable: data order or instruction order*/
}Symbol;
typedef struct
{
char * label_name;
unsigned addr;
}ExternSy;
typedef struct
{
unsigned index;
func type;
}EntrySy;
void insertNewError(char * error);
void allocate_check(void * p);
void freeLinkedList(char ** list);
/*-------------------------------------------Defining Global Variables-------------------------------------------*/
ExternSy ** ExtSymbolsTable; /*table that save all the indexes of the externs labels*/
Symbol ** symbol_table; /*The symbols table*/
int * data_table; /*Int dynamic array to store all the data instructions*/
Instruction ** instructions_table; /* for data and instruction order*/
unsigned IC; /*Instruction table counter*/
unsigned SC; /*Symbol counter*/
unsigned EC; /*Error counter*/
unsigned LC; /*Line counter*/
unsigned DC; /*Data table counter*/
unsigned Total_IC; /*total of Instructions after the first iteration*/
unsigned SymbolExtCount;
#endif /* main_h */