From 0d5c81020431735720d9cd0d8b081311756228e0 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Sat, 30 Jul 2022 13:07:02 +1000 Subject: [PATCH] Split decode_z80.sed into decode_z80_(pre|post).sed, simplify decoder --- .gitignore | 1 + decode_z80.py | 5 +---- decode_z80.sh | 4 ++++ decode_z80.sed => decode_z80_post.sed | 0 decode_z80_pre.sed | 2 ++ 5 files changed, 8 insertions(+), 4 deletions(-) create mode 100755 decode_z80.sh rename decode_z80.sed => decode_z80_post.sed (100%) create mode 100644 decode_z80_pre.sed diff --git a/.gitignore b/.gitignore index 8d0d587..e224f36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.ihx *.o /decode_65c02.txt +/decode_z80.txt /emu_65c02 /emu_65c02_alt /emu_6800 diff --git a/decode_z80.py b/decode_z80.py index 1771a95..834bdaf 100755 --- a/decode_z80.py +++ b/decode_z80.py @@ -238,14 +238,11 @@ for i in prefixes: ) ) else: - instr = line.lower().split() + instr = line.split() if len(instr) == 0: instr = ['ill'] elif len(instr) >= 2: instr[1:] = [l for k in instr[1:] for l in k.split(',')] - if len(instr) >= 4: # the undocumented DDCB and FDCB variants - assert instr[0] == 'ld' - instr = instr[2:] + instr[1:2] # "ld a,op (ix+n)" to "op (ix+n),a" #print('xxx', instr) suffix = '' if instr[0] not in byte_opcodes and instr[0] not in word_opcodes: diff --git a/decode_z80.sh b/decode_z80.sh new file mode 100755 index 0000000..d296dbf --- /dev/null +++ b/decode_z80.sh @@ -0,0 +1,4 @@ +#!/bin/sh +sed -f decode_z80_pre.sed decode_z80.txt diff --git a/decode_z80.sed b/decode_z80_post.sed similarity index 100% rename from decode_z80.sed rename to decode_z80_post.sed diff --git a/decode_z80_pre.sed b/decode_z80_pre.sed new file mode 100644 index 0000000..2ef5272 --- /dev/null +++ b/decode_z80_pre.sed @@ -0,0 +1,2 @@ +y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ +s/ld \([abcdehl]\),\(\(res\|rl\|rr\|set\|sl\|sr\).*\)/\2,\1/ -- 2.34.1