-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.h
53 lines (40 loc) · 1.52 KB
/
parser.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
#include "symbols.h"
#include "assembler.h"
#ifndef PARSER_H_
#define PARSER_H_
#define NOT_REGISTER_OPERAND "000"
typedef struct
{
char *symbol;
char *command;
char *sourceOperand;
char *destinationOperand;
char *externSymbol;
char *entrySymbol;
char *data;
} CommandParts;
StatementType getStatementType(char *line);
CommandParts parseAssemblyLine(char *line);
/* Returns the integer value of the addressing mode for the given operand*/
/* The function assumes a valid operand */
int parseAddressingMode(char *operand);
const char *parseOperand(char *operand);
const char *parseCommand(char *command);
char *extractFirstGuidanceData(char *data);
/*Extracts the next number string in the data string that was initialized in the extractFirstGuidanceData method. */
/*Returns NULL if there are no more values to return */
char *extractNextGuidanceData();
char *extractGuidanceData(char *line);
char *extractGuidanceString(char *line);
char *extractImmediateAddressingModeValue(char *operand);
/*Extracts the symbol part from a valid index addressing operand */
char *extractIndexAddressingSymbol(char *operand);
/*Extracts the offset part from a valid index addressing operand */
char *extractIndexAddressingOffset(char *operand);
char *extractIndex2dAddressingSymbol(char *operand);
char *extractIndex2dAddressingOffset(char *operand);
char *extractIndex2dAddressingRegister(char *operand);
int isSymbolGuidanceCommand(char *line);
/*Returns a base 2 assembly word of the given base 10 value*/
char *convertBase10toBase2(int base10);
#endif