Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.core
Class Instr

    java.lang.Object
      avrora.core.Instr

All Implemented Interfaces:
  InstrPrototype

Direct Known Subclasses:
  Instr.IMM_class, Instr.IMMIMM_class, Instr.IMMREG_class, Instr.IMMWORD_class, Instr.NONE_class, Instr.REG_class, Instr.REGIMM_class, Instr.REGIMMREG_class, Instr.REGREG_class, Instr.REGREGIMM_class, Instr.WORD_class

public abstract class Instr
extends java.lang.Object
implements InstrPrototype

The `Instr` class and its descendants represent instructions within the assembly code. The visitor pattern is applied here. Each instruction has an `accept()` method that allows it to be visited with double dispatch by a `InstrVisitor`. Each instruction in the AVR instruction set is represented by an inner class whose source has been generated from a simple specification.

See Also:
  `InstrVisitor`

Nested Class Summary
`static class` | `Instr.ADC` I N S T R U C T I O N D E S C R I P T I O N S ---------------------------------------------------------------- These are the actual instruction descriptions that contain the constraints on operands and sizes, etc.
`static class` | `Instr.ADD`
`static class` | `Instr.ADIW`
`static class` | `Instr.AND`
`static class` | `Instr.ANDI`
`static class` | `Instr.ASR`
`static class` | `Instr.BCLR`
`static class` | `Instr.BLD`
`static class` | `Instr.BRBC`
`static class` | `Instr.BRBS`
`static class` | `Instr.BRCC`
`static class` | `Instr.BRCS`
`static class` | `Instr.BREAK`
`static class` | `Instr.BREQ`
`static class` | `Instr.BRGE`
`static class` | `Instr.BRHC`
`static class` | `Instr.BRHS`
`static class` | `Instr.BRID`
`static class` | `Instr.BRIE`
`static class` | `Instr.BRLO`
`static class` | `Instr.BRLT`
`static class` | `Instr.BRMI`
`static class` | `Instr.BRNE`
`static class` | `Instr.BRPL`
`static class` | `Instr.BRSH`
`static class` | `Instr.BRTC`
`static class` | `Instr.BRTS`
`static class` | `Instr.BRVC`
`static class` | `Instr.BRVS`
`static class` | `Instr.BSET`
`static class` | `Instr.BST`
`static class` | `Instr.CALL`
`static class` | `Instr.CBI`
`static class` | `Instr.CBR`
`static class` | `Instr.CLC`
`static class` | `Instr.CLH`
`static class` | `Instr.CLI`
`static class` | `Instr.CLN`
`static class` | `Instr.CLR`
`static class` | `Instr.CLS`
`static class` | `Instr.CLT`
`static class` | `Instr.CLV`
`static class` | `Instr.CLZ`
`static class` | `Instr.COM`
`static class` | `Instr.CP`
`static class` | `Instr.CPC`
`static class` | `Instr.CPI`
`static class` | `Instr.CPSE`
`static class` | `Instr.DEC`
`static class` | `Instr.EICALL`
`static class` | `Instr.EIJMP`
`static class` | `Instr.ELPM`
`static class` | `Instr.ELPMD`
`static class` | `Instr.ELPMPI`
`static class` | `Instr.EOR`
`static class` | `Instr.FMUL`
`static class` | `Instr.FMULS`
`static class` | `Instr.FMULSU`
`static class` | `Instr.ICALL`
`static class` | `Instr.IJMP`
`static class` | `Instr.IMM_class`
`static class` | `Instr.ImmediateRequired` The `ImmediateRequired` class represents an error in construction of an instance of `Instr` where the given operand is expected to be an immediate but is not.
`static class` | `Instr.IMMIMM_class`
`static class` | `Instr.IMMREG_class`
`static class` | `Instr.IMMWORD_class`
`static class` | `Instr.IN`
`static class` | `Instr.INC`
`static class` | `Instr.InvalidImmediate` The `InvalidImmediate` class represents an error in construction of an instance of `Instr` where the given immediate operand is not within the range that is specified by the instruction set manual.
`static class` | `Instr.InvalidOperand` The `InvalidOperand` class represents a runtime error thrown by the constructor of an instruction or the `build` method of a prototype when an operand does not meet the restrictions imposed by the AVR instruction set architecture.
`static class` | `Instr.InvalidRegister` The `InvalidRegister` class represents an error in constructing an instance of `Instr` where a register operand does not meet the instruction set specification.
`static class` | `Instr.JMP`
`static class` | `Instr.LD`
`static class` | `Instr.LDD`
`static class` | `Instr.LDI`
`static class` | `Instr.LDPD`
`static class` | `Instr.LDPI`
`static class` | `Instr.LDS`
`static class` | `Instr.LPM`
`static class` | `Instr.LPMD`
`static class` | `Instr.LPMPI`
`static class` | `Instr.LSL`
`static class` | `Instr.LSR`
`static class` | `Instr.MOV`
`static class` | `Instr.MOVW`
`static class` | `Instr.MUL`
`static class` | `Instr.MULS`
`static class` | `Instr.MULSU`
`static class` | `Instr.NEG`
`static class` | `Instr.NONE_class`
`static class` | `Instr.NOP`
`static class` | `Instr.OR`
`static class` | `Instr.ORI`
`static class` | `Instr.OUT`
`static class` | `Instr.POP`
`static class` | `Instr.PUSH`
`static class` | `Instr.RCALL`
`static class` | `Instr.REG_class`
`static class` | `Instr.REGIMM_class`
`static class` | `Instr.REGIMMREG_class`
`static class` | `Instr.RegisterRequired` The `RegisterRequired` class represents an error in construction of an instance of `Instr` where the given operand is expected to be a register but is not.
`static class` | `Instr.REGREG_class` A B S T R A C T C L A S S E S -------------------------------------------------------- These abstract implementations of the instruction simplify the specification of each individual instruction considerably.
`static class` | `Instr.REGREGIMM_class`
`static class` | `Instr.RET`
`static class` | `Instr.RETI`
`static class` | `Instr.RJMP`
`static class` | `Instr.ROL`
`static class` | `Instr.ROR`
`static class` | `Instr.SBC`
`static class` | `Instr.SBCI`
`static class` | `Instr.SBI`
`static class` | `Instr.SBIC`
`static class` | `Instr.SBIS`
`static class` | `Instr.SBIW`
`static class` | `Instr.SBR`
`static class` | `Instr.SBRC`
`static class` | `Instr.SBRS`
`static class` | `Instr.SEC`
`static class` | `Instr.SEH`
`static class` | `Instr.SEI`
`static class` | `Instr.SEN`
`static class` | `Instr.SER`
`static class` | `Instr.SES`
`static class` | `Instr.SET`
`static class` | `Instr.SEV`
`static class` | `Instr.SEZ`
`static class` | `Instr.SLEEP`
`static class` | `Instr.SPM`
`static class` | `Instr.ST`
`static class` | `Instr.STD`
`static class` | `Instr.STPD`
`static class` | `Instr.STPI`
`static class` | `Instr.STS`
`static class` | `Instr.SUB`
`static class` | `Instr.SUBI`
`static class` | `Instr.SWAP`
`static class` | `Instr.TST`
`static class` | `Instr.WDR`
`static class` | `Instr.WORD_class`
`static class` | `Instr.WrongNumberOfOperands` The `WrongNumberOfOperands` class represents a runtime error thrown by the `build` method of a prototype when the wrong number of operands is passed to build an instruction.

Field Summary
`InstrProperties` | `properties`

Constructor Summary
`Instr(InstrProperties ip)`

Method Summary
`abstract void` | `accept(InstrVisitor v)` The `accept()` method is part of the visitor pattern for instructions.
`int` | `getCycles()` The `getCycles()` method returns the number of cylces consumed by the instruction in the default case.
`java.lang.String` | `getName()` The `getName()` method returns the name of the instruction as a string.
`abstract java.lang.String` | `getOperands()` The `getOperands()` method returns a string representation of the operands of the instruction.
`int` | `getSize()` The `getSize()` method returns the size of the instruction in bytes.
`java.lang.String` | `getVariant()` The `getVariant()` method returns the variant name of the instruction as a string.
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface avrora.core.InstrPrototype
`build`

Field Detail

### properties

    public final InstrProperties properties

Constructor Detail

### Instr

    public Instr(InstrProperties ip)

Method Detail

### getOperands

    public abstract java.lang.String getOperands()

  The `getOperands()` method returns a string representation of the operands of the instruction. This is useful for printing and tracing of instructions as well as generating listings.

  Returns:
    a string representing the operands of the instruction

### getVariant

    public java.lang.String getVariant()

  The `getVariant()` method returns the variant name of the instruction as a string. Since instructions like load and store have multiple variants, they each have specific variant names to distinguish them internally in the core of Avrora. For example, for "ld x+, (addr)", the variant is "ldpi" (load with post increment), but the actual instruction is "ld", so this method will return "ldpi".

  Specified by:
    `getVariant` in interface `InstrPrototype`
  Returns:
    the variant of the instruction that this prototype represents

### getSize

    public int getSize()

  The `getSize()` method returns the size of the instruction in bytes.

  Specified by:
    `getSize` in interface `InstrPrototype`
  Returns:
    the size of this instruction in bytes

### getName

    public java.lang.String getName()

  The `getName()` method returns the name of the instruction as a string. For instructions that are variants of instructions, this method returns the actual name of the instruction. For example, for "ld x+, (addr)", the variant is "ldpi" (load with post increment), but the actual instruction is "ld", so this method will return "ld".

  Specified by:
    `getName` in interface `InstrPrototype`
  Returns:
    the name of the instruction

### toString

    public java.lang.String toString()

### getCycles

    public int getCycles()

  The `getCycles()` method returns the number of cylces consumed by the instruction in the default case. Most instructions consume the same amount of clock cycles no matter what behavior. For example, 8-bit arithmetic takes one cycle, load and stores take two cycles, etc. Some instructions like the branch and skip instructions take more cycles if they are taken or not taken. In that case, this count returned is the smallest number of cycles that can be consumed by this instruction.

  Returns:
    the number of cycles that this instruction consumes

### accept

    public abstract void accept(InstrVisitor v)

  The `accept()` method is part of the visitor pattern for instructions. The visitor pattern uses two virtual dispatches combined with memory overloading to achieve dispatching on multiple types. The result is clean and modular code.

  Parameters:
    `v` - the visitor to accept

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD