class Ronin::ASM::Syntax::Common
Abstract base-class for all Assembly Syntax
classes.
Constants
- BITS
Bit sizes for various architectures
Public Class Methods
Emits a floating point number.
@param [Float] value
The number.
@return [String]
The formatted float.
@abstract
# File lib/ronin/asm/syntax/common.rb, line 92 def self.emit_float(value) end
Emits an immediate operand.
@param [ImmediateOperand] op
The immediate operand.
@return [String]
The formatted immediate operand.
@abstract
# File lib/ronin/asm/syntax/common.rb, line 106 def self.emit_immediate_operand(op) end
Emits an instruction.
@param [Instruction] ins
The instruction.
@return [String]
The formatted instruction.
@abstract
# File lib/ronin/asm/syntax/common.rb, line 178 def self.emit_instruction(ins) end
Emits an integer.
@param [Integer] value
The integer.
@return [String]
The formatted integer.
# File lib/ronin/asm/syntax/common.rb, line 75 def self.emit_integer(value) if value >= 0 then "0x%x" % value else "-0x%x" % value.abs end end
Emits a keyword.
@param [Symbol] name
Name of the keyword.
@return [String]
The formatted keyword.
# File lib/ronin/asm/syntax/common.rb, line 49 def self.emit_keyword(name) name.to_s end
Emits a label.
@param [Symbol] name
The name of the label.
@return [String]
The formatted label.
# File lib/ronin/asm/syntax/common.rb, line 163 def self.emit_label(name) "#{name}:" end
Emits an memory operand.
@param [MemoryOperand] op
The memory operand.
@return [String]
The formatted memory operand.
@abstract
# File lib/ronin/asm/syntax/common.rb, line 120 def self.emit_memory_operand(op) end
Emits an operand.
@param [ImmediateOperand, MemoryOperand
, Register
, Symbol] op
The operand.
@return [String]
The formatted operand.
# File lib/ronin/asm/syntax/common.rb, line 132 def self.emit_operand(op) case op when ImmediateOperand then emit_immediate_operand(op) when MemoryOperand then emit_memory_operand(op) when Register then emit_register(op) when Symbol then emit_keyword(op) end end
Emits multiple operands.
@param [Array<ImmediateOperand, MemoryOperand
, Register
, Symbol>] ops
The Array of operands.
@return [String]
The formatted operands.
# File lib/ronin/asm/syntax/common.rb, line 150 def self.emit_operands(ops) ops.map { |op| emit_operand(op) }.join(",\t") end
Emits a program.
@param [Program] program
The program.
@return [String]
The formatted program.
# File lib/ronin/asm/syntax/common.rb, line 218 def self.emit_program(program) lines = [ emit_prologue(program), emit_section(:text), emit_label(:_start) ].compact program.instructions.each do |ins| case ins when Symbol then lines << emit_label(ins) when Instruction then lines << "\t#{emit_instruction(ins)}" end end lines << '' return lines.join($/) end
Emits the program’s prologue.
@param [Program] program
The program.
@return [String]
The formatted prologue.
@since 0.2.0
# File lib/ronin/asm/syntax/common.rb, line 206 def self.emit_prologue(program) end
Emits a register.
@param [Register] reg
@return [String]
The formatted register.
@abstract
# File lib/ronin/asm/syntax/common.rb, line 63 def self.emit_register(reg) end
Emits a section name.
@param [Symbol] name
The section name.
@return [String]
The formatted section name.
@since 0.2.0
# File lib/ronin/asm/syntax/common.rb, line 192 def self.emit_section(name) end