Skip to content

Commit

Permalink
Add single-operand sub, and, xor, or & cp, which are the canonical fo…
Browse files Browse the repository at this point in the history
…rms; but keep sub a, b etc for convenience
  • Loading branch information
Prof9 committed Sep 20, 2020
1 parent 71f39ec commit c8b58ff
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 45 deletions.
10 changes: 10 additions & 0 deletions Archs/Z80/Z80Opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,27 @@ const tZ80Opcode Z80Opcodes[] = {
{ L"sub", 1, 0x90, Z80_PARAM_A, Z80_PARAM_REG8_MEMHL, -1, 0, 0 },
{ L"sub", 2, 0xD6, Z80_PARAM_A, Z80_PARAM_IMMEDIATE, -1, -1, Z80_IMMEDIATE_U8 | Z80_ADD_SUB_IMMEDIATE },
{ L"sub", 2, 0xE8, Z80_PARAM_SP, Z80_PARAM_IMMEDIATE, -1, -1, Z80_IMMEDIATE_S8 | Z80_NEGATE_IMM | Z80_GAMEBOY },
{ L"sub", 1, 0x90, Z80_PARAM_REG8_MEMHL, Z80_PARAM_NONE, 0, -1, 0 },
{ L"sub", 2, 0xD6, Z80_PARAM_IMMEDIATE, Z80_PARAM_NONE, -1, -1, Z80_IMMEDIATE_U8 | Z80_ADD_SUB_IMMEDIATE },
{ L"sbc", 1, 0x98, Z80_PARAM_A, Z80_PARAM_REG8_MEMHL, -1, 0, 0 },
{ L"sbc", 2, 0xDE, Z80_PARAM_A, Z80_PARAM_IMMEDIATE, -1, -1, Z80_IMMEDIATE_U8 | Z80_ADD_SUB_IMMEDIATE },
{ L"sbc", 2, 0x42, Z80_PARAM_HL, Z80_PARAM_REG16_SP, -1, 4, Z80_Z80 | Z80_PREFIX_ED },
{ L"and", 1, 0xA0, Z80_PARAM_A, Z80_PARAM_REG8_MEMHL, -1, 0, 0 },
{ L"and", 2, 0xE6, Z80_PARAM_A, Z80_PARAM_IMMEDIATE, -1, -1, Z80_IMMEDIATE_U8 },
{ L"and", 1, 0xA0, Z80_PARAM_REG8_MEMHL, Z80_PARAM_NONE, 0, -1, 0 },
{ L"and", 2, 0xE6, Z80_PARAM_IMMEDIATE, Z80_PARAM_NONE, -1, -1, Z80_IMMEDIATE_U8 },
{ L"xor", 1, 0xA8, Z80_PARAM_A, Z80_PARAM_REG8_MEMHL, -1, 0, 0 },
{ L"xor", 2, 0xEE, Z80_PARAM_A, Z80_PARAM_IMMEDIATE, -1, -1, Z80_IMMEDIATE_U8 },
{ L"xor", 1, 0xA8, Z80_PARAM_REG8_MEMHL, Z80_PARAM_NONE, 0, -1, 0 },
{ L"xor", 2, 0xEE, Z80_PARAM_IMMEDIATE, Z80_PARAM_NONE, -1, -1, Z80_IMMEDIATE_U8 },
{ L"or", 1, 0xB0, Z80_PARAM_A, Z80_PARAM_REG8_MEMHL, -1, 0, 0 },
{ L"or", 2, 0xF6, Z80_PARAM_A, Z80_PARAM_IMMEDIATE, -1, -1, Z80_IMMEDIATE_U8 },
{ L"or", 1, 0xB0, Z80_PARAM_REG8_MEMHL, Z80_PARAM_NONE, 0, -1, 0 },
{ L"or", 2, 0xF6, Z80_PARAM_IMMEDIATE, Z80_PARAM_NONE, -1, -1, Z80_IMMEDIATE_U8 },
{ L"cp", 1, 0xB8, Z80_PARAM_A, Z80_PARAM_REG8_MEMHL, -1, 0, 0 },
{ L"cp", 2, 0xFE, Z80_PARAM_A, Z80_PARAM_IMMEDIATE, -1, -1, Z80_IMMEDIATE_U8 },
{ L"cp", 1, 0xB8, Z80_PARAM_REG8_MEMHL, Z80_PARAM_NONE, 0, -1, 0 },
{ L"cp", 2, 0xFE, Z80_PARAM_IMMEDIATE, Z80_PARAM_NONE, -1, -1, Z80_IMMEDIATE_U8 },
{ L"inc", 1, 0x04, Z80_PARAM_REG8_MEMHL, Z80_PARAM_NONE, 3, -1, 0 },
{ L"inc", 1, 0x03, Z80_PARAM_REG16_SP, Z80_PARAM_NONE, 4, -1, 0 },
{ L"dec", 1, 0x05, Z80_PARAM_REG8_MEMHL, Z80_PARAM_NONE, 3, -1, 0 },
Expand Down
90 changes: 45 additions & 45 deletions Tests/Z80/GB Opcodes/GB Opcodes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@
adc a, l
adc a, (hl)
adc a, a
sub a, b
sub a, c
sub a, d
sub a, e
sub a, h
sub a, l
sub a, (hl)
sub a, a
sub b
sub c
sub d
sub e
sub h
sub l
sub (hl)
sub a
sbc a, b
sbc a, c
sbc a, d
Expand All @@ -162,38 +162,38 @@
sbc a, l
sbc a, (hl)
sbc a, a
and a, b
and a, c
and a, d
and a, e
and a, h
and a, l
and a, (hl)
and a, a
xor a, b
xor a, c
xor a, d
xor a, e
xor a, h
xor a, l
xor a, (hl)
xor a, a
or a, b
or a, c
or a, d
or a, e
or a, h
or a, l
or a, (hl)
or a, a
cp a, b
cp a, c
cp a, d
cp a, e
cp a, h
cp a, l
cp a, (hl)
cp a, a
and b
and c
and d
and e
and h
and l
and (hl)
and a
xor b
xor c
xor d
xor e
xor h
xor l
xor (hl)
xor a
or b
or c
or d
or e
or h
or l
or (hl)
or a
cp b
cp c
cp d
cp e
cp h
cp l
cp (hl)
cp a
ret nz
pop bc
jp nz, 0x1234
Expand All @@ -214,7 +214,7 @@
jp nc, 0x1234
call nc, 0x1234
push de
sub a, 0x55
sub 0x55
rst 2
ret c
reti
Expand All @@ -226,25 +226,25 @@
pop hl
ld (0xFF00+c), a
push hl
and a, 0x55
and 0x55
rst 4
add sp, -0x56
jp hl
ld (0x1234), a
xor a, 0x55
xor 0x55
rst 5
ld a, (0xFF00+0x55)
pop af
ld a, (0xFF00+c)
di
push af
or a, 0x55
or 0x55
rst 6
ldhl sp, 0x55
ld sp, hl
ld a, (0x1234)
ei
cp a, 0x55
cp 0x55
rst 7

// CB 00-FF
Expand Down

0 comments on commit c8b58ff

Please sign in to comment.