Record Class Instruction
java.lang.Object
java.lang.Record
org.applecommander.disassembler.api.Instruction
- Record Components:
address- The starting address for this instruction.code- The raw bytes representing the instruction.mnemonic- The opcode mnemonic.operands- List of operands, assumed to be joined with ",".description- An optional description given to the opcode.
public record Instruction(int address, byte[] code, String mnemonic, List<Instruction.Operand> operands, Optional<String> description)
extends Record
An instruction represents one decoded lines. It potentially could also be a "directive" (not really, but useful
for humans); for example the switching instruction set uses ".6502" and ".SWEET16" to indicate mode switches.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic final recordAn operand represents a single operand. -
Constructor Summary
ConstructorsConstructorDescriptionInstruction(int address, byte[] code, String mnemonic, List<Instruction.Operand> operands, Optional<String> description) Creates an instance of aInstructionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintaddress()Returns the value of theaddressrecord component.static Instruction.Builderat(int address) Initiate construction of an instruction.byte[]code()Returns the value of thecoderecord component.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.mnemonic()Returns the value of themnemonicrecord component.operands()Returns the value of theoperandsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Instruction
public Instruction(int address, byte[] code, String mnemonic, List<Instruction.Operand> operands, Optional<String> description) Creates an instance of aInstructionrecord class.- Parameters:
address- the value for theaddressrecord componentcode- the value for thecoderecord componentmnemonic- the value for themnemonicrecord componentoperands- the value for theoperandsrecord componentdescription- the value for thedescriptionrecord component
-
-
Method Details
-
addressRef
-
at
Initiate construction of an instruction. For example (this is fabricated but also gives an idea):int operandValue = program.peekUnsignedByte(1); Instruction inst = Instruction.at(program.currentAddress()) .code(program.read(2)) .mnemonic("LDA") .opValue("#%s", "%d", operandValue) .get(); -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
address
public int address()Returns the value of theaddressrecord component.- Returns:
- the value of the
addressrecord component
-
code
public byte[] code()Returns the value of thecoderecord component.- Returns:
- the value of the
coderecord component
-
mnemonic
Returns the value of themnemonicrecord component.- Returns:
- the value of the
mnemonicrecord component
-
operands
Returns the value of theoperandsrecord component.- Returns:
- the value of the
operandsrecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-