Created
November 24, 2012 17:49
-
-
Save jcrubino/4140668 to your computer and use it in GitHub Desktop.
A Python Netwide Assembley Utility makes 32bit assembly compatible with 64bit Os or tweaks basic 32bit assembly programs (not all) to native 64bit assembly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Python Netwide Assembley Utility | |
# makes 32bit assembly compatible with 64bit Os | |
# tweaks basic 32bit assembly (not all) to native 64bit assembly | |
# | |
# License GPLv3 | |
# code author: James Rubino | |
from subprocess import check_call | |
import sys | |
def make_compatible(source): | |
base = source.split('.')[0] | |
r1 = check_call(['nasm','-f','elf','-g','-F','stabs',source]) | |
r2 = check_call(['ld','-o',base,base+'.o','-melf_i386']) | |
print "\n$./{0}\t\t to run\n".format(base) | |
def convert_to_64bit(source): | |
base = source.split('.')[0] | |
r1 = check_call(['nasm', '-f', 'elf64', '-g', '-F', 'stabs', source]) | |
r2 = check_call(['ld', '-o', base, base+'.o']) | |
print "\n$./{0}\t\t to run\n".format(base) | |
if __name__ == '__main__': | |
try: | |
if sys.argv[1] == 'comp64': | |
make_compatible(sys.argv[2]) | |
if sys.argv[1] == 'conv64': | |
convert_to_64bit(sys.argv[2]) | |
except IndexError: | |
print '\n'*2 | |
print "Choices are:" | |
print "\tcomp64 -> make compatible with 64bit" | |
print "\tconv64 -> convert to 64bit" | |
print '\n'*2 | |
except Exception, e: | |
print '\n'*2 | |
print Exception, e | |
print '\n'*2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment