Class Program

java.lang.Object
org.applecommander.disassembler.api.Program

public class Program extends Object
Program is a state class that tracks where decoding is, what the address is, and provides a few helper methods to assist with various data types. Note that "get" reads from an absolute position (always from 0) while "peek" reads from a relative position (from offset).
  • Constructor Details

    • Program

      public Program(byte[] code, int address)
  • Method Details

    • length

      public int length()
      Length of code.
    • hasMore

      public boolean hasMore()
      Test if there are more bytes to process.
    • peekUnsignedByte

      public int peekUnsignedByte()
      Get an unsigned byte at the current offset. Does not advance the offset value.
    • peekUnsignedByte

      public int peekUnsignedByte(int n)
      Get an unsigned byte at the current offset + n. Does not advance the offset value.
    • peekUnsignedShort

      public int peekUnsignedShort(int n)
      Get an unsigned short (2 bytes, little endian) at the current offset + n. Does not advance the offset value.
    • peekSignedByte

      public int peekSignedByte(int n)
      Get a *signed* byte at the current offset + n. Does not advance the offset value.
    • read

      public byte[] read(int n)
      Read n bytes. Advances offset. Used to read all bytes that are part of an instruction.
    • getUnsignedByte

      public int getUnsignedByte(int n)
      Get an unsigned byte from specified offset. This is not relative like the others.
    • currentOffset

      public int currentOffset()
      Get the current offset.
    • baseAddress

      public int baseAddress()
      Get the base address. This is the initial address passed into the constructor.
    • currentAddress

      public int currentAddress()
      Get the current address. Note that the address is wrapped across the address space. Currently, 64K.