From 010801d17e1c7d92ff4a2bda8b4a9499668c0fae Mon Sep 17 00:00:00 2001 From: Timendus Date: Tue, 13 Aug 2024 21:40:52 +0200 Subject: [PATCH 1/2] Test memory quirk for reading too (Fx65) --- README.md | 1 + src/tests/5-quirks.8o | 53 +++++++++++++++++++++++++++++++------------ src/utils/helpers.8o | 4 +++- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a6ace2f..bfbcb38 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,7 @@ cross). - `Memory` - The save and load opcodes (`Fx55` and `Fx65`) increment the index register. More information [here](https://laurencescotford.net/chip-8-on-the-cosmac-vip-loading-and-saving-variables/) and [here](https://tobiasvl.github.io/blog/write-a-chip-8-emulator/#fx55-and-fx65-store-and-load-memory). + Test will show `ERR1` if reading and writing don't behave the same. - `Display wait` - Drawing sprites to the display waits for the vertical blank interrupt, limiting their speed to max 60 sprites per second. More information [here](https://laurencescotford.net/chip-8-on-the-cosmac-vip-drawing-sprites/). diff --git a/src/tests/5-quirks.8o b/src/tests/5-quirks.8o index a5a7899..9886d0a 100644 --- a/src/tests/5-quirks.8o +++ b/src/tests/5-quirks.8o @@ -378,31 +378,56 @@ # memQuirk # When reading or writing memory, i gets incremented text 1 6 quirks-mem - v0 := 5 - i := scratchpad-plus-16 - save v0 + v0 := 1 + v1 := 2 + v2 := 3 + v3 := 4 + v4 := 5 + i := scratchpad-plus-3 + save v4 + v0 := 11 + v1 := 12 + v2 := 13 + i := scratchpad-plus-3 + save v2 load v0 v5 := v0 + load v0 + v6 := v0 i := scratchpad load v0 i := flag-err - if v0 == CHIP8 begin - if v5 != 5 then i := flag-ok - end - if v0 == SCHIP_MODERN begin - if v5 == 5 then i := flag-ok - end - if v0 == SCHIP_LEGACY begin - if v5 == 5 then i := flag-ok + + if v0 == CHIP8 then jump expect-memquirk + if v0 == SCHIP_MODERN then jump expect-no-memquirk + if v0 == SCHIP_LEGACY then jump expect-no-memquirk + if v0 == XOCHIP then jump expect-memquirk + +: expect-memquirk + if v5 == 4 begin + if v6 == 5 begin + i := flag-ok + else + i := quirks-inconsistent-1 + end end - if v0 == XOCHIP begin - if v5 != 5 then i := flag-ok + jump memquirk-done + +: expect-no-memquirk + if v5 == 11 begin + if v6 == 11 begin + i := flag-ok + else + i := quirks-inconsistent-1 + end end + +: memquirk-done x := 59 y := 7 sprite x y 3 i := quirks-on - if v5 == 5 then i := quirks-off + if v5 == 11 then i := quirks-off vD := 42 vE := 6 drawText diff --git a/src/utils/helpers.8o b/src/utils/helpers.8o index cb4b569..f341730 100644 --- a/src/utils/helpers.8o +++ b/src/utils/helpers.8o @@ -27,8 +27,10 @@ : scratchpad-plus-1 0 : scratchpad-plus-2 + 0 +: scratchpad-plus-3 0 0 0 0 0 - 0 0 0 0 0 + 0 0 0 0 0 0 0 0 : scratchpad-plus-16 0 From c2e3748599188ead4fde936c3bf63f865800eacb Mon Sep 17 00:00:00 2001 From: Tim Franssen Date: Sat, 17 Aug 2024 14:02:28 +0200 Subject: [PATCH 2/2] ERR1 is a string, not a flag --- src/tests/5-quirks.8o | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tests/5-quirks.8o b/src/tests/5-quirks.8o index 9886d0a..444361e 100644 --- a/src/tests/5-quirks.8o +++ b/src/tests/5-quirks.8o @@ -394,10 +394,11 @@ v5 := v0 load v0 v6 := v0 + i := scratchpad load v0 i := flag-err - + v1 := 0 if v0 == CHIP8 then jump expect-memquirk if v0 == SCHIP_MODERN then jump expect-no-memquirk if v0 == SCHIP_LEGACY then jump expect-no-memquirk @@ -408,7 +409,7 @@ if v6 == 5 begin i := flag-ok else - i := quirks-inconsistent-1 + v1 := 1 end end jump memquirk-done @@ -418,7 +419,7 @@ if v6 == 11 begin i := flag-ok else - i := quirks-inconsistent-1 + v1 := 1 end end @@ -428,6 +429,7 @@ sprite x y 3 i := quirks-on if v5 == 11 then i := quirks-off + if v1 == 1 then i := quirks-inconsistent-1 vD := 42 vE := 6 drawText