Split decode_z80.sed into decode_z80_(pre|post).sed, simplify decoder
authorNick Downing <nick@ndcode.org>
Sat, 30 Jul 2022 03:07:02 +0000 (13:07 +1000)
committerNick Downing <nick@ndcode.org>
Sat, 30 Jul 2022 08:46:19 +0000 (18:46 +1000)
.gitignore
decode_z80.py
decode_z80.sh [new file with mode: 0755]
decode_z80_post.sed [moved from decode_z80.sed with 100% similarity]
decode_z80_pre.sed [new file with mode: 0644]

index 8d0d587..e224f36 100644 (file)
@@ -1,6 +1,7 @@
 *.ihx
 *.o
 /decode_65c02.txt
+/decode_z80.txt
 /emu_65c02
 /emu_65c02_alt
 /emu_6800
index 1771a95..834bdaf 100755 (executable)
@@ -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 (executable)
index 0000000..d296dbf
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+sed -f decode_z80_pre.sed <instr_z80.txt |\
+./decode_z80.py |\
+sed -f decode_z80_post.sed >decode_z80.txt
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 (file)
index 0000000..2ef5272
--- /dev/null
@@ -0,0 +1,2 @@
+y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+s/ld \([abcdehl]\),\(\(res\|rl\|rr\|set\|sl\|sr\).*\)/\2,\1/