2018-03-26 19:04:39 +02:00
|
|
|
require "util/list"
|
|
|
|
module Arm
|
|
|
|
# Arm instruction base class
|
|
|
|
# Mostly linked list functionality that all instructions have
|
|
|
|
class Instruction
|
|
|
|
include Constants
|
|
|
|
include Attributed
|
|
|
|
include Util::List
|
|
|
|
|
|
|
|
def initialize( source , nekst = nil )
|
|
|
|
@source = source
|
|
|
|
@next = nekst
|
|
|
|
return unless source
|
|
|
|
raise "Source must be string or Instruction, not #{source.class}" unless source.is_a?(String) or source.is_a?(Mom::Instruction)
|
|
|
|
end
|
|
|
|
attr_reader :source
|
|
|
|
|
|
|
|
def total_byte_length
|
|
|
|
ret = 0
|
|
|
|
self.each{|ins| ret += ins.byte_length}
|
|
|
|
ret
|
|
|
|
end
|
|
|
|
|
2018-05-05 22:55:50 +02:00
|
|
|
def insert(instruction)
|
|
|
|
super
|
2018-05-06 19:04:02 +02:00
|
|
|
my_pos = Risc::Position.get(self)
|
2018-05-08 19:53:48 +02:00
|
|
|
# set my position to set next according to rules
|
2018-06-02 20:59:41 +02:00
|
|
|
Risc::InstructionListener.init(instruction , my_pos.get_code)
|
2018-05-05 22:55:50 +02:00
|
|
|
end
|
2018-03-26 19:04:39 +02:00
|
|
|
end
|
|
|
|
end
|