Skip to content

Commit

Permalink
Fixed assembler
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Robson committed May 7, 2024
1 parent 6116de0 commit 56fa7cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 64 deletions.
21 changes: 11 additions & 10 deletions emulator/scripts/swasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -227,9 +233,4 @@ def assembleFile(self,file,l):
asm.assembleFile(f,h)
h.close()
m.writeMemory("out.bin")

#
# Wrapping
# Branch long
#
#
sys.exit(0)
56 changes: 2 additions & 54 deletions nf.sublime-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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"
}
]
}
],
Expand Down

0 comments on commit 56fa7cb

Please sign in to comment.