class Asm

Public Class Methods

compile(code, arch:"i386", format:"hex") click to toggle source

Supported Format: hex, c, binary

# File lib/asm.rb, line 7
def self.compile(code, arch:"i386", format:"hex")
    r = RestClient.post 'http://atdog.tw/asm/compile', :code => code, :arch => arch, :format => format
    r = JSON.parse r
    if r['result'] == 1
        if format == "binary"
            return Base64.decode64(r['code'])
        else
            return r['code']
        end
    else
        raise "asm compile error. [code]: #{code}"
    end
end