Updated link in README file.
[Hack-Assembler.git] / symbol.h
blob4dc8db93320091a57f6437a62a6ff713dbb1c93f
1 /* Hash size must be a prime number. */
2 #define HASH_SIZE 104729
4 struct symbol_hash
6 char name[MAXSYMBOL];
7 int address;
8 };
11 * Returns current value of RAM address.
13 int get_ram_address();
16 * Increments ROM Address value.
17 * ROM Address used to store location of instruction tied to symbols.
18 * This number correponds to the instruction number of the "jump" instruction.
20 void inc_rom_address();
23 * Returns current value of ROM address.
25 int get_rom_address();
28 * Prints out hash.
29 * Must pass hash pointer and length of hash array
31 void print_hash();
34 * Calculates Hash value.
35 * Returns integer value of hash based on string input
37 int hash(char symbol[]);
40 * Adds pair (symbol, address) to the table.
41 * If address is set to < 0, hash chooses address.
42 * Returns 1 if entry added to table and 0 otherwise.
44 int add_entry(char symbol[], int address);
47 * Look from beginning of hash for an empty slot and return it's address
48 * This should be used only when a hash collision occurs as there is a
49 * performance penalty for finding this value later.
51 int next_hash_space(void);
54 * Returns address associated with symbol.
55 * If array found in hash, address is returned,
56 * otherwise return -1
58 int get_address(char symbol[]);