lib/ronin/asm/syntax/common.rb in ronin-asm-0.1.0 vs lib/ronin/asm/syntax/common.rb in ronin-asm-0.2.0

- old
+ new

@@ -1,9 +1,9 @@ # # Ronin ASM - A Ruby DSL for crafting Assembly programs and Shellcode. # -# Copyright (c) 2007-2012 Hal Brodigan (postmodern.mod3 at gmail.com) +# Copyright (c) 2007-2013 Hal Brodigan (postmodern.mod3 at gmail.com) # # This file is part of Ronin ASM. # # Ronin is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,10 +29,16 @@ # # Abstract base-class for all Assembly Syntax classes. # class Common + # Bit sizes for various architectures + BITS = { + x86: 32, + amd64: 64, + } + # # Emits a keyword. # # @param [Symbol] name # Name of the keyword. @@ -171,19 +177,51 @@ # def self.emit_instruction(ins) end # + # Emits a section name. + # + # @param [Symbol] name + # The section name. + # + # @return [String] + # The formatted section name. + # + # @since 0.2.0 + # + def self.emit_section(name) + end + + # + # Emits the program's prologue. + # + # @param [Program] program + # The program. + # + # @return [String] + # The formatted prologue. + # + # @since 0.2.0 + # + def self.emit_prologue(program) + end + + # # Emits a program. # # @param [Program] program # The program. # # @return [String] # The formatted program. # def self.emit_program(program) - lines = [emit_label(:_start)] + 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)}"