all repos — 3ByteBadVM @ 736bc261c184c872daaa37bd8f0759c7e8bb7ece

3ByteBadVM

Tidy up makefile, fix VM memory bug
x1phosura x1phosura@x1phosura.zone
Thu, 29 Apr 2021 21:15:13 -0400
commit

736bc261c184c872daaa37bd8f0759c7e8bb7ece

parent

a002c494b77f4934829b0f2ddca0c6a7d241bdbf

3 files changed, 16 insertions(+), 10 deletions(-)

jump to
M MakefileMakefile

@@ -8,16 +8,21 @@ # For more, check out https://youtu.be/G5dNorAoeCM

# Note: I understand this makefile is not as optimal as it could/should be -CC = gcc -CFLAGS ?= -Wall -Wpedantic -Wextra -std=c99 -ROM = rom.bin +CC = gcc +CFLAGS ?= -Wall -Wpedantic -Wextra -std=c99 +DEBUG = -g -ggdb +ROM = rom.bin TRACE_SUFFIX = +TARGET = hard -all: hard +all: $(TARGET) + +debug: CFLAGS += $(DEBUG) +debug: $(TARGET) -trace: CFLAGS += -g -ggdb -DTRACE -lreadline +trace: CFLAGS += $(DEBUG) -DTRACE -lreadline trace: TRACE_SUFFIX = -trace -trace: hard +trace: $(TARGET) disass: CFLAGS += -DTRACE -lreadline

@@ -37,7 +42,7 @@

rom.bin: src/rom.asm src/zeropage.incbin ./ass.sh src/rom.asm src/zeropage.incbin -hard: bin/main.o bin/vm.o +$(TARGET): bin/main.o bin/vm.o $(CC) $(CFLAGS) -o bin/$@$(TRACE_SUFFIX) $^ clean:

@@ -45,5 +50,5 @@ rm -f bin/*

cleano: rm -f bin/*.o -.PHONY: all trace clean clean +.PHONY: all debug trace clean cleano
M src/vm.csrc/vm.c

@@ -303,9 +303,10 @@ print_vm_memory(mem, 0, 0x100);

break; case 'm': if (sscanf(command+2,"%i %i", &mem_start, - &num_bytes) == EOF) + &num_bytes) == EOF) { ; // So far, sscanf always returns EOF // (idk why). TODO: fix eventually + } printf("Dumping %d bytes of memory starting " "at 0x%04x\n", num_bytes, mem_start); print_vm_memory(mem, (uint16_t)mem_start,
M src/vm.hsrc/vm.h

@@ -2,7 +2,7 @@ /* x1phosura 2021 */

#pragma once // WAAAAAY better than a dumb header guard ;) -#define RAM_SIZE 16384 // highest it can be given 16-bit addresses +#define RAM_SIZE 65536 // highest it can be given 16-bit addresses #define STACK_LIM 64