clean up intruction instantiation and fix tests
This commit is contained in:
@ -5,31 +5,10 @@ require_relative "move_instruction"
|
||||
require_relative "compare_instruction"
|
||||
require_relative "memory_instruction"
|
||||
require_relative "call_instruction"
|
||||
require_relative "constants"
|
||||
|
||||
module Arm
|
||||
class ArmMachine < Vm::CMachine
|
||||
|
||||
# defines a method in the current class, with the name inst (first erg)
|
||||
# the method instantiates an instruction of the given class which gets passed a single hash as arg
|
||||
|
||||
# gets called for every "standard" instruction.
|
||||
# may be used for machine specific ones too
|
||||
def define_instruction inst , clazz
|
||||
super
|
||||
return
|
||||
# need to use create_method and move to attributes hash
|
||||
define_method("#{inst}s") do |*args|
|
||||
instruction clazz , inst , :al , 1 , *args
|
||||
end
|
||||
ArmMachine::COND_CODES.keys.each do |suffix|
|
||||
define_method("#{inst}#{suffix}") do |attributes|
|
||||
instruction clazz , inst , suffix , 0 , *args
|
||||
end
|
||||
define_method("#{inst}s#{suffix}") do |attributes|
|
||||
instruction clazz , inst , suffix , 1 , *args
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def integer_less_or_equal block , left , right
|
||||
block.add_code cmp(:left => left , :right => right )
|
||||
|
Reference in New Issue
Block a user