From 2bd8f7c5a4a455d4447f111cc5fed90af76bf280 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Thu, 22 Sep 2022 13:04:12 -0700 Subject: Support comments in tests --- Makefile | 4 +++- tests/countdown.hex | 10 +++++----- tests/fib-mem.hex | 18 +++++++++--------- tests/fib-regs.hex | 12 ++++++------ tests/loop-with-add.hex | 4 ++-- tests/loop.hex | 2 +- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 184f7c0..f470f1b 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ DEBUG := -g CXX := g++ CXXFLAGS := $(WARNINGS) $(OPTIMIZE) $(DEBUG) +SED := sed + XXD := xxd override CXXFLAGS += -std=c++20 @@ -47,4 +49,4 @@ $(BUILD)/procmodel: $(OBJECTS) $(BUILD)/%.bin: %.hex @mkdir -p $(dir $@) - $(XXD) -r -p $< $@ + $(SED) -e "s/\\s*#.*//" $< | $(XXD) -r -p > $@ diff --git a/tests/countdown.hex b/tests/countdown.hex index 1185774..c1af1fb 100644 --- a/tests/countdown.hex +++ b/tests/countdown.hex @@ -1,5 +1,5 @@ -93 90 A3 03 -92 90 02 -92 90 FF 03 -91 90 00 -93 90 A4 00 +93 90 A3 03 # 0: r0 = 3 + 0 +92 90 02 # 4: emit r0 +92 90 FF 03 # 7: r0 = r0 - 1 +91 90 00 # a: jump 0 if r0 == 0 +93 90 A4 00 # d: jump 4 diff --git a/tests/fib-mem.hex b/tests/fib-mem.hex index 521301b..2e49c4e 100644 --- a/tests/fib-mem.hex +++ b/tests/fib-mem.hex @@ -1,9 +1,9 @@ -93 90 A1 A0 A0 A8 B1 05 -93 90 A1 A0 A1 A0 03 -92 91 F0 04 -92 90 A1 02 -92 92 F8 04 -91 A1 B2 03 -B1 05 -92 90 B8 03 -93 90 AF 00 +93 90 A1 A0 A0 A8 B1 05 # 00: [1008] = 1 +93 90 A1 A0 A1 A0 03 # 08: r0 = 1010 +92 91 F0 04 # 0f: r1 = [r0-10] +92 90 A1 02 # 13: emit r1 +92 92 F8 04 # 17: r2 = [r0-8] +91 A1 B2 03 # 1b: r1 = r1 + r2 +B1 05 # 1f: [r0] = r1 +92 90 B8 03 # 21: r0 = r0 + 8 +93 90 AF 00 # 25: jump f diff --git a/tests/fib-regs.hex b/tests/fib-regs.hex index 0f8c5f8..ed7283c 100644 --- a/tests/fib-regs.hex +++ b/tests/fib-regs.hex @@ -1,6 +1,6 @@ -93 91 A1 03 -92 90 02 -92 B1 03 -92 90 A1 03 -92 91 A2 03 -93 90 A4 00 +93 91 A1 03 # 00: r1 = 1 +92 90 02 # 04: emit r0 +92 B1 03 # 07: r2 = r0 + r1 +92 90 A1 03 # 0a: r0 = r1 +92 91 A2 03 # 0e: r1 = r2 +93 90 A4 00 # 12: jump 4 diff --git a/tests/loop-with-add.hex b/tests/loop-with-add.hex index 7c93780..1e1c851 100644 --- a/tests/loop-with-add.hex +++ b/tests/loop-with-add.hex @@ -1,2 +1,2 @@ -03 -91 90 00 +03 # 0: r0 = r0 + r0 +91 90 00 # 1: jump 0 if r0 == 0 diff --git a/tests/loop.hex b/tests/loop.hex index 29fe69d..9666699 100644 --- a/tests/loop.hex +++ b/tests/loop.hex @@ -1 +1 @@ -93 90 00 +93 90 00 # 0: jmp 0 -- cgit v1.2.3