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" |
"sub" |
"mul" |
"imul" |
"div" |
"idiv" |
"rem" |
"irem" |
"and" |
"or" |
"xor" |

View File

@ -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<Rule>, 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),