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 class
static class
static final record
An 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 aInstruction
record class. -
Method Summary
Modifier and TypeMethodDescriptionint
address()
Returns the value of theaddress
record component.static Instruction.Builder
at
(int address) Initiate construction of an instruction.byte[]
code()
Returns the value of thecode
record component.Returns the value of thedescription
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.mnemonic()
Returns the value of themnemonic
record component.operands()
Returns the value of theoperands
record component.final String
toString()
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 aInstruction
record class.- Parameters:
address
- the value for theaddress
record componentcode
- the value for thecode
record componentmnemonic
- the value for themnemonic
record componentoperands
- the value for theoperands
record componentdescription
- the value for thedescription
record 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 theaddress
record component.- Returns:
- the value of the
address
record component
-
code
public byte[] code()Returns the value of thecode
record component.- Returns:
- the value of the
code
record component
-
mnemonic
Returns the value of themnemonic
record component.- Returns:
- the value of the
mnemonic
record component
-
operands
Returns the value of theoperands
record component.- Returns:
- the value of the
operands
record component
-
description
Returns the value of thedescription
record component.- Returns:
- the value of the
description
record component
-