Fix some indenting and proceed with label processing
This commit is contained in:
parent
84a26a7189
commit
7ea187efc6
3 changed files with 52 additions and 40 deletions
10
src/labels.c
10
src/labels.c
|
@ -1,4 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "../header/labels.h"
|
#include "../header/labels.h"
|
||||||
|
|
||||||
void build_label_table(char label_tokens[][MAX_TOKEN_SIZE], shash_hashtable_t *label_table)
|
void build_label_table(char label_tokens[][MAX_TOKEN_SIZE], shash_hashtable_t *label_table)
|
||||||
|
@ -16,7 +17,14 @@ void build_label_table(char label_tokens[][MAX_TOKEN_SIZE], shash_hashtable_t *l
|
||||||
|
|
||||||
void remove_label_definition_tokens(char label_tokens[][MAX_TOKEN_SIZE], char no_label_definition_tokens[][MAX_TOKEN_SIZE])
|
void remove_label_definition_tokens(char label_tokens[][MAX_TOKEN_SIZE], char no_label_definition_tokens[][MAX_TOKEN_SIZE])
|
||||||
{
|
{
|
||||||
|
unsigned int new_index = 0;
|
||||||
|
for(unsigned int i = 0; label_tokens[i][0] != EOF; i++)
|
||||||
|
{
|
||||||
|
if(label_tokens[i][0] == '$') continue;
|
||||||
|
strncpy(no_label_definition_tokens[new_index], label_tokens[i], MAX_TOKEN_SIZE);
|
||||||
|
new_index++;
|
||||||
|
}
|
||||||
|
no_label_definition_tokens[new_index][0] = EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void replace_labels_with_adresses(char no_label_definition_tokens[][MAX_TOKEN_SIZE], char tokens[][MAX_TOKEN_SIZE])
|
void replace_labels_with_adresses(char no_label_definition_tokens[][MAX_TOKEN_SIZE], char tokens[][MAX_TOKEN_SIZE])
|
||||||
|
|
|
@ -122,7 +122,10 @@ int main(int argc, char **argv)
|
||||||
FILE *assembly_file;
|
FILE *assembly_file;
|
||||||
assembly_file = fopen(arguments.input_file, "r");
|
assembly_file = fopen(arguments.input_file, "r");
|
||||||
if (assembly_file == NULL)
|
if (assembly_file == NULL)
|
||||||
|
{
|
||||||
|
printf("Error: Couldn't open input file\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
char(*label_tokens)[MAX_TOKEN_SIZE] = calloc(MAX_MEMORY, sizeof(*label_tokens));
|
char(*label_tokens)[MAX_TOKEN_SIZE] = calloc(MAX_MEMORY, sizeof(*label_tokens));
|
||||||
if (label_tokens == NULL)
|
if (label_tokens == NULL)
|
||||||
|
@ -154,6 +157,7 @@ int main(int argc, char **argv)
|
||||||
// Check if the EIPA Assembly contains errors with the no_label_definition_tokens array
|
// Check if the EIPA Assembly contains errors with the no_label_definition_tokens array
|
||||||
shash_hashtable_t instruction_informations = create_instruction_information_hastable();
|
shash_hashtable_t instruction_informations = create_instruction_information_hastable();
|
||||||
printf("Found %d errors\n", check_token_errors(no_label_definition_tokens, instruction_informations));
|
printf("Found %d errors\n", check_token_errors(no_label_definition_tokens, instruction_informations));
|
||||||
|
exit(0);
|
||||||
|
|
||||||
// Part II of processing labels
|
// Part II of processing labels
|
||||||
char(*tokens)[MAX_TOKEN_SIZE] = calloc(MAX_MEMORY, sizeof(*tokens));
|
char(*tokens)[MAX_TOKEN_SIZE] = calloc(MAX_MEMORY, sizeof(*tokens));
|
||||||
|
|
Loading…
Reference in a new issue