Added error return value...

This commit is contained in:
xolatile 2024-07-27 11:10:17 -04:00
parent 65a74456f2
commit 86c4188320
3 changed files with 10 additions and 7 deletions

View File

@ -416,7 +416,7 @@ unsigned char * text_sector_byte = NULL;
int was_instruction_array_empty = 0; int was_instruction_array_empty = 0;
void assemble (unsigned int count, unsigned int * array) { int assemble (unsigned int count, unsigned int * array) {
unsigned int index; unsigned int index;
if ((count == 0) || (array == NULL)) { if ((count == 0) || (array == NULL)) {
@ -463,8 +463,7 @@ void assemble (unsigned int count, unsigned int * array) {
case ENTER: index += build_enter (& array [index]); break; case ENTER: index += build_enter (& array [index]); break;
case POP: index += build_pop (& array [index]); break; case POP: index += build_pop (& array [index]); break;
case PUSH: index += build_push (& array [index]); break; case PUSH: index += build_push (& array [index]); break;
// IS IT BAD TO JUST QUIT? default: return (EXIT_FAILURE);
default: exit ((int) array [index]);
} }
} }
@ -480,4 +479,6 @@ void assemble (unsigned int count, unsigned int * array) {
replace (& text_sector_byte [get], (unsigned char *) & set, sizeof (set)); replace (& text_sector_byte [get], (unsigned char *) & set, sizeof (set));
} }
return (EXIT_SUCCESS);
} }

View File

@ -41,6 +41,6 @@ extern unsigned char * text_sector_byte;
extern int was_instruction_array_empty; extern int was_instruction_array_empty;
extern void assemble (unsigned int count, unsigned int * array); extern int assemble (unsigned int count, unsigned int * array);
#endif #endif

View File

@ -96,13 +96,15 @@ int compile(void) {
dump_variables_to_assembler(); dump_variables_to_assembler();
assemble(token_count, token_array); if (assemble(token_count, token_array)) {
return 1;
}
create_header(); create_header();
FILE * output_file = fopen(output_file_name, "w"); FILE * output_file = fopen(output_file_name, "w");
check(write_output(output_file)); check(write_output(output_file));
fclose(output_file); fclose(output_file);
make_executable(output_file_name); make_executable(output_file_name);