]> Chaos Git - corbenik/corbenik.git/commitdiff
Add string/utf16le string support to assembler
authorchaoskagami <chaos.kagami@gmail.com>
Sun, 12 Jun 2016 20:49:02 +0000 (16:49 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sun, 12 Jun 2016 20:49:02 +0000 (16:49 -0400)
host/bytecode_asm.py
patch/mset_str.pco

index eef5c183cddd1d3be0af231c6ad32f828b5f58a1..18463ce4f4b4652cffbaaa879331470b2f11ad3b 100755 (executable)
@@ -134,8 +134,15 @@ def parse_op(token_list, instr_offs):
                if s != 2:
                        syn_err("invalid number of arguments")
 
-               # We cut corners and calculate stuff manually.
-               return bytearray.fromhex("02") + bytearray([len(token_list[1]) / 2]) + bytearray.fromhex(token_list[1])
+               if token_list[1][:1] == "\"": # Quoted string.
+                       data = bytearray(eval(token_list[1]).encode('utf-8'))
+                       return bytearray.fromhex("02") + bytearray([len(data)]) + data
+               elif token_list[1][:2] == "u\"": # Wide quoted string.
+                       data = bytearray(eval(token_list[1]).encode('utf-16le'))
+                       return bytearray.fromhex("02") + bytearray([len(data)]) + data
+               else:
+                       # We cut corners and calculate stuff manually.
+                       return bytearray.fromhex("02") + bytearray([len(token_list[1]) / 2]) + bytearray.fromhex(token_list[1])
        elif token_list[0] == "back":
                if s != 2:
                        syn_err("invalid number of arguments")
@@ -150,14 +157,28 @@ def parse_op(token_list, instr_offs):
                if s != 2:
                        syn_err("invalid number of arguments")
 
-               # We cut corners and calculate stuff manually.
-               return bytearray.fromhex("05") + bytearray([len(token_list[1]) / 2]) + bytearray.fromhex(token_list[1])
+               if token_list[1][:1] == "\"": # Quoted string.
+                       data = bytearray(eval(token_list[1]).encode('utf-8'))
+                       return bytearray.fromhex("05") + bytearray([len(data)]) + data
+               elif token_list[1][:2] == "u\"": # Wide quoted string.
+                       data = bytearray(eval(token_list[1]).encode('utf-16le'))
+                       return bytearray.fromhex("05") + bytearray([len(data)]) + data
+               else:
+                       # We cut corners and calculate stuff manually.
+                       return bytearray.fromhex("05") + bytearray([len(token_list[1]) / 2]) + bytearray.fromhex(token_list[1])
        elif token_list[0] == "test":
                if s != 2:
                        syn_err("invalid number of arguments")
 
-               # We cut corners and calculate stuff manually.
-               return bytearray.fromhex("06") + bytearray([len(token_list[1]) / 2]) + bytearray.fromhex(token_list[1])
+               if token_list[1][:1] == "\"": # Quoted string.
+                       data = bytearray(eval(token_list[1]).encode('utf-8'))
+                       return bytearray.fromhex("06") + bytearray([len(data)]) + data
+               elif token_list[1][:2] == "u\"": # Wide quoted string.
+                       data = bytearray(eval(token_list[1]).encode('utf-16le'))
+                       return bytearray.fromhex("06") + bytearray([len(data)]) + data
+               else:
+                       # We cut corners and calculate stuff manually.
+                       return bytearray.fromhex("06") + bytearray([len(token_list[1]) / 2]) + bytearray.fromhex(token_list[1])
        elif token_list[0] == "jmp":
                if s != 2:
                        syn_err("invalid number of arguments")
index c001f5d25f37075900ea7320a94a8537ce8ae7e4..e0b051c4ec14d7084943c71aa4d06aadfa0eadd1 100644 (file)
@@ -9,9 +9,9 @@ rel exe_text
 # Status: needs loader
 
 # u"Ver."
-find 5600650072002e00
+find u"Ver."
 
 abortnf
 
 # u".hax"
-set  2e006800610078
+set  u".hax"