-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.h
More file actions
91 lines (70 loc) · 1.87 KB
/
util.h
File metadata and controls
91 lines (70 loc) · 1.87 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
86
87
88
89
90
/*
* util.h
*
* by: Shlomi Gottlieb
* ID: 200505717
*
* by: Adiel Bin Nun
* ID: 319028288
*/
#ifndef UTIL_H_
#define UTIL_H_
/************ Includes **************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
/************ Macros **************/
#define MAX_LABLE_LENGTH 30 /*length of label can be max 30 characters*/
#define FALSE 0
#define TRUE 1
#define SHORT_WORD_LENGTH 13
#define LONG_WORD_LENGTH 15
#define FOREVER for(;;)
#define EXTERN ".extern"
#define ENTRY ".entry"
#define DATA ".data"
#define STRING ".string"
/************ New types **************/
/* Values of special octal signs */
struct {
char *binary; /* the binary code */
char *octal; /* the special octal equivalent */
} specialOctal[] = { { "000", "!" }, { "001", "@" }, { "010", "#" }, { "011",
"$" }, { "100", "%" }, { "101", "^" }, { "110", "&" }, { "111", "*" }, {
NULL, NULL } };
typedef unsigned int boolean;
/* Lines Management */
typedef struct some_line {
int lineNumber; /* The line number */
int address; /* The address of the line - get the IC/DC*/
char *lineStr; /* The string in the line */
boolean isError; /* The line contains error */
char *savedWord; /* the binary word of the line */
} lineInfo;
/* Labels Management */
typedef struct some_label {
char name[MAX_LABLE_LENGTH];
int address;
boolean isExtern;
boolean isEntry;
boolean isCommand;
boolean isData;
} labelInfo;
/********** External variables ************/
extern struct {
char *name;
char *code;
} reg[];
/* Values of commands */
extern struct {
char *name; /* The name */
char *code; /* The code of operand */
short numOfOp; /* The number of operands that the command can handle */
} commands[];
extern int curLabel;
extern labelInfo labelsTable[];
/************ Function declaration **************/
char * isCommand(char*);
char * isRegister(char *);
#endif /* UTIL_H_ */