From abd160e6e58cd3edbe925941fc2569233ee08203 Mon Sep 17 00:00:00 2001 From: Ry Date: Fri, 27 Jan 2023 15:21:40 -0800 Subject: [PATCH] Add support for `imul`, `idiv`, and `irem` --- src/fox32.pest | 3 +++ src/main.rs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/fox32.pest b/src/fox32.pest index f7073f8..bca7355 100644 --- a/src/fox32.pest +++ b/src/fox32.pest @@ -116,8 +116,11 @@ instruction_two = @{ "add" | "sub" | "mul" | + "imul" | "div" | + "idiv" | "rem" | + "irem" | "and" | "or" | "xor" | diff --git a/src/main.rs b/src/main.rs index 5dcad23..990b3c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -190,8 +190,11 @@ enum InstructionTwo { Add, Sub, Mul, + Imul, Div, + Idiv, Rem, + Irem, And, Or, Xor, @@ -919,8 +922,11 @@ fn parse_instruction_two(pair: pest::iterators::Pair, mut lhs: AstNode, mu "add" => InstructionTwo::Add, "sub" => InstructionTwo::Sub, "mul" => InstructionTwo::Mul, + "imul" => InstructionTwo::Imul, "div" => InstructionTwo::Div, + "idiv" => InstructionTwo::Idiv, "rem" => InstructionTwo::Rem, + "irem" => InstructionTwo::Irem, "and" => InstructionTwo::And, "or" => InstructionTwo::Or, "xor" => InstructionTwo::Xor, @@ -1054,8 +1060,11 @@ fn instruction_to_byte(node: &AstNode) -> u8 { InstructionTwo::Add => 0x01 | size_to_byte(size), InstructionTwo::Sub => 0x21 | size_to_byte(size), InstructionTwo::Mul => 0x02 | size_to_byte(size), + InstructionTwo::Imul => 0x14 | size_to_byte(size), InstructionTwo::Div => 0x22 | size_to_byte(size), + InstructionTwo::Idiv => 0x34 | size_to_byte(size), InstructionTwo::Rem => 0x32 | size_to_byte(size), + InstructionTwo::Irem => 0x35 | size_to_byte(size), InstructionTwo::And => 0x03 | size_to_byte(size), InstructionTwo::Or => 0x13 | size_to_byte(size), InstructionTwo::Xor => 0x23 | size_to_byte(size),