From 3deaa5a4828348bfa82b73a7b6faa0c8802daae9 Mon Sep 17 00:00:00 2001 From: Rob Greene Date: Tue, 29 Sep 2015 09:58:55 -0500 Subject: [PATCH] Tweak to ilen routine, shortened it a bit. --- shared/Makefile | 2 ++ shared/ilen.asm | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/shared/Makefile b/shared/Makefile index 302cb77..11834a1 100755 --- a/shared/Makefile +++ b/shared/Makefile @@ -6,6 +6,8 @@ VIRTUAL2 = /Applications/Virtual\ \]\[/Virtual\ \]\[.app/Contents/MacOS/Virtual\ all: @echo "Please select a target." +ilen-test: ilen-test.bin + ilen-test.bin: ilen-test.asm cl65 -o ilen-test.bin -t none --start-addr 0x2000 -l ilen-test.asm cp $(TEMPLATE) ilen-test.po diff --git a/shared/ilen.asm b/shared/ilen.asm index e414ee6..3fb1c41 100644 --- a/shared/ilen.asm +++ b/shared/ilen.asm @@ -7,18 +7,18 @@ ; ; Calculate Instruction Length ; Based on observations in 65C02 data sheet: -; * Generally, length is based on LOW nibble -; * There are a few special cases (including X9 column) +; * Generally, length is based on LOW nibble: +; - X0..X7 = 2 bytes +; - X8..XB = 1 byte +; - XC..XF = 3 bytes +; * There are a few special cases (including X0 and X9 columns) ; Input: Acc. = instruction ; Output: Acc. = length ; .proc ilen - bit #$0f - bne @notcol0 -@column0: - bit #%10010000 ; Normal instructions have at least one of these bits set - beq @notnormal ; None are set -@notcol0: ; "Normal" values for ALL columns 0-F + bit #%10011111 ; Normal instructions have at least one of these bits set + beq @column0 ; None are set, column 0 special cases ($00 / $20 / $40 / $60) +@normal: ; "Normal" values for ALL columns 0-F asl asl asl @@ -36,7 +36,7 @@ lda #3 rts -@notnormal: +@column0: ; Only special cases cmp #$20 ; JSR ($20) beq @three ; fall through for BRK ($00) / RTI ($40) / RTS ($60)