makes memory a three operand instruction, like add etc. But 3 regs are still undone

This commit is contained in:
Torsten Ruger
2014-06-01 21:20:44 +03:00
parent 08bbad0fdc
commit 31a55b07ac
4 changed files with 24 additions and 17 deletions

View File

@@ -49,8 +49,10 @@ module Vm
end
end
class MemoryInstruction < Instruction
def initialize first , options = {}
@first = first
def initialize result , left , right = nil , options = {}
@result = result
@left = left
@right = right
super(options)
end
end

View File

@@ -57,7 +57,7 @@ module Vm
define_instruction_two(inst , CompareInstruction)
end
[:strb, :str , :ldrb, :ldr].each do |inst|
define_instruction_one(inst , MemoryInstruction)
define_instruction_three(inst , MemoryInstruction)
end
[:b, :call , :swi].each do |inst|
define_instruction_one(inst , CallInstruction)
@@ -126,7 +126,7 @@ module Vm
# same for three args (result = left right,)
def define_instruction_three(inst , clazz , defaults = {} )
clazz = self.class_for(clazz)
create_method(inst) do |result , left ,right , options = nil|
create_method(inst) do |result , left ,right = nil , options = nil|
options = {} if options == nil
options.merge defaults
options[:opcode] = inst