diff --git a/src/Makefile b/src/Makefile index 40c6c9a..eb44e88 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,12 +2,13 @@ CC := gcc CSTND := --std=c11 CFLAGS := -o SRC := tyvm.c +DEPS := lc3_lib.h lc3_lib.c preprocessor.c registers.c -OUT = tyvm-unix +OUT := tyvm-unix #OUT := tyvm-win .PHONY: all clean all: tyvm -tyvm: tyvm.c includes.h registers.h +tyvm: $(SRC) $(DEPS) $(CC) $(CSTND) $(SRC) $(CFLAGS) $(OUT) \ No newline at end of file diff --git a/src/lc3_lib.c b/src/lc3_lib.c index 10a47f0..b1f751b 100644 --- a/src/lc3_lib.c +++ b/src/lc3_lib.c @@ -1,7 +1,6 @@ -//FIXME: all includes maybe unnecessary -#include "preprocessor.h" -#include "registers.c" +#include "preprocessor.c" #include "lc3_lib.h" +#include "registers.c" uint16_t sign_extend(uint16_t n, int bit_count) { if((n >> (bit_count - 1)) & 1) { @@ -57,7 +56,7 @@ int read_image(const char* file) { return 1; } -/* Defining functions for Unix or Windows based systems */ +/* Defining OS-dependent functions for Unix or Windows based systems */ #ifdef __UNIX uint16_t check_key() { fd_set readfds; @@ -109,11 +108,11 @@ void mem_write(uint16_t address, uint16_t val) { } int mem_read(uint16_t address) { - if(address == MMR_KSR) { + if(address == MR_KSR) { if(check_key()) { - memory[MMR_KSR] = 1 << 15; - memory[MMR_KDR] = getchar(); - } else memory[MMR_KSR] = 0; + memory[MR_KSR] = 1 << 15; + memory[MR_KDR] = getchar(); + } else memory[MR_KSR] = 0; } return memory[address]; diff --git a/src/lc3_lib.h b/src/lc3_lib.h index ffe18e5..60b3495 100644 --- a/src/lc3_lib.h +++ b/src/lc3_lib.h @@ -1,5 +1,6 @@ /* Library of functions used in tyvm.c */ +#include "preprocessor.c" /* Sign extension function for immediate add mode (imm5[0:4]) transforms 5bit number to 8bit number preserving sign*/