diff options
| Commit | 741c317d0ab0481117033b6826cc69856807506e (patch) | |
|---|---|---|
| Author | 2025-02-14 18:03:25 +0200 | |
| Committer | 2025-02-14 18:03:25 +0200 | |
| Files | b1853fdf8a0d1a8037a27c388e4294733d5e8447 /assembler/src/parser | |
| tonkobali-741c317d0ab0481117033b6826cc69856807506e.tar tonkobali-741c317d0ab0481117033b6826cc69856807506e.tar.gz tonkobali-741c317d0ab0481117033b6826cc69856807506e.zip | ||
| Parent | 1e75ec0d31f05fb8a87939db0415a63a8a021b18 (diff) | |
feat(assembler): Implement inc instruction
1 files changed, 5 insertions, 2 deletions
| -rw-r--r-- | assembler/src/parser/instruction.rs | 7 |
diff --git a/assembler/src/parser/instruction.rs b/assembler/src/parser/instruction.rs index ed3051d..5e19b7e 100644 --- a/assembler/src/parser/instruction.rs +++ b/assembler/src/parser/instruction.rs @@ -53,7 +53,7 @@ impl Instruction { return Err(ArgumentError::NotLocation); } }, - "dec" => { + "inc" | "dec" => { self.check_args_len(1)?; }, "add" => { @@ -82,6 +82,9 @@ impl Instruction { "jmp" => vec![ Instruction::new_subleq(&Z, &Z, &self.args[0]), ], + "inc" => vec![ + Instruction::new_subleq(&N, &self.args[0], &Address::Instruction(next + 1)), + ], "dec" => vec![ Instruction::new_subleq(&E, &self.args[0], &Address::Instruction(next + 1)), ], @@ -108,7 +111,7 @@ impl Instruction { pub(crate) fn collapse_len(&self) -> usize { match &*self.name { - "subleq" | "jmp" | "dec" + "subleq" | "jmp" | "inc" | "dec" => 1, "add" => 3, |
