-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
99 lines (81 loc) · 1.6 KB
/
utils.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
/* ------------------------------------- */
/* Yoav Levy */
/* */
/* 2023 Semester A */
/* ------------------------------------- */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
/* Defining constants */
#define LINE_LENGTH 82
#define LABEL_LENGTH 30
#define WORD_SIZE 14
#define MEMORY_SIZE 256
#define MEMORY_LOAD_START 100
#define NUM_OF_COMMANDS_FIRST_GROUP 5
#define NUM_OF_COMMANDS_SECOND_GROUP 9
#define NUM_OF_COMMANDS_THIRD_GROUP 2
#define NUM_OF_JWP 3
#define NUM_OF_COMMANDS 16
#define NUM_OF_REG 8
#define NUM_OF_DATA_DIRECTIVES 2
#define NUM_OF_LABEL_DIRECTIVES 2
/* Defining the boolean type: */
typedef enum
{
FALSE,
TRUE
} boolean;
/* Defining the isFail type: */
typedef enum
{
SUCCESS,
FAIL
} isFail;
#define NO_REG -1
/* This enum contains all the commands: */
typedef enum
{
Mov = 1,
Cmp,
Add,
Sub,
Not,
Clr,
Lea,
Inc,
Dec,
Jmp,
Bne,
Red,
Prn,
Jsr,
Rts,
Stop
} commandName;
/* This enum contains all the commands groups: */
typedef enum
{
TwoArg = 1,
OneArg,
ZeroArg
} commandGroup;
/* This enum contains all the adressing systems types: */
typedef enum
{
Immediate = 0,
Label,
JumpWithParam,
Register,
NoOperand
} adressingSystem;
/* Help functions: */
boolean endOfLine(char *line);
char *skipSpaces(char *ch);
char *skipNotSpaces(char *ch);
char *skipUntilSign(char *ch, char sign);
void copyUntilSign(char *line, char *to, char sign);
int ignoreLine(char *line);
void copyNextWord(char *line, char *to);
void copyNextOperandName(char *line, char *to);