From: bylex Date: Wed, 26 Feb 2025 07:48:36 +0000 (+0100) Subject: Fix loading memory and add simple stack test X-Git-Url: https://git.bylex.cz/?a=commitdiff_plain;h=a84fd73a9a7962d4427399b60c640982afb31093;p=maturita.git Fix loading memory and add simple stack test --- diff --git a/interpreter.c b/interpreter.c index cb83f35..17c8333 100644 --- a/interpreter.c +++ b/interpreter.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "tigr.h" @@ -26,14 +27,14 @@ uint64_t instruction_counter = 0; void load_mem(char* file_name) { uint32_t current_addr = 0; - uint8_t* line_buffer = malloc(5); + uint8_t* line_buffer = malloc(4); FILE* input_file = fopen(file_name, "rb"); if(!input_file) { perror("Error opening input file"); exit(1); } - while(fgets(line_buffer, 5, input_file)) + while(fread(line_buffer, 4, 1, input_file)) { if(current_addr > 65534) break; memcpy(&(mem[current_addr]), line_buffer, 4); diff --git a/test_stack.o b/test_stack.o new file mode 100644 index 0000000..7ed3afb Binary files /dev/null and b/test_stack.o differ diff --git a/test_stack.s b/test_stack.s new file mode 100644 index 0000000..0c661b7 --- /dev/null +++ b/test_stack.s @@ -0,0 +1,3 @@ +ldl 1 255 +pts 1 +pfs 2