Remove unneccessary checks
This commit is contained in:
28
decode_ed.go
28
decode_ed.go
@@ -6,10 +6,6 @@ import (
|
||||
|
||||
// decodeED decodes ED-prefixed instructions
|
||||
func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
if len(data) < 2 {
|
||||
return nil, fmt.Errorf("insufficient data for ED prefix")
|
||||
}
|
||||
|
||||
opcode := data[1]
|
||||
|
||||
// Handle ED prefixed instructions
|
||||
@@ -22,9 +18,6 @@ func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
case 0x42:
|
||||
return &Instruction{Mnemonic: "SBC HL, BC", Length: 2, Address: 0xFFFF}, nil
|
||||
case 0x43:
|
||||
if len(data) < 4 {
|
||||
return nil, fmt.Errorf("insufficient data for LD (nn), BC")
|
||||
}
|
||||
nn := uint16(data[3])<<8 | uint16(data[2])
|
||||
return &Instruction{Mnemonic: fmt.Sprintf("LD ($%04X), BC", nn), Length: 4, Address: nn}, nil
|
||||
case 0x44:
|
||||
@@ -42,9 +35,6 @@ func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
case 0x4A:
|
||||
return &Instruction{Mnemonic: "ADC HL, BC", Length: 2, Address: 0xFFFF}, nil
|
||||
case 0x4B:
|
||||
if len(data) < 4 {
|
||||
return nil, fmt.Errorf("insufficient data for LD BC, (nn)")
|
||||
}
|
||||
nn := uint16(data[3])<<8 | uint16(data[2])
|
||||
return &Instruction{Mnemonic: fmt.Sprintf("LD BC, ($%04X)", nn), Length: 4, Address: nn}, nil
|
||||
case 0x4C:
|
||||
@@ -64,9 +54,6 @@ func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
case 0x52:
|
||||
return &Instruction{Mnemonic: "SBC HL, DE", Length: 2, Address: 0xFFFF}, nil
|
||||
case 0x53:
|
||||
if len(data) < 4 {
|
||||
return nil, fmt.Errorf("insufficient data for LD (nn), DE")
|
||||
}
|
||||
nn := uint16(data[3])<<8 | uint16(data[2])
|
||||
return &Instruction{Mnemonic: fmt.Sprintf("LD ($%04X), DE", nn), Length: 4, Address: nn}, nil
|
||||
case 0x54:
|
||||
@@ -84,9 +71,6 @@ func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
case 0x5A:
|
||||
return &Instruction{Mnemonic: "ADC HL, DE", Length: 2, Address: 0xFFFF}, nil
|
||||
case 0x5B:
|
||||
if len(data) < 4 {
|
||||
return nil, fmt.Errorf("insufficient data for LD DE, (nn)")
|
||||
}
|
||||
nn := uint16(data[3])<<8 | uint16(data[2])
|
||||
return &Instruction{Mnemonic: fmt.Sprintf("LD DE, ($%04X)", nn), Length: 4, Address: nn}, nil
|
||||
case 0x5C:
|
||||
@@ -106,9 +90,6 @@ func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
case 0x62:
|
||||
return &Instruction{Mnemonic: "SBC HL, HL", Length: 2, Address: 0xFFFF}, nil
|
||||
case 0x63:
|
||||
if len(data) < 4 {
|
||||
return nil, fmt.Errorf("insufficient data for LD (nn), HL")
|
||||
}
|
||||
nn := uint16(data[3])<<8 | uint16(data[2])
|
||||
return &Instruction{Mnemonic: fmt.Sprintf("LD ($%04X), HL", nn), Length: 4, Address: nn}, nil
|
||||
case 0x64:
|
||||
@@ -126,9 +107,6 @@ func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
case 0x6A:
|
||||
return &Instruction{Mnemonic: "ADC HL, HL", Length: 2, Address: 0xFFFF}, nil
|
||||
case 0x6B:
|
||||
if len(data) < 4 {
|
||||
return nil, fmt.Errorf("insufficient data for LD HL, (nn)")
|
||||
}
|
||||
nn := uint16(data[3])<<8 | uint16(data[2])
|
||||
return &Instruction{Mnemonic: fmt.Sprintf("LD HL, ($%04X)", nn), Length: 4, Address: nn}, nil
|
||||
case 0x6C:
|
||||
@@ -148,9 +126,6 @@ func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
case 0x72:
|
||||
return &Instruction{Mnemonic: "SBC HL, SP", Length: 2, Address: 0xFFFF}, nil
|
||||
case 0x73:
|
||||
if len(data) < 4 {
|
||||
return nil, fmt.Errorf("insufficient data for LD (nn), SP")
|
||||
}
|
||||
nn := uint16(data[3])<<8 | uint16(data[2])
|
||||
return &Instruction{Mnemonic: fmt.Sprintf("LD ($%04X), SP", nn), Length: 4, Address: nn}, nil
|
||||
case 0x74:
|
||||
@@ -168,9 +143,6 @@ func (d *Disassembler) decodeED(data []byte) (*Instruction, error) {
|
||||
case 0x7A:
|
||||
return &Instruction{Mnemonic: "ADC HL, SP", Length: 2, Address: 0xFFFF}, nil
|
||||
case 0x7B:
|
||||
if len(data) < 4 {
|
||||
return nil, fmt.Errorf("insufficient data for LD SP, (nn)")
|
||||
}
|
||||
nn := uint16(data[3])<<8 | uint16(data[2])
|
||||
return &Instruction{Mnemonic: fmt.Sprintf("LD SP, ($%04X)", nn), Length: 4, Address: nn}, nil
|
||||
case 0x7C:
|
||||
|
||||
Reference in New Issue
Block a user