summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm.myr10
1 files changed, 10 insertions, 0 deletions
diff --git a/asm.myr b/asm.myr
index 5fed9b7..ab26cbb 100644
--- a/asm.myr
+++ b/asm.myr
@@ -212,6 +212,16 @@ const emitinstr = {p
| _:
-> `std.Err(std.fmt("invalid argument to ADD: {}", p[1]))
;;
+ | "SUB":
+ if p.len < 3
+ -> `std.Err("SUB missing arguments")
+ ;;
+ match (parselit(p[1]), parselit(p[2]))
+ | (`Register(m), `Register(n)): b = `std.Some([0x80 | (m & 0x0f), ((n & 0x0f) << 1) | 0x05])
+ | _:
+ -> `std.Err(std.fmt("invalid argument to SUB: {}", p[1]))
+ ;;
+
| _:
-> `std.Err(std.fmt("unrecognized instruction {}", p[0]))
;;