slightly better name for builder

This commit is contained in:
Torsten Ruger 2014-04-21 00:28:26 +03:00
parent 98a197a0ca
commit 49ee2af8af

View File

@ -80,50 +80,50 @@ module Asm
s = @s ? 1 : 0 s = @s ? 1 : 0
case opcode case opcode
when :adc, :add, :and, :bic, :eor, :orr, :rsb, :rsc, :sbc, :sub when :adc, :add, :and, :bic, :eor, :orr, :rsb, :rsc, :sbc, :sub
a = NormalBuilder.new(OPC_DATA_PROCESSING, OPCODES[opcode], s) builder = NormalBuilder.new(OPC_DATA_PROCESSING, OPCODES[opcode], s)
a.cond = COND_BITS[@cond] builder.cond = COND_BITS[@cond]
a.rd = reg_ref(args[0]) builder.rd = reg_ref(args[0])
a.rn = reg_ref(args[1]) builder.rn = reg_ref(args[1])
a.build_operand args[2] builder.build_operand args[2]
a.write io, as builder.write io, as
when :cmn, :cmp, :teq, :tst when :cmn, :cmp, :teq, :tst
a = NormalBuilder.new(OPC_DATA_PROCESSING, OPCODES[opcode], 1) builder = NormalBuilder.new(OPC_DATA_PROCESSING, OPCODES[opcode], 1)
a.cond = COND_BITS[@cond] builder.cond = COND_BITS[@cond]
a.rn = reg_ref(args[0]) builder.rn = reg_ref(args[0])
a.rd = 0 builder.rd = 0
a.build_operand args[1] builder.build_operand args[1]
a.write io, as builder.write io, as
when :mov, :mvn when :mov, :mvn
a = NormalBuilder.new(OPC_DATA_PROCESSING, OPCODES[opcode], s) builder = NormalBuilder.new(OPC_DATA_PROCESSING, OPCODES[opcode], s)
a.cond = COND_BITS[@cond] builder.cond = COND_BITS[@cond]
a.rn = 0 builder.rn = 0
a.rd = reg_ref(args[0]) builder.rd = reg_ref(args[0])
a.build_operand args[1] builder.build_operand args[1]
a.write io, as builder.write io, as
when :strb, :str when :strb, :str
a = MemoryAccessBuilder.new(OPC_MEMORY_ACCESS, (opcode == :strb ? 1 : 0), 0) builder = MemoryAccessBuilder.new(OPC_MEMORY_ACCESS, (opcode == :strb ? 1 : 0), 0)
a.cond = COND_BITS[@cond] builder.cond = COND_BITS[@cond]
a.rd = reg_ref(args[1]) builder.rd = reg_ref(args[1])
a.build_operand args[0] builder.build_operand args[0]
a.write io, as, @ast_asm, self builder.write io, as, @ast_asm, self
when :ldrb, :ldr when :ldrb, :ldr
a = MemoryAccessBuilder.new(OPC_MEMORY_ACCESS, (opcode == :ldrb ? 1 : 0), 1) builder = MemoryAccessBuilder.new(OPC_MEMORY_ACCESS, (opcode == :ldrb ? 1 : 0), 1)
a.cond = COND_BITS[@cond] builder.cond = COND_BITS[@cond]
a.rd = reg_ref(args[0]) builder.rd = reg_ref(args[0])
a.build_operand args[1] builder.build_operand args[1]
a.write io, as, @ast_asm, self builder.write io, as, @ast_asm, self
when :push, :pop when :push, :pop
# downward growing, decrement before memory access # downward growing, decrement before memory access
# official ARM style stack as used by gas # official ARM style stack as used by gas
if (opcode == :push) if (opcode == :push)
a = StackBuilder.new(1,0,1,0) builder = StackBuilder.new(1,0,1,0)
else else
a = StackBuilder.new(0,1,1,1) builder = StackBuilder.new(0,1,1,1)
end end
a.cond = COND_BITS[@cond] builder.cond = COND_BITS[@cond]
a.rn = 13 # sp builder.rn = 13 # sp
a.build_operand args builder.build_operand args
a.write io, as builder.write io, as
when :b, :bl when :b, :bl
arg = args[0] arg = args[0]
if (arg.is_a?(Asm::NumLiteralArgNode)) if (arg.is_a?(Asm::NumLiteralArgNode))
@ -135,7 +135,10 @@ module Asm
elsif (arg.is_a?(Asm::LabelObject) or arg.is_a?(Asm::LabelRefArgNode)) elsif (arg.is_a?(Asm::LabelObject) or arg.is_a?(Asm::LabelRefArgNode))
arg = @ast_asm.object_for_label(arg.label, self) if arg.is_a?(Asm::LabelRefArgNode) arg = @ast_asm.object_for_label(arg.label, self) if arg.is_a?(Asm::LabelRefArgNode)
as.add_relocation(io.tell, arg, Asm::Arm::R_ARM_PC24, RelocHandler) as.add_relocation(io.tell, arg, Asm::Arm::R_ARM_PC24, RelocHandler)
#write 0 "for now" and let relocation happen
io << "\x00\x00\x00" io << "\x00\x00\x00"
else
raise "else not coded #{arg.inspect}"
end end
io.write_uint8 OPCODES[opcode] | (COND_BITS[@cond] << 4) io.write_uint8 OPCODES[opcode] | (COND_BITS[@cond] << 4)
when :bx when :bx