mirror of
https://github.com/romychs/z80go.git
synced 2026-04-18 09:41:17 +03:00
fix disassm bit ops
This commit is contained in:
parent
6f6a08f37f
commit
fec7798be9
@ -354,15 +354,16 @@ func (d *Disassembler) getRel() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var shiftOps = []string{"RLC", "RRC", "RL", "RR", "SLA", "SRA", "SLL", "SRL"}
|
var shiftOps = []string{"RLC", "RRC", "RL", "RR", "SLA", "SRA", "SLL", "SRL"}
|
||||||
|
var bitOps = []string{"BIT", "RES", "SET"}
|
||||||
|
|
||||||
// opocodeCB disassemble Z80 Opcodes, with CB first byte
|
// opocodeCB disassemble Z80 Opcodes, with CB first byte
|
||||||
func (d *Disassembler) opocodeCB() string {
|
func (d *Disassembler) opocodeCB() string {
|
||||||
op := ""
|
op := ""
|
||||||
opcode := d.getByte()
|
opcode := d.getByte()
|
||||||
if opcode <= 0x3F {
|
if opcode <= 0x3F {
|
||||||
op = shiftOps[opcode>>3&0x07] + operands[opcode&0x7]
|
op = shiftOps[opcode>>3&0x07] + sep + operands[opcode&0x7]
|
||||||
} else {
|
} else {
|
||||||
op = shiftOps[(opcode>>6&0x03)-1] + operands[opcode&0x7]
|
op = bitOps[(opcode>>6&0x03)-1] + " " + string(rune(48+(opcode>>3)&0x07)) + sep + operands[opcode&0x7]
|
||||||
}
|
}
|
||||||
return op
|
return op
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,3 +129,26 @@ func Test_LD_r_IXn(t *testing.T) {
|
|||||||
t.Errorf("Error disassm LD_r_IXn, result '%s', expected '%s'", res, expected)
|
t.Errorf("Error disassm LD_r_IXn, result '%s', expected '%s'", res, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var testBITnH = []byte{0xcb, 0x64, 0xcb, 0xde, 0xcb, 0x95}
|
||||||
|
|
||||||
|
func Test_BIT_nn(t *testing.T) {
|
||||||
|
expected := " 0000 BIT 4, H" // JR back
|
||||||
|
setMemory(0x0000, testBITnH)
|
||||||
|
res := disasm.Disassm(0x0000)
|
||||||
|
if res != expected {
|
||||||
|
t.Errorf("Error disassm BIT n,H, result '%s', expected '%s'", res, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected = " 0002 SET 3, (HL)" // JR back
|
||||||
|
res = disasm.Disassm(0x0002)
|
||||||
|
if res != expected {
|
||||||
|
t.Errorf("Error disassm SET n,(HL), result '%s', expected '%s'", res, expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected = " 0004 RES 2, L" // JR back
|
||||||
|
res = disasm.Disassm(0x0004)
|
||||||
|
if res != expected {
|
||||||
|
t.Errorf("Error disassm RES n,(HL), result '%s', expected '%s'", res, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user