#!/usr/bin/env python
import sys
import os

path1 = "/python/assemble/temp.s"
path2 = "/python/assemble/temp"

sys.stdout = open(path1,"w")
print("BITS 32")
print("\n")
print("_start:")

sys.argv.pop(0)
for line in sys.argv:
	print("		{0}".format(line))

sys.stdout.close()
sys.stdout = sys.__stdout__

os.system("nasm " + path1);

buf1 = []
buf2 = []
f = open(path2, "rb")
for b in f.read():
	s = hex(ord(b)).replace("0x","").zfill(2)
	buf1.append(s)
	buf2.append("\\x" + s)
f.close()

print("------------------------------------------")
print(" ".join(buf1))
print("------------------------------------------")
print("".join(buf2))
print("------------------------------------------")
os.system("ndisasm -b32 " + path2);
