-
Notifications
You must be signed in to change notification settings - Fork 0
/
shared_fp_sp.h
72 lines (60 loc) · 1.97 KB
/
shared_fp_sp.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
#ifndef _SHARED_FP_SP_H
#define _SHARED_FP_SP_H
#include "shared.h"
#define _DATA 16
#define _STRING 17
#define _ENTRY 18
#define _EXTERN 19
#define ABSOLUTE "00"
#define RELOCATABLE "10"
/*12 - which is the size of word +1 terminator*/
#define SIZE_OF_WORD 13
typedef struct label{
char labelName[MAX_LABEL_MACRO_LENGTH];
int line;
int address;
int isInstruction;
} label;
typedef struct extentlabel{
char labelName[MAX_LABEL_MACRO_LENGTH];
struct{
int* addr;
int count;
} address;
int type;
int line;
struct extentlabel* next;
} extentlabel;
typedef struct maplabel{
int icAddress;
int lineNum;
struct maplabel* next;
} maplabel;
/**
* This function searches the label table for a label with a given name and returns its entry.
*
* @param labelTable Pointer to the label table array.
* @param labelName The name of the label to be found.
* @param labelCount The number of labels in the table.
* @return The pointer to the label entry, or NULL if not found.
*/
label* find_label(label *labelTable, char *labelName, int labelCount);
/**
* This function searches the extent label list for a label with a given name and returns its node.
*
* @param head Pointer to the head of the extent label list.
* @param labelName The name of the label to be found.
* @return The pointer to the extent label node, or NULL if not found.
*/
extentlabel* find_extent_label(extentlabel* head, char* labelName);
/**
* This function converts an integer value to its binary representation of a specified size.
* It handles both positive and negative numbers and performs 2's complement conversion for negative numbers.
*
* @param binary Pointer to the output buffer for the binary representation.
* @param number The integer number to be converted.
* @param size The size of the binary representation.
* @return The success status of the conversion.
*/
int convert_to_binary(char binary[], int number, int size);
#endif /* _SHARED_FP_SP_H */