diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.lonestar.org> | 2019-12-27 17:37:47 -0500 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.lonestar.org> | 2019-12-27 17:38:53 -0500 |
| commit | 0f7d451b18dbfbdb6060cd021dfdd56e199e98b8 (patch) | |
| tree | fc8dc953cf7427c5bf2551b22ed474aa626dd004 | |
| parent | abedf4e102aae0b63f1f5746c1790f029c9c4db2 (diff) | |
Implement ADD instruction.
| -rw-r--r-- | asm.myr | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -199,6 +199,19 @@ const emitinstr = {p | _: -> `std.Err(std.fmt("invalid argument to LD: {}", p[1])) ;; + | "ADD": + if p.len < 3 + -> `std.Err("ADD missing arguments") + ;; + match (parselit(p[1]), parselit(p[2])) + | (`AddressRegister, `Register(n)): b = `std.Some([0xf0 | (n & 0x0f), 0x1e]) + | (`Register(m), `Number(n)): b = `std.Some([0x70 | (m & 0x0f), n & 0xff]) + | (`Register(m), `Label(l)): b = `std.Some([0x70 | (m & 0x0f), 0x00]) + mark = `std.Some(strdup(l)) + | (`Register(m), `Register(n)): b = `std.Some([0x80 | (m & 0x0f), ((n & 0x0f) << 1) | 0x04]) + | _: + -> `std.Err(std.fmt("invalid argument to ADD: {}", p[1])) + ;; | _: -> `std.Err(std.fmt("unrecognized instruction {}", p[0])) ;; |