Class: Ronin::Code::ASM::Syntax::Common
- Inherits:
-
Object
- Object
- Ronin::Code::ASM::Syntax::Common
- Defined in:
- lib/ronin/code/asm/syntax/common.rb
Overview
Abstract base-class for all Assembly Syntax classes.
Constant Summary collapse
- BITS =
Bit sizes for various architectures
{ x86: 32, amd64: 64, }
Class Method Summary collapse
-
.emit_float(value) ⇒ String
abstract
Emits a floating point number.
-
.emit_immediate_operand(op) ⇒ String
abstract
Emits an immediate operand.
-
.emit_instruction(ins) ⇒ String
abstract
Emits an instruction.
-
.emit_integer(value) ⇒ String
Emits an integer.
-
.emit_keyword(name) ⇒ String
Emits a keyword.
-
.emit_label(name) ⇒ String
Emits a label.
-
.emit_memory_operand(op) ⇒ String
abstract
Emits an memory operand.
-
.emit_operand(op) ⇒ String
Emits an operand.
-
.emit_operands(ops) ⇒ String
Emits multiple operands.
-
.emit_program(program) ⇒ String
Emits a program.
-
.emit_prologue(program) ⇒ String
Emits the program's prologue.
-
.emit_register(reg) ⇒ String
abstract
Emits a register.
-
.emit_section(name) ⇒ String
Emits a section name.
Class Method Details
.emit_float(value) ⇒ String
This method is abstract.
Emits a floating point number.
92 93 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 92 def self.emit_float(value) end |
.emit_immediate_operand(op) ⇒ String
This method is abstract.
Emits an immediate operand.
106 107 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 106 def self.emit_immediate_operand(op) end |
.emit_instruction(ins) ⇒ String
This method is abstract.
Emits an instruction.
178 179 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 178 def self.emit_instruction(ins) end |
.emit_integer(value) ⇒ String
Emits an integer.
75 76 77 78 79 |
# File 'lib/ronin/code/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 |
.emit_keyword(name) ⇒ String
Emits a keyword.
49 50 51 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 49 def self.emit_keyword(name) name.to_s end |
.emit_label(name) ⇒ String
Emits a label.
163 164 165 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 163 def self.emit_label(name) "#{name}:" end |
.emit_memory_operand(op) ⇒ String
This method is abstract.
Emits an memory operand.
120 121 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 120 def self.emit_memory_operand(op) end |
.emit_operand(op) ⇒ String
Emits an operand.
132 133 134 135 136 137 138 139 |
# File 'lib/ronin/code/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 |
.emit_operands(ops) ⇒ String
Emits multiple operands.
150 151 152 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 150 def self.emit_operands(ops) ops.map { |op| emit_operand(op) }.join(",\t") end |
.emit_program(program) ⇒ String
Emits a program.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/ronin/code/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 |
.emit_prologue(program) ⇒ String
Emits the program's prologue.
206 207 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 206 def self.emit_prologue(program) end |
.emit_register(reg) ⇒ String
This method is abstract.
Emits a register.
63 64 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 63 def self.emit_register(reg) end |
.emit_section(name) ⇒ String
Emits a section name.
192 193 |
# File 'lib/ronin/code/asm/syntax/common.rb', line 192 def self.emit_section(name) end |