finally cleaned up those pestey parse errors
This commit is contained in:
parent
ceefa05b2f
commit
f4299de120
@ -1,7 +1,5 @@
|
||||
|
||||
module Asm
|
||||
ERRSTR_NUMERIC_TOO_LARGE = 'cannot fit numeric literal argument in operand'
|
||||
ERRSTR_INVALID_ARG = 'invalid operand argument'
|
||||
|
||||
class Assembler
|
||||
def initialize
|
||||
|
@ -1,12 +1,8 @@
|
||||
module Asm
|
||||
class AssemblyError < StandardError
|
||||
def initialize(message, node)
|
||||
def initialize(message)
|
||||
super(message)
|
||||
|
||||
@node = node
|
||||
end
|
||||
attr_reader :node
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -116,10 +116,10 @@ module Asm
|
||||
io << packed
|
||||
io.write_uint8 0b1111 | (COND_CODES[@cond] << 4)
|
||||
else
|
||||
raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG, arg)
|
||||
raise Asm::AssemblyError.new("invalid operand argument expected literal not #{arg}")
|
||||
end
|
||||
else
|
||||
raise Asm::AssemblyError.new("unknown instruction #{opcode}", self)
|
||||
raise Asm::AssemblyError.new("unknown instruction #{opcode} #{self}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -37,7 +37,7 @@ module Asm
|
||||
|
||||
def reg_ref(arg)
|
||||
if (not arg.is_a?(Asm::Register))
|
||||
raise Asm::AssemblyError.new('argument must be a register', arg)
|
||||
raise Asm::AssemblyError.new("argument must be a register not #{arg}")
|
||||
end
|
||||
|
||||
ref =
|
||||
@ -49,7 +49,7 @@ module Asm
|
||||
'lr' => 14, 'pc' => 15}[arg.name.downcase]
|
||||
|
||||
if (not ref)
|
||||
raise Asm::AssemblyError.new('unknown register %s' % arg.name.downcase, arg)
|
||||
raise Asm::AssemblyError.new("unknown register #{arg}")
|
||||
end
|
||||
|
||||
ref
|
||||
|
@ -44,7 +44,7 @@ module Asm
|
||||
@add_offset = 1
|
||||
end
|
||||
if (@operand.abs > 4095)
|
||||
raise Asm::AssemblyError.new('reference offset too large/small (max 4095)', argr.right)
|
||||
raise Asm::AssemblyError.new("reference offset too large/small (max 4095) #{argr.right}" )
|
||||
end
|
||||
end
|
||||
elsif (arg.is_a?(Asm::Label) or arg.is_a?(Asm::NumLiteral))
|
||||
@ -53,7 +53,7 @@ module Asm
|
||||
@use_addrtable_reloc = true
|
||||
@addrtable_reloc_target = arg
|
||||
else
|
||||
raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG + " " + arg.inspect, arg.inspect)
|
||||
raise Asm::AssemblyError.new("invalid operand argument #{arg.inspect}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,7 +59,7 @@ module Asm
|
||||
@operand = op_with_rot
|
||||
@i = 1
|
||||
else
|
||||
raise Asm::AssemblyError.new(Asm::ERRSTR_NUMERIC_TOO_LARGE, arg)
|
||||
raise Asm::AssemblyError.new("cannot fit numeric literal argument in operand #{arg}")
|
||||
end
|
||||
elsif (arg.is_a?(Asm::Register))
|
||||
@operand = reg_ref(arg)
|
||||
@ -89,7 +89,7 @@ module Asm
|
||||
|
||||
@operand = rm_ref | (shift_op << 4) | (shift_imm << 4+3)
|
||||
else
|
||||
raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG + " " + arg.inspect, arg)
|
||||
raise Asm::AssemblyError.new("invalid operand argument #{arg.inspect}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ module Asm
|
||||
@operand |= (1 << reg)
|
||||
end
|
||||
else
|
||||
raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG + " " + arg.inspect , arg)
|
||||
raise Asm::AssemblyError.new("invalid operand argument #{arg.inspect}")
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user