Documentation ¶
Index ¶
- Constants
- Variables
- func ASR(regs *Registers, value uint32, shift_n uint8, setflags SetFlags) uint32
- func ASR_C(value uint32, amount uint8) (uint32, bool)
- func AddImmediate(regs *Registers, instr InstrFields)
- func AddRegister(regs *Registers, instr InstrFields, shift Shift)
- func AddWithCarry(x uint32, y uint32, carry_in uint8) (uint32, uint8, uint8)
- func LSL(regs *Registers, value uint32, shift_n uint8, setflags SetFlags) uint32
- func LSL_C(value uint32, amount uint8) (uint32, bool)
- func LSR(regs *Registers, value uint32, shift_n uint8, setflags SetFlags) uint32
- func LSR_C(value uint32, amount uint8) (uint32, bool)
- func MoveRegister(regs *Registers, dest RegIndex, source RegIndex, setflags SetFlags, carry bool)
- func MoveValue(regs *Registers, dest RegIndex, value uint32, setflags SetFlags, carry bool)
- func ShiftOp(regs *Registers, value uint32, shift_n uint8, setflags SetFlags, ...) uint32
- func SubRegister(regs *Registers, instr InstrFields, shift Shift)
- type AddImmT1
- type AddImmT2
- type AddRegSPT1
- type AddRegSPT2
- type AddRegT1
- type AddRegT2
- type Apsr
- type AsrImm
- type Control
- type DecodeFunc
- type DecodedInstr
- func AddImm16T1(instr FetchedInstr) DecodedInstr
- func AddImm16T2(instr FetchedInstr) DecodedInstr
- func AddReg16T1(instr FetchedInstr) DecodedInstr
- func AddReg16T2(instr FetchedInstr) DecodedInstr
- func AddRegSP16T1(instr FetchedInstr) DecodedInstr
- func AddRegSP16T2(instr FetchedInstr) DecodedInstr
- func AsrImm16(instr FetchedInstr) DecodedInstr
- func LslImm16(instr FetchedInstr) DecodedInstr
- func LslReg16(instr FetchedInstr) DecodedInstr
- func LsrImm16(instr FetchedInstr) DecodedInstr
- func LsrReg16(instr FetchedInstr) DecodedInstr
- func MovImm16(instr FetchedInstr) DecodedInstr
- func MovReg16T1(instr FetchedInstr) DecodedInstr
- func MovReg16T2(instr FetchedInstr) DecodedInstr
- func SubReg16T1(instr FetchedInstr) DecodedInstr
- type Epsr
- type FetchedInstr
- type FetchedInstr16
- type FetchedInstr32
- type GeneralRegs
- type InstrFields
- type Ipsr
- type LslImm
- type LslReg
- type LsrImm
- type LsrReg
- type Mode
- type MovImm
- type MovRegT1
- type MovRegT2
- type Opcode
- type RegIndex
- type Registers
- func (regs *Registers) ALUWritePC(addr uint32)
- func (regs *Registers) BranchTo(addr uint32)
- func (regs *Registers) BranchWritePC(addr uint32)
- func (regs Registers) InITBlock() bool
- func (regs Registers) LastInITBlock() bool
- func (regs Registers) LookupSP() SPType
- func (regs Registers) Lr() uint32
- func (regs Registers) Msp() uint32
- func (regs Registers) Pc() uint32
- func (regs Registers) Pretty() string
- func (regs Registers) Print()
- func (regs Registers) Psp() uint32
- func (regs Registers) R(i RegIndex) uint32
- func (regs *Registers) SetR(i RegIndex, value uint32)
- func (regs Registers) Sp() uint32
- type SPRegs
- type SPType
- type SetFlags
- type Shift
- type ShiftFunc
- type SubRegT1
- type UndefinedInstr
- type UnpredictableInstr
Constants ¶
const ( WORD_INSTR_MASK = 0xf800 WORD_INSTR1 = 0xe800 WORD_INSTR2 = 0xf000 WORD_INSTR3 = 0xf800 )
If bits [15:11] of the instruction being decoded are any of * the following WORD_INSTR, then the instruction is the first * halfword of a 32-bit instruction. * ARMv7-M ARM A5.1
Variables ¶
var ErrIncompleteInstruction = errors.New("Only first halfword of word instruction decoded.")
var ErrUndefinedInstruction = errors.New("Instruction not defined.")
var InstrOpcodes16 = map[Opcode]DecodeFunc{ Opcode{mask: 0xf800, value: 0x0000}: LslImm16, Opcode{mask: 0xffc0, value: 0x4080}: LslReg16, Opcode{mask: 0xf800, value: 0x0800}: LsrImm16, Opcode{mask: 0xffc0, value: 0x40c0}: LsrReg16, Opcode{mask: 0xf800, value: 0x1000}: AsrImm16, Opcode{mask: 0xf800, value: 0x2000}: MovImm16, Opcode{mask: 0xff00, value: 0x4600}: MovReg16T1, Opcode{mask: 0xffc0, value: 0x0000}: MovReg16T2, Opcode{mask: 0xfe00, value: 0x1800}: AddReg16T1, Opcode{mask: 0xff00, value: 0x4400}: AddReg16T2, Opcode{mask: 0xff78, value: 0x4468}: AddRegSP16T1, Opcode{mask: 0xff87, value: 0x4485}: AddRegSP16T2, Opcode{mask: 0xfe00, value: 0x1a00}: SubReg16T1, Opcode{mask: 0xfe00, value: 0x1c00}: AddImm16T1, Opcode{mask: 0xf800, value: 0x3000}: AddImm16T2, }
var InstrOpcodes32 = map[Opcode]DecodeFunc{}
Functions ¶
func AddImmediate ¶
func AddImmediate(regs *Registers, instr InstrFields)
Perform addition instruction (imm), updating condition codes
func AddRegister ¶
func AddRegister(regs *Registers, instr InstrFields, shift Shift)
Perform addition instruction (reg), with shift, updating condition codes
func AddWithCarry ¶
Perform actual addition operation, determining carry out and overflow
func MoveRegister ¶
func ShiftOp ¶
func ShiftOp(regs *Registers, value uint32, shift_n uint8, setflags SetFlags, do_shift ShiftFunc) uint32
Perform shift operation, updating condition codes
func SubRegister ¶
func SubRegister(regs *Registers, instr InstrFields, shift Shift)
Perform subtraction instruction (reg), with shift, updating condition codes
Types ¶
type AddRegSPT1 ¶
type AddRegSPT1 InstrFields
ADD (SP plus register) * ARM ARM A7.7.6 * Encoding T1
func (AddRegSPT1) Execute ¶
func (instr AddRegSPT1) Execute(regs *Registers)
func (AddRegSPT1) String ¶
func (instr AddRegSPT1) String() string
type AddRegSPT2 ¶
type AddRegSPT2 InstrFields
ADD (SP plus register) * ARM ARM A7.7.6 * Encoding T2
func (AddRegSPT2) Execute ¶
func (instr AddRegSPT2) Execute(regs *Registers)
func (AddRegSPT2) String ¶
func (instr AddRegSPT2) String() string
type DecodeFunc ¶
type DecodeFunc func(FetchedInstr) DecodedInstr
type DecodedInstr ¶
type DecodedInstr interface {
Execute(*Registers)
}
func AddImm16T1 ¶
func AddImm16T1(instr FetchedInstr) DecodedInstr
func AddImm16T2 ¶
func AddImm16T2(instr FetchedInstr) DecodedInstr
func AddReg16T1 ¶
func AddReg16T1(instr FetchedInstr) DecodedInstr
func AddReg16T2 ¶
func AddReg16T2(instr FetchedInstr) DecodedInstr
func AddRegSP16T1 ¶
func AddRegSP16T1(instr FetchedInstr) DecodedInstr
func AddRegSP16T2 ¶
func AddRegSP16T2(instr FetchedInstr) DecodedInstr
func AsrImm16 ¶
func AsrImm16(instr FetchedInstr) DecodedInstr
func LslImm16 ¶
func LslImm16(instr FetchedInstr) DecodedInstr
func LslReg16 ¶
func LslReg16(instr FetchedInstr) DecodedInstr
func LsrImm16 ¶
func LsrImm16(instr FetchedInstr) DecodedInstr
func LsrReg16 ¶
func LsrReg16(instr FetchedInstr) DecodedInstr
func MovImm16 ¶
func MovImm16(instr FetchedInstr) DecodedInstr
func MovReg16T1 ¶
func MovReg16T1(instr FetchedInstr) DecodedInstr
func MovReg16T2 ¶
func MovReg16T2(instr FetchedInstr) DecodedInstr
func SubReg16T1 ¶
func SubReg16T1(instr FetchedInstr) DecodedInstr
type FetchedInstr ¶
type FetchedInstr interface { Decode() (DecodedInstr, error) String() string Uint32() uint32 }
type FetchedInstr16 ¶
type FetchedInstr16 uint16
func (FetchedInstr16) Decode ¶
func (instr FetchedInstr16) Decode() (DecodedInstr, error)
func (FetchedInstr16) Extend ¶
func (upper FetchedInstr16) Extend(lower FetchedInstr16) FetchedInstr32
Extend upper halfword of instruction with lower halfword to make 32-bit instruction
func (FetchedInstr16) String ¶
func (instr FetchedInstr16) String() string
func (FetchedInstr16) Uint32 ¶
func (instr FetchedInstr16) Uint32() uint32
type FetchedInstr32 ¶
type FetchedInstr32 uint32
func (FetchedInstr32) Decode ¶
func (instr FetchedInstr32) Decode() (DecodedInstr, error)
func (FetchedInstr32) String ¶
func (instr FetchedInstr32) String() string
func (FetchedInstr32) Uint32 ¶
func (instr FetchedInstr32) Uint32() uint32
type GeneralRegs ¶
type GeneralRegs [13]uint32
type InstrFields ¶
type Opcode ¶
type Opcode struct {
// contains filtered or unexported fields
}
func (*Opcode) Match ¶
func (op *Opcode) Match(instr FetchedInstr) bool
type Registers ¶
type Registers struct { Apsr Apsr Ipsr Ipsr Epsr Epsr Mode Mode Primask bool Faultmask bool Basepri uint8 Control Control // contains filtered or unexported fields }
func (*Registers) ALUWritePC ¶
func (*Registers) BranchWritePC ¶
func (Registers) LastInITBlock ¶
type ShiftFunc ¶
Generic shifting function * * @param value uint32 Value to shift * @param amount uint8 Amount to shift by * * @return result uint32 Result of shift * @return carry bool Carry out of shift
type UndefinedInstr ¶
type UndefinedInstr InstrFields
func (UndefinedInstr) Execute ¶
func (instr UndefinedInstr) Execute(regs *Registers)
Placeholder UNDEFINED instruction
type UnpredictableInstr ¶
type UnpredictableInstr InstrFields
func (UnpredictableInstr) Execute ¶
func (instr UnpredictableInstr) Execute(regs *Registers)
Case to execute in the event of UNPREDICTABLE instruction behavior