summaryrefslogtreecommitdiff
path: root/asm.py
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-05-02 23:16:30 +0100
committerubq323 <ubq323@ubq323.website>2024-05-02 23:16:30 +0100
commita71e6c729761d07c7bf189c057951440d1fe251f (patch)
tree9b4c6e02cc4997357e944a7bf6ca4f7d2ce8c5b6 /asm.py
parent20ddcf5e3733677b695d50d86d65c8de5b386e60 (diff)
more things
Diffstat (limited to 'asm.py')
-rwxr-xr-xasm.py40
1 files changed, 2 insertions, 38 deletions
diff --git a/asm.py b/asm.py
index 26eaf8f..3d61543 100755
--- a/asm.py
+++ b/asm.py
@@ -1,39 +1,6 @@
#!/usr/bin/env python3
-mnems = """
-nop
-rot
-nrt
-dup
-swp
-ovr
-drp
-tck
-nip
-equ
-neq
-add
-sub
-mul
-div
-neg
-slt
-ult
-sle
-ule
-lod
-sto
-psh
-pop
-""".split()
-mnems.extend(['???']*(64-len(mnems)))
-def opws(kw):
- for k in range(16):
- mnems.append(kw + str(k))
-opws("mark") # who is mark
-opws("loc")
-opws("ret")
-opws("lit")
+from mnems import mnems
# print(mnems)
import sys
@@ -81,7 +48,7 @@ def assemble_line(args, lineno):
opc2 = mnems.index(i2)
emit_instrs(opc1, opc2)
case ["l", val]:
- emit_lit(int(val))
+ emit_lit(int(val,16))
case [':', label]:
if label in labels:
@@ -145,9 +112,6 @@ def jump_instr(target, origin):
rel = target - origin + 2048
return (rel&0b111111111111)|0b0100000000000000
-
-
-
import sys
def main():
for ix, line in enumerate(sys.stdin):