diff --git a/Web Interface prototype Generator.py b/Web Interface prototype Generator.py
index 990b824..118c0e7 100644
--- a/Web Interface prototype Generator.py
+++ b/Web Interface prototype Generator.py
@@ -1,22 +1,152 @@
+import subprocess
import ctypes
+import re
+
+subprocess.call("./bin/dis foo | sponge z_disassembled", shell=True)
vm = ctypes.CDLL('./libvm.so')
vm.initialize_lilith()
-c_s = ctypes.create_string_buffer("foo".encode('ascii'))
-vm.load_lilith(c_s)
+vm.load_lilith(ctypes.create_string_buffer("foo".encode('ascii')))
-vm.get_register.argtype = ctypes.c_uint
-vm.get_register.restype = ctypes.c_uint
+# vm.get_byte.argtype = ctypes.c_uint
+# vm.get_byte.restype = ctypes.c_ubyte
-R0 = vm.get_register(3)
-print( R0)
-
-vm.get_byte.argtype = ctypes.c_uint
-vm.get_byte.restype = ctypes.c_ubyte
-
-for i in range(0, 20):
- print(vm.get_byte(i))
+# print("Memory 0-19 values:")
+# for i in range(0, 20):
+# print(vm.get_byte(i))
+vm.get_memory.argtype = ctypes.c_uint
vm.get_memory.restype = ctypes.c_char_p
-print( (vm.get_memory()).decode('utf-8'))
+
+hexlookup = { 0 : '0', 1 : '1', 2 : '2', 3 : '3', 4 : '4', 5 : '5', 6 : '6', 7 : '7', 8 : '8', 9 : '9', 10 : 'A', 11 : 'B', 12 : 'C', 13 : 'D', 14 : 'E', 15 : 'F' }
+
+def formatByte(a):
+ first = a >> 4
+ second = a % 16
+ return str(hexlookup[first]+hexlookup[second])
+
+def formatAddress(a):
+ first = a >> 24
+ second = (a % 16777216) >> 16
+ third = (a % 65536) >> 8
+ fourth = a % 256
+ myreturn = formatByte(first) + formatByte(second) + formatByte(third) + formatByte(fourth)
+ return myreturn[:-1] + "x"
+
+def formatRegister(a):
+ first = a >> 24
+ second = (a % 16777216) >> 16
+ third = (a % 65536) >> 8
+ fourth = a % 256
+ return formatByte(first) + formatByte(second) + formatByte(third) + formatByte(fourth)
+
+def get_header():
+ return """
+
+
+
+
+ Knight CPU Debugger
+
+
+
+
+
+
+
+
+
+
+
+ Index |
+ 0 |
+ 1 |
+ 2 |
+ 3 |
+ 4 |
+ 5 |
+ 6 |
+ 7 |
+ 8 |
+ 8 |
+ A |
+ B |
+ C |
+ D |
+ E |
+ F |
+
+
+ """
+
+def get_spacer1():
+ return """
+
+
+
+"""
+
+def get_registers(index):
+ vm.get_register.argtype = ctypes.c_uint
+ vm.get_register.restype = ctypes.c_uint
+
+# R0 = vm.get_register(3)
+# print("Register R0 value:")
+# print(R0)
+
+ temp = """
+
+
+ Register |
+ Value |
+
+
+ """
+
+ for i in range(0,8):
+ temp = temp + """R""" + str(index + i) + " | " + formatRegister(vm.get_register(index + i)) + " |
\n"
+
+ return temp + """
+
"""
+
+def get_spacer2():
+ return """
+
+
+ """
+
+def get_disassembled():
+ f = open('z_disassembled', "r")
+
+ temp = """
"""
+ i = 0
+ for line in f:
+ pieces = re.split(r'\t+', line)
+ temp = temp + "" + formatRegister(i) + " | " + pieces[0] + " | " + pieces[1] + " |
\n"
+ i = i + 4
+
+ return temp + "
"
+
+def get_footer():
+ return """
+
+
+
+"""
+
+print(get_header())
+print( (vm.get_memory(0)).decode('utf-8'))
+print(get_spacer1())
+print(get_registers(0))
+print(get_registers(8))
+print(get_spacer2())
+print(get_disassembled())
+print(get_footer())