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 in the `Generator` class.

See Also:
  `InstrVisitor`, `Generator`

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.

Constructor Summary
`Instr()`

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.
`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 gets the variant of the instruction.
`boolean` | `isInstr()` The `isInstr()` method is part of the is/as convention for instructions and data as they are unified in the `Elem` interface.
`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, getName`

Constructor Detail

### Instr

    public Instr()

Method Detail

### isInstr

    public boolean isInstr()

  The `isInstr()` method is part of the is/as convention for instructions and data as they are unified in the `Elem` interface. This convention avoids stupid casts and subtype tests by replacing them with virtual dispatch. In a small world, this is manageable.

  Returns:
    true because this object is an instruction

### 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 gets the variant of the instruction. Since instructions like load and store can have multiple forms, each unique form is a named variant and its own class.

  Specified by:
    `getVariant` in interface `InstrPrototype`
  Returns:
    the name of this variant

### 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

### 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