From a20f4a248edb2e7fee85804a469e89b3d1242571 Mon Sep 17 00:00:00 2001 From: julianb0 Date: Thu, 30 May 2019 11:41:00 +0200 Subject: [PATCH] negative offset --- as/k-as.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/as/k-as.py b/as/k-as.py index 01758ce..786dc62 100755 --- a/as/k-as.py +++ b/as/k-as.py @@ -421,13 +421,22 @@ def gentext(): lastimm = 4 elif word == "%imm64": lastimm = 8 - elif word[2:] == "off" and word[0] == '%': + + if word[2:] == "off" and word[0] == '%': lastimm = 2 - b_text.write(special_syms[word].to_bytes(2, byteorder='little', signed=False)) + isSigned = True + else: + isSigned = False + + b_text.write(special_syms[word].to_bytes(2, byteorder='little', signed=isSigned)) continue if is_number(word): - b_text.write(int(word, base=0).to_bytes(lastimm, byteorder='little', signed=False)) + if word[0] == '-': + isSigned = True + else: + isSigned = False + b_text.write(int(word, base=0).to_bytes(lastimm, byteorder='little', signed=isSigned)) continue print("Assembly error, unknown token '{}' in line: {}".format(word, line))