rubyx/lib/arm/attributed.rb

48 lines
1.1 KiB
Ruby
Raw Normal View History

2016-12-14 12:43:13 +01:00
module Arm
# The arm machine has following instruction classes
# - Memory
# - Stack
# - Logic
# - Math
# - Control/Compare
# - Move
# - Call class Instruction
module Attributed
attr_reader :attributes
def opcode
@attributes[:opcode]
end
def set_opcode code
@attributes[:opcode] = code
end
# for the shift handling that makes the arm so unique
def shift val , by
raise "Not integer #{val}:#{val.class} #{inspect}" unless val.is_a? Fixnum
val << by
end
2016-12-15 11:38:22 +01:00
def condition_code
shift(cond_bit_code , 28 )
end
def instruction_code
shift(instuction_class , 26)
end
2016-12-14 12:43:13 +01:00
def byte_length
4
end
end
end
require_relative "constants"
require_relative "instructions/instruction"
2016-12-14 12:43:13 +01:00
require_relative "instructions/call_instruction"
require_relative "instructions/compare_instruction"
require_relative "instructions/logic_instruction"
require_relative "instructions/memory_instruction"
require_relative "instructions/move_instruction"
require_relative "instructions/stack_instruction"