From 741c317d0ab0481117033b6826cc69856807506e Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 14 Feb 2025 18:03:25 +0200 Subject: feat(assembler): Implement inc instruction --- assembler/src/parser/instruction.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'assembler/src/parser') 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, -- cgit v1.3.1-26-gb76a