diff --git a/lib/asm/arm/builder_b.rb b/lib/asm/arm/builder_b.rb index 520dc7fa..c6037a2c 100644 --- a/lib/asm/arm/builder_b.rb +++ b/lib/asm/arm/builder_b.rb @@ -87,7 +87,8 @@ module Asm @use_addrtable_reloc = true @addrtable_reloc_target = arg1 else - raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG, arg1) + puts "Invalid #{arg1.inspect}" + raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG, arg1.inspect) end end diff --git a/lib/asm/arm/code_generator.rb b/lib/asm/arm/code_generator.rb index 885a8dfa..449bc71a 100644 --- a/lib/asm/arm/code_generator.rb +++ b/lib/asm/arm/code_generator.rb @@ -33,18 +33,12 @@ class Asm::Arm::CodeGenerator args.each { |arg| if (arg.is_a?(Array)) if (arg[0] == :reg) - node.args << Asm::RegisterArgNode.new { |n| - n.name = arg[1] - } + node.args << Asm::RegisterArgNode.new(arg[1]) end elsif (arg.is_a?(Integer)) - node.args << Asm::NumLiteralArgNode.new { |n| - n.value = arg - } + node.args << Asm::NumLiteralArgNode.new(arg) elsif (arg.is_a?(Symbol)) - node.args << Asm::LabelRefArgNode.new { |n| - n.label = arg.to_s - } + node.args << Asm::LabelRefArgNode.new(arg.to_s) elsif (arg.is_a?(Asm::Arm::GeneratorLabel) or arg.is_a?(Asm::Arm::GeneratorExternLabel)) node.args << arg else @@ -55,7 +49,7 @@ class Asm::Arm::CodeGenerator @asm.add_object Asm::Arm::Instruction.new(node) end - %w(adc add and bic eor orr rsb rsc sbc sub mov mvn cmn cmp teq tst b bl bx swi strb + %w(adc add and bic eor orr rsb rsc sbc sub mov mvn cmn cmp teq tst b bl bx swi str strb ldr ldrb ).each { |inst| define_method(inst) { |*args| instruction inst.to_sym, *args diff --git a/lib/asm/nodes.rb b/lib/asm/nodes.rb index 847c1ed4..14fe2344 100644 --- a/lib/asm/nodes.rb +++ b/lib/asm/nodes.rb @@ -37,6 +37,9 @@ module Asm class RegisterArgNode < ArgNode attr_accessor :name + def initialize name + @name = name + end end class RegisterListArgNode < ArgNode @@ -45,18 +48,28 @@ module Asm class NumLiteralArgNode < ArgNode attr_accessor :value + def initialize val + @value = val + end end class NumEquivAddrArgNode < NumLiteralArgNode end class LabelRefArgNode < ArgNode attr_accessor :label, :label_object + def initialize label , object = nil + @label = label + @label_object = object + end end class LabelEquivAddrArgNode < LabelRefArgNode end class ReferenceArgNode < ArgNode attr_accessor :argument + def initilize arg + @argument = arg + end end class ParseError < StandardError