From 5a31ecc2453d1f7d9ce34e811afe709534baf77b Mon Sep 17 00:00:00 2001 From: Jeff Tranter Date: Thu, 2 Jul 2015 18:34:12 -0400 Subject: [PATCH] Implement more of Z80. --- z80.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/z80.py b/z80.py index 3ae0be2..1db58ab 100644 --- a/z80.py +++ b/z80.py @@ -17,8 +17,6 @@ leadInBytes = [0xcb, 0xdd, 0xed, 0xfd] # List of addressing modes and corresponding format strings for operands. addressModeTable = { "implied" : "", -"(ix+d)" : "(ix+${0:02X})", -"(iy+d)" : "(iy+${0:02X})", "0" : "0", "0,a" : "0,a", "0,b" : "0,b", @@ -107,6 +105,7 @@ addressModeTable = { "a,indde" : "a,(de)", "a,indhl" : "a,(hl)", "a,indix+d" : "a,(ix+${0:02X})", +"a,indiy+d" : "a,(iy+${0:02X})", "a,indn" : "a,(${0:02X})", "a,indnn" : "a,(${1:02X}{0:02X})", "a,l" : "a,l", @@ -124,6 +123,7 @@ addressModeTable = { "b,indc" : "b,(c)", "b,indhl" : "b,(hl)", "b,indix+d" : "b,(ix+${0:02X})", +"b,indiy+d" : "b,(iy+${0:02X})", "b,l" : "b,l", "b,n" : "b,${0:02X}", "bc" : "bc", @@ -139,6 +139,7 @@ addressModeTable = { "c,indc" : "c,(c)", "c,indhl" : "c,(hl)", "c,indix+d" : "c,(ix+${0:02X})", +"c,indiy+d" : "c,(iy+${0:02X})", "c,l" : "c,l", "c,n" : "b,${0:02X}", "c,n" : "c,${0:04X}", @@ -153,6 +154,7 @@ addressModeTable = { "d,indc" : "d,(c)", "d,indhl" : "d,(hl)", "d,indix+d" : "d,(ix+${0:02X})", +"d,indiy+d" : "d,(iy+${0:02X})", "d,l" : "d,l", "d,n" : "d,${0:02X}", "de" : "de", @@ -169,6 +171,7 @@ addressModeTable = { "e,indc" : "e,(c)", "e,indhl" : "e,(hl)", "e,indix+d" : "e,(ix+${0:02X})", +"e,indiy+d" : "e,(iy+${0:02X})", "e,l" : "e,l", "e,n" : "e,${0:02X}", "h" : "h", @@ -181,6 +184,7 @@ addressModeTable = { "h,indc" : "h,(c)", "h,indhl" : "h,(hl)", "h,indix+d" : "h,(ix+${0:02X})", +"h,indiy+d" : "h,(iy+${0:02X})", "h,l" : "h,l", "h,n" : "h,${0:02X}", "hl" : "hl", @@ -194,6 +198,7 @@ addressModeTable = { "indaa,bc" : "(${1:02X}{0:02X}),bc", "indaa,de" : "(${1:02X}{0:02X}),de", "indaa,ix" : "(${1:02X}{0:02X}),ix", +"indaa,iy" : "(${1:02X}{0:02X}),iy", "indaa,sp" : "(${1:02X}{0:02X}),sp", "indbc,a" : "(bc),a", "indc,a" : "(c),a", @@ -215,6 +220,7 @@ addressModeTable = { "indhl,n" : "(hl),(${0:02X})", "indix+d" : "(ix+${0:02X})", "indix+d,a" : "(ix+${0:02X}),a", +"indiy+d,a" : "(iy+${0:02X}),a", "indix+d,b" : "(ix+${0:02X}),b", "indix+d,c" : "(ix+${0:02X}),c", "indix+d,d" : "(ix+${0:02X}),d", @@ -222,6 +228,14 @@ addressModeTable = { "indix+d,h" : "(ix+${0:02X}),h", "indix+d,l" : "(ix+${0:02X}),l", "indix+d,n" : "(ix+${0:02X}),${1:02X}", +"indiy+d" : "(iy+${0:02X})", +"indiy+d,b" : "(iy+${0:02X}),b", +"indiy+d,c" : "(iy+${0:02X}),c", +"indiy+d,d" : "(iy+${0:02X}),d", +"indiy+d,e" : "(iy+${0:02X}),e", +"indiy+d,h" : "(iy+${0:02X}),h", +"indiy+d,l" : "(iy+${0:02X}),l", +"indiy+d,n" : "(iy+${0:02X}),${1:02X}", "indn,a" : "(${0:02X}),a", "indnn,a" : "(${1:02X}{0:02X}),a", "indnn,hl" : "(${1:02X}{0:02X}),hl", @@ -232,7 +246,14 @@ addressModeTable = { "ix,de" : "ix,de", "ix,indaa" : "ix,(${1:02X}{0:02X})", "ix,ix" : "ix,ix", +"iy" : "iy", +"iy,aa" : "iy,${0:02X}{1:02X}", "iy,bc" : "iy,bc", +"iy,bc" : "iy,bc", +"iy,de" : "iy,de", +"iy,indaa" : "iy,(${1:02X}{0:02X})", +"iy,indaa" : "iy,(${1:02X}{0:02X})", +"iy,iy" : "iy,iy", "l" : "l", "l,a" : "l,a", "l,b" : "l,b", @@ -243,13 +264,14 @@ addressModeTable = { "l,indc" : "l,(c)", "l,indhl" : "l,(hl)", "l,indix+d" : "l,(ix+${0:02X})", +"l,indiy+d" : "l,(iy+${0:02X})", "l,l" : "l,l", "l,n" : "l,${0:02X}", "m" : "m", "m,nn" : "m,${1:02X}{0:02X}", "n" : "${0:02X}", -"n,(ix+d)" : "n,(ix+${0:02X})", -"n,(iy+d)" : "n,(iy+${0:02X})", +"n,indix+d" : "n,(ix+${0:02X})", +"n,indiy+d" : "n,(iy+${0:02X})", "nc" : "nc", "nc,n" : "nc,${0:04X}", "nc,nn" : "nc,${1:02X}{0:02X}", @@ -853,9 +875,9 @@ opcodeTable = { 0xddb6 : [ 3, "or", "indix+d" ], 0xddbe : [ 3, "cp", "indix+d" ], -0xdd8e : [3, "adc", "(ix+d)" ], +0xdd8e : [3, "adc", "indix+d" ], -0xddcb : [ 4, "bit", "n,(ix+d)" ], +0xddcb : [ 4, "bit", "n,indix+d" ], 0xed40 : [ 2, "in", "b,indc" ], 0xed41 : [ 2, "out", "indc,b" ], @@ -915,10 +937,41 @@ opcodeTable = { 0xedbb : [ 2, "otdr", "implied" ], 0xfd09 : [ 2, "add", "iy,bc" ], +0xfd19 : [ 2, "add", "iy,de" ], +0xfd21 : [ 4, "ld", "iy,aa" ], +0xfd22 : [ 4, "ld", "indaa,iy" ], +0xfd23 : [ 2, "inc", "iy" ], +0xfd29 : [ 2, "add", "iy,iy" ], +0xfd2a : [ 4, "ld", "iy,indaa" ], +0xfd2b : [ 2, "dec", "iy" ], +0xfd34 : [ 3, "inc", "indiy+d" ], +0xfd35 : [ 3, "dec", "indiy+d" ], +0xfd36 : [ 4, "ld", "indiy+d,n" ], +0xfd39 : [ 2, "add", "xy,sp" ], +0xfd46 : [ 3, "ld", "b,indiy+d" ], +0xfd4e : [ 3, "ld", "c,indiy+d" ], +0xfd56 : [ 3, "ld", "d,indiy+d" ], +0xfd5e : [ 3, "ld", "e,indiy+d" ], +0xfd66 : [ 3, "ld", "h,indiy+d" ], +0xfd6e : [ 3, "ld", "l,indiy+d" ], +0xfd70 : [ 3, "ld", "indiy+d,b" ], +0xfd71 : [ 3, "ld", "indiy+d,c" ], +0xfd72 : [ 3, "ld", "indiy+d,d" ], +0xfd73 : [ 3, "ld", "indiy+d,e" ], +0xfd74 : [ 3, "ld", "indiy+d,h" ], +0xfd75 : [ 3, "ld", "indiy+d,l" ], +0xfd77 : [ 3, "ld", "indiy+d,a" ], +0xfd7e : [ 3, "ld", "a,indiy+d" ], +0xfd86 : [ 3, "add", "a,indiy+d" ], +0xfd8e : [ 3, "adc", "a,indiy+d" ], +0xfd96 : [ 3, "sub", "indiy+d" ], +0xfd9e : [ 3, "sbc", "a,indiy+d" ], +0xfda6 : [ 3, "and", "indiy+d" ], +0xfdae : [ 3, "xor", "indiy+d" ], +0xfdb6 : [ 3, "or", "indiy+d" ], +0xfdbe : [ 3, "cp", "indiy+d" ], -0xfd8e : [3, "adc", "(iy+d)" ], - -0xfdcb : [ 4, "bit", "n,(iy+d)" ], +0xfdcb : [ 4, "bit", "n,indiy+d" ], }