From 56fa7cbb4163a15fcd0f93965a1d195aa76bc9dd Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Tue, 7 May 2024 18:06:17 +0100 Subject: [PATCH] Fixed assembler --- emulator/scripts/swasm.py | 21 ++++++++------- nf.sublime-workspace | 56 ++------------------------------------- 2 files changed, 13 insertions(+), 64 deletions(-) diff --git a/emulator/scripts/swasm.py b/emulator/scripts/swasm.py index a7aae45b..4476558f 100644 --- a/emulator/scripts/swasm.py +++ b/emulator/scripts/swasm.py @@ -38,7 +38,7 @@ def evaluate(self,expr,pass2): except NameError: if pass2: raise AssemblerError("Unknown identifier in "+expr) - v = None + v = 0 except SyntaxError: raise AssemblerError("Bad expression "+expr) return v @@ -102,7 +102,7 @@ def __init__(self,memory,evaluator): "cpr":0xD0,"inr":0xE0,"dcr":0xF0 } self.group2 = { - "bra":0x01,"bnc":0x02,"bc":0x03,"bp":0x04,"bm":0x05,"bz":0x06, + "br":0x01,"bnc":0x02,"bc":0x03,"bp":0x04,"bm":0x05,"bz":0x06, "bnz":0x07,"bm1":0x08,"bnm1":0x09,"bs":0x0C } @@ -119,7 +119,7 @@ def assemble(self,l,listing = None): s = l if l.find(";") < 0 else l[:l.find(";")] s = s.replace("\t"," ").strip() if s != "": - m = re.match('^([a-z1]+\\s?\\@?)(.*)$',s) + m = re.match('^([a-z1]+\\s*\\@?)(.*)$',s) opcode = s.split(" ")[0].lower().strip() opcode = "" if m is None else m.group(1).replace(" ","") operand = "" if m is None else m.group(2).strip() @@ -215,7 +215,13 @@ def assembleFile(self,file,l): AssemblerError.__LINE__ = 0 for s in open(file,"r").readlines(): AssemblerError.__LINE__ += 1 - self.assemble(s,l) + #print(AssemblerError.__LINE__,s) + try: + self.assemble(s.replace("\t"," "),l) + except AssemblerError as x: + print("Error '{0}' {1}:{2}".format(str(x),AssemblerError.__FILE__,AssemblerError.__LINE__)) + sys.exit(1) + if __name__ == "__main__": m = Memory() @@ -227,9 +233,4 @@ def assembleFile(self,file,l): asm.assembleFile(f,h) h.close() m.writeMemory("out.bin") - -# -# Wrapping -# Branch long -# -# \ No newline at end of file + sys.exit(0) diff --git a/nf.sublime-workspace b/nf.sublime-workspace index c3cc7aee..d86ce0fd 100644 --- a/nf.sublime-workspace +++ b/nf.sublime-workspace @@ -55,28 +55,6 @@ }, "buffers": [ - { - "contents": "p", - "settings": - { - "buffer_size": 1, - "line_ending": "Unix", - "name": "p" - }, - "undo_stack": - [ - [ - 1, - 1, - "insert", - { - "characters": "p" - }, - "AQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA", - "AgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPC/AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8L8" - ] - ] - } ], "build_system": "", "build_system_choices": @@ -114,8 +92,9 @@ ], "file_history": [ - "/home/paulr/Projects/easy-game-creator/compiler/Makefile", "/home/paulr/Projects/easy-game-creator/compiler/cfc.py", + "/home/paulr/Projects/easy-game-creator/build_env/common.make", + "/home/paulr/Projects/easy-game-creator/compiler/Makefile", "/home/paulr/Projects/neo6502-firmware/firmware/common/config/system/group1_system.inc", "/home/paulr/Projects/neo6502-firmware/emulator/Makefile", "/home/paulr/Projects/neo6502-firmware/emulator/src/core/sys_processor.cpp", @@ -137,7 +116,6 @@ "/home/paulr/Projects/neo6502-firmware/emulator/scripts/swasm.py", "/home/paulr/Projects/neo6502-firmware/firmware/Makefile", "/home/paulr/Projects/neo6502-firmware/basic/scripts/makebuild.py", - "/home/paulr/Projects/easy-game-creator/build_env/common.make", "/home/paulr/Projects/neo6502-firmware/firmware/sources/CMakeLists.txt", "/home/paulr/Projects/neo6502-firmware/firmware/common/sources/interface/pininterface.cpp", "/home/paulr/Projects/neo6502-firmware/firmware/common/config/system/group10_uext.inc", @@ -186,36 +164,6 @@ { "sheets": [ - { - "buffer": 0, - "selected": true, - "semi_transient": false, - "settings": - { - "buffer_size": 1, - "regions": - { - }, - "selection": - [ - [ - 1, - 1 - ] - ], - "settings": - { - "auto_name": "p", - "syntax": "Packages/Text/Plain text.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "stack_index": 0, - "stack_multiselect": false, - "type": "text" - } ] } ],