Module: Indis::ARM::PseudoCodeInstructionHelper
- Included in:
- InstructionHelper
- Defined in:
- lib/indis-arm/instruction_helper.rb
Instance Method Summary collapse
-
#ARMExpandImm(bits_imm12) ⇒ Object
A5.2.4.
-
#ARMExpandImm_C(bits_imm12, carry_in) ⇒ Object
A5.2.4.
- #DecodeImmShift(bits2_type, bits5_imm5) ⇒ Object
-
#LSL(bits_x, shift) ⇒ Object
A2.2.1.
-
#LSL_C(bits_x, shift) ⇒ Object
A2.2.1.
-
#LSR(bits_x, shift) ⇒ Object
A2.2.1.
-
#LSR_C(bits_x, shift) ⇒ Object
A2.2.1.
-
#ROR_C(bits_x, shift) ⇒ Object
A2.2.1.
-
#Shift_C(bits_value, type, amount, carry_in) ⇒ Object
A8.4.3.
-
#SignExtend(bits_x, i) ⇒ Object
P5.3.
-
#ZeroExtend(bits_x, i) ⇒ Object
P5.3.
Instance Method Details
#ARMExpandImm(bits_imm12) ⇒ Object
A5.2.4
24 25 26 |
# File 'lib/indis-arm/instruction_helper.rb', line 24 def ARMExpandImm(bits_imm12) # A5.2.4 ARMExpandImm_C(bits_imm12, 0)[0] # FIXME APSR.C ??? end |
#ARMExpandImm_C(bits_imm12, carry_in) ⇒ Object
A5.2.4
28 29 30 31 |
# File 'lib/indis-arm/instruction_helper.rb', line 28 def ARMExpandImm_C(bits_imm12, carry_in) # A5.2.4 unrotated_value = bits_imm12.bits(7, 0).zero_extend(32) Shift_C(unrotated_value, :SRType_ROR, 2*(bits_imm12.bits(11, 8).to_i), carry_in) end |
#DecodeImmShift(bits2_type, bits5_imm5) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/indis-arm/instruction_helper.rb', line 33 def DecodeImmShift(bits2_type, bits5_imm5) imm = bits5_imm5.to_i case bits2_type.to_i when 0b00 [:SRType_LSL, imm] when 0b01 [:SRType_LSR, imm == 0 ? 32 : imm] when 0b10 [:SRType_ASR, imm == 0 ? 32 : imm] when 0b11 imm == 0 ? [:SRType_RRX, 1] : [:SRType_ROR, imm] end end |
#LSL(bits_x, shift) ⇒ Object
A2.2.1
90 91 92 93 |
# File 'lib/indis-arm/instruction_helper.rb', line 90 def LSL(bits_x, shift) # A2.2.1 raise ArgumentError unless shift >= 0 bits_x << shift end |
#LSL_C(bits_x, shift) ⇒ Object
A2.2.1
95 96 97 98 |
# File 'lib/indis-arm/instruction_helper.rb', line 95 def LSL_C(bits_x, shift) # A2.2.1 raise ArgumentError unless shift > 0 [bits_x << shift, bits_x.bit(shift)] end |
#LSR(bits_x, shift) ⇒ Object
A2.2.1
80 81 82 83 |
# File 'lib/indis-arm/instruction_helper.rb', line 80 def LSR(bits_x, shift) # A2.2.1 raise ArgumentError unless shift >= 0 bits_x >> shift end |
#LSR_C(bits_x, shift) ⇒ Object
A2.2.1
85 86 87 88 |
# File 'lib/indis-arm/instruction_helper.rb', line 85 def LSR_C(bits_x, shift) # A2.2.1 raise ArgumentError unless shift > 0 [bits_x >> shift, bits_x.bit(shift-1)] end |
#ROR_C(bits_x, shift) ⇒ Object
A2.2.1
74 75 76 77 78 |
# File 'lib/indis-arm/instruction_helper.rb', line 74 def ROR_C(bits_x, shift) # A2.2.1 raise ArgumentError unless shift != 0 [bits_x.ror(shift), bits_x.rbit(0)] end |
#Shift_C(bits_value, type, amount, carry_in) ⇒ Object
A8.4.3
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/indis-arm/instruction_helper.rb', line 55 def Shift_C(bits_value, type, amount, carry_in) # A8.4.3 raise ArgumentError unless !(type == :SRType_RRX && amount != 1) return [bits_value, carry_in] if amount == 0 case type when :SRType_LSL LSL_C(bits_value, amount) when :SRType_LSR LSR_C(bits_value, amount) when :SRType_ASR ASR_C(bits_value, amount) when :SRType_ROR ROR_C(bits_value, amount) when :SRType_RRX RRX_C(bits_value, carry_in) end end |
#SignExtend(bits_x, i) ⇒ Object
P5.3
51 52 53 |
# File 'lib/indis-arm/instruction_helper.rb', line 51 def SignExtend(bits_x, i) # P5.3 bits_x.sign_extend(i) end |
#ZeroExtend(bits_x, i) ⇒ Object
P5.3
47 48 49 |
# File 'lib/indis-arm/instruction_helper.rb', line 47 def ZeroExtend(bits_x, i) # P5.3 bits_x.zero_extend(i) end |