lib/ronin/asm/syntax/att.rb in ronin-asm-0.1.0 vs lib/ronin/asm/syntax/att.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 @@ -86,10 +86,27 @@ return asm end # + # Emits multiple operands. + # + # @param [Array<ImmediateOperand, MemoryOperand, Register, Symbol>] ops + # The Array of operands. + # + # @return [String] + # The formatted operands. + # + def self.emit_operands(ops) + if ops.length > 1 + [*ops[1..-1], ops[0]].map { |op| emit_operand(op) }.join(",\t") + else + super(ops) + end + end + + # # Emits an instruction. # # @param [Instruction] ins # The instruction. # @@ -109,26 +126,36 @@ return line end # - # Emits a program. + # 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) + ".#{name}" + end + + # + # Emits the program's prologue. + # # @param [Program] program # The program. # # @return [String] - # The formatted program. + # The formatted prologue. # - def self.emit_program(program) - asm = super(program) - - # prepend the `.code64` directive for YASM - if program.arch == :amd64 - asm = [".code64", '', asm].join($/) - end - - return asm + # @since 0.2.0 + # + def self.emit_prologue(program) + ".code#{BITS[program.arch]}" end end end end