Add support for imul, idiv, and irem

This commit is contained in:
Ry 2023-01-27 15:21:40 -08:00
parent b40c8d50b6
commit abd160e6e5
2 changed files with 12 additions and 0 deletions

View File

@ -116,8 +116,11 @@ instruction_two = @{
"add" | "add" |
"sub" | "sub" |
"mul" | "mul" |
"imul" |
"div" | "div" |
"idiv" |
"rem" | "rem" |
"irem" |
"and" | "and" |
"or" | "or" |
"xor" | "xor" |

View File

@ -190,8 +190,11 @@ enum InstructionTwo {
Add, Add,
Sub, Sub,
Mul, Mul,
Imul,
Div, Div,
Idiv,
Rem, Rem,
Irem,
And, And,
Or, Or,
Xor, Xor,
@ -919,8 +922,11 @@ fn parse_instruction_two(pair: pest::iterators::Pair<Rule>, mut lhs: AstNode, mu
"add" => InstructionTwo::Add, "add" => InstructionTwo::Add,
"sub" => InstructionTwo::Sub, "sub" => InstructionTwo::Sub,
"mul" => InstructionTwo::Mul, "mul" => InstructionTwo::Mul,
"imul" => InstructionTwo::Imul,
"div" => InstructionTwo::Div, "div" => InstructionTwo::Div,
"idiv" => InstructionTwo::Idiv,
"rem" => InstructionTwo::Rem, "rem" => InstructionTwo::Rem,
"irem" => InstructionTwo::Irem,
"and" => InstructionTwo::And, "and" => InstructionTwo::And,
"or" => InstructionTwo::Or, "or" => InstructionTwo::Or,
"xor" => InstructionTwo::Xor, "xor" => InstructionTwo::Xor,
@ -1054,8 +1060,11 @@ fn instruction_to_byte(node: &AstNode) -> u8 {
InstructionTwo::Add => 0x01 | size_to_byte(size), InstructionTwo::Add => 0x01 | size_to_byte(size),
InstructionTwo::Sub => 0x21 | size_to_byte(size), InstructionTwo::Sub => 0x21 | size_to_byte(size),
InstructionTwo::Mul => 0x02 | 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::Div => 0x22 | size_to_byte(size),
InstructionTwo::Idiv => 0x34 | size_to_byte(size),
InstructionTwo::Rem => 0x32 | 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::And => 0x03 | size_to_byte(size),
InstructionTwo::Or => 0x13 | size_to_byte(size), InstructionTwo::Or => 0x13 | size_to_byte(size),
InstructionTwo::Xor => 0x23 | size_to_byte(size), InstructionTwo::Xor => 0x23 | size_to_byte(size),