Archived
1
0

minor changes

This commit is contained in:
Erick
2022-02-13 22:59:32 +01:00
parent 655201c064
commit 32b7cb2667
3 changed files with 11 additions and 10 deletions
+3 -2
View File
@@ -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)
+7 -8
View File
@@ -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];
+1
View File
@@ -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*/