From ebe53f540c8f8fe8e42a8b63480c0a5fb67ce94b Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Thu, 29 Mar 2018 11:46:56 +0100 Subject: [PATCH] Fix bug when zero page address was $00. --- eg/atari2600/atari-2600-example.60p | 2 +- eg/atari2600/build.sh | 1 + src/sixtypical/compiler.py | 2 +- tests/SixtyPical Compilation.md | 11 ++++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/eg/atari2600/atari-2600-example.60p b/eg/atari2600/atari-2600-example.60p index 59d8179..fad76c3 100644 --- a/eg/atari2600/atari-2600-example.60p +++ b/eg/atari2600/atari-2600-example.60p @@ -26,7 +26,7 @@ byte colour @ $80 byte luminosity @ $81 byte joystick_delay @ $82 -byte table[8] image_data : "ZZZZUUUU" // [126, 129, 153, 165, 129, 165, 129, 126] +byte table[8] image_data : 126, 129, 153, 165, 129, 165, 129, 126 // %01111110 // %10000001 // %10011001 diff --git a/eg/atari2600/build.sh b/eg/atari2600/build.sh index 1f141c1..1cb7509 100755 --- a/eg/atari2600/build.sh +++ b/eg/atari2600/build.sh @@ -6,4 +6,5 @@ if [ "x$COMPARE" != "x" ]; then dcc6502 -o 0xf000 -m 200 atari-2600-example.bin > atari-2600-example.bin.disasm.txt dcc6502 -o 0xf000 -m 200 atari-2600-example-60p.bin > atari-2600-example-60p.bin.disasm.txt paste atari-2600-example.bin.disasm.txt atari-2600-example-60p.bin.disasm.txt | pr -t -e24 + #diff -ru atari-2600-example.bin.disasm.txt atari-2600-example-60p.bin.disasm.txt fi diff --git a/src/sixtypical/compiler.py b/src/sixtypical/compiler.py index add19e9..7dedbd4 100644 --- a/src/sixtypical/compiler.py +++ b/src/sixtypical/compiler.py @@ -68,7 +68,7 @@ class Compiler(object): return self.labels[name] def absolute_or_zero_page(self, label): - if label.addr and label.addr < 256: + if label.addr is not None and label.addr < 256: return ZeroPage(label) else: return Absolute(label) diff --git a/tests/SixtyPical Compilation.md b/tests/SixtyPical Compilation.md index 511ed5c..629237d 100644 --- a/tests/SixtyPical Compilation.md +++ b/tests/SixtyPical Compilation.md @@ -114,19 +114,24 @@ Memory location with explicit address. Accesses to memory locations in zero-page with `ld` and `st` use zero-page addressing. + | byte zp @ $00 | byte screen @ 100 | | routine main - | inputs screen - | outputs screen + | inputs screen, zp + | outputs screen, zp | trashes a, z, n | { | ld a, screen | st a, screen + | ld a, zp + | st a, zp | } = $080D LDA $64 = $080F STA $64 - = $0811 RTS + = $0811 LDA $00 + = $0813 STA $00 + = $0815 RTS Memory location with initial value.