Module: Indis::ARM::InstructionHelper

Extended by:
PseudoCodeInstructionHelper
Defined in:
lib/indis-arm/instruction_helper.rb

Constant Summary collapse

COND =
[".EQ", ".NE", ".CS", ".CC", ".MI", ".PL", ".VS", ".VC", ".HI", ".LS", ".GE", ".LT", ".GT", ".LE", ""]
COND_SYM =
[:eq, :ne, :cs, :cc, :mi, :pl, :vs, :vc, :hi, :ls, :ge, :lt, :gt, :le, :al]
NAMED_REG =
{ r13: :sp, r14: :lr, r15: :pc }
REG =
[:r0, :r1, :r2, :r3, :r4, :r5, :r6, :r7, :r8, :r9, :r10, :r11, :r12, :r13, :r14, :r15]
SHIFT_TYPES =
{
  SRType_LSL: :lsl,
  SRType_LSR: :lsr,
  SRType_ASR: :asr,
  SRType_ROR: :ror,
  SRType_RRX: :rrx,
}

Class Method Summary collapse

Methods included from PseudoCodeInstructionHelper

ARMExpandImm, ARMExpandImm_C, DecodeImmShift, LSL, LSL_C, LSR, LSR_C, ROR_C, Shift_C, SignExtend, ZeroExtend

Class Method Details

.cond(i) ⇒ Object



148
149
150
# File 'lib/indis-arm/instruction_helper.rb', line 148

def cond(i)
  COND_SYM[i]
end

.cond_to_s(cond) ⇒ Object



130
131
132
# File 'lib/indis-arm/instruction_helper.rb', line 130

def cond_to_s(cond)
  ('.' + cond.to_s.upcase).sub('.AL', '')
end

.flag(f, fn) ⇒ Object



139
140
141
# File 'lib/indis-arm/instruction_helper.rb', line 139

def flag(f, fn)
  f ? fn : ''
end

.reg(i) ⇒ Object



143
144
145
146
# File 'lib/indis-arm/instruction_helper.rb', line 143

def reg(i)
  r = REG[i]
  NAMED_REG[r] || r
end

.regs_from_bits(bits_list) ⇒ Object



115
116
117
118
119
120
121
122
123
124
# File 'lib/indis-arm/instruction_helper.rb', line 115

def regs_from_bits(bits_list)
  bl = bits_list.to_s(2)
  bl = ('0'*(16-bl.length)) + bl
  regs = []
  bl.reverse! # XXX so that r0 is bit 0
  bl.length.times do |i| 
    regs << "r#{i}".to_sym if bl[i] == '1'
  end
  regs
end

.regs_to_s(regs) ⇒ Object



134
135
136
137
# File 'lib/indis-arm/instruction_helper.rb', line 134

def regs_to_s(regs)
  regs = regs.map { |r| NAMED_REG[r] || r }
  regs.join(', ')
end

.shift_type_to_s(shift) ⇒ Object



126
127
128
# File 'lib/indis-arm/instruction_helper.rb', line 126

def shift_type_to_s(shift)
  SHIFT_TYPES[shift]
end