Add mse, mcl, and tlb instructions, bump version to 0.3.0

This commit is contained in:
Ry 2022-08-15 17:22:40 -07:00
parent ee98141e1d
commit b35bc82cf7
4 changed files with 16 additions and 5 deletions

2
Cargo.lock generated
View File

@ -128,7 +128,7 @@ dependencies = [
[[package]] [[package]]
name = "fox32asm" name = "fox32asm"
version = "0.1.0" version = "0.3.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"lazy_static", "lazy_static",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "fox32asm" name = "fox32asm"
version = "0.2.0" version = "0.3.0"
edition = "2021" edition = "2021"
build = "build.rs" build = "build.rs"

View File

@ -90,7 +90,9 @@ instruction_zero = @{
"reti" | "reti" |
"ret" | "ret" |
"ise" | "ise" |
"icl" "icl" |
"mse" |
"mcl"
} }
instruction_one = @{ instruction_one = @{
@ -105,7 +107,8 @@ instruction_one = @{
"rloop" | "rloop" |
"push" | "push" |
"pop" | "pop" |
"int" "int" |
"tlb"
} }
instruction_two = @{ instruction_two = @{

View File

@ -161,6 +161,8 @@ enum InstructionZero {
Reti, Reti,
Ise, Ise,
Icl, Icl,
Mse,
Mcl,
} }
#[derive(PartialEq, Debug, Clone, Copy)] #[derive(PartialEq, Debug, Clone, Copy)]
@ -178,6 +180,7 @@ enum InstructionOne {
Push, Push,
Pop, Pop,
Int, Int,
Tlb,
} }
#[derive(PartialEq, Debug, Clone, Copy)] #[derive(PartialEq, Debug, Clone, Copy)]
@ -849,6 +852,8 @@ fn parse_instruction_zero(pair: pest::iterators::Pair<Rule>, condition: Conditio
"reti" => InstructionZero::Reti, "reti" => InstructionZero::Reti,
"ise" => InstructionZero::Ise, "ise" => InstructionZero::Ise,
"icl" => InstructionZero::Icl, "icl" => InstructionZero::Icl,
"mse" => InstructionZero::Mse,
"mcl" => InstructionZero::Mcl,
_ => panic!("Unsupported conditional instruction (zero): {}", pair.as_str()), _ => panic!("Unsupported conditional instruction (zero): {}", pair.as_str()),
}, },
} }
@ -898,6 +903,7 @@ fn parse_instruction_one(pair: pest::iterators::Pair<Rule>, mut operand: AstNode
"push" => InstructionOne::Push, "push" => InstructionOne::Push,
"pop" => InstructionOne::Pop, "pop" => InstructionOne::Pop,
"int" => InstructionOne::Int, "int" => InstructionOne::Int,
"tlb" => InstructionOne::Tlb,
_ => panic!("Unsupported conditional instruction (one): {}", pair.as_str()), _ => panic!("Unsupported conditional instruction (one): {}", pair.as_str()),
}, },
operand: Box::new(operand), operand: Box::new(operand),
@ -1020,6 +1026,8 @@ fn instruction_to_byte(node: &AstNode) -> u8 {
InstructionZero::Reti => 0x3A | size_to_byte(&Size::Word), InstructionZero::Reti => 0x3A | size_to_byte(&Size::Word),
InstructionZero::Ise => 0x0C | size_to_byte(&Size::Word), InstructionZero::Ise => 0x0C | size_to_byte(&Size::Word),
InstructionZero::Icl => 0x1C | size_to_byte(&Size::Word), InstructionZero::Icl => 0x1C | size_to_byte(&Size::Word),
InstructionZero::Mse => 0x0D | size_to_byte(&Size::Word),
InstructionZero::Mcl => 0x1D | size_to_byte(&Size::Word),
} }
} }
AstNode::OperationOne {size, instruction, ..} => { AstNode::OperationOne {size, instruction, ..} => {
@ -1036,7 +1044,7 @@ fn instruction_to_byte(node: &AstNode) -> u8 {
InstructionOne::Push => 0x0A | size_to_byte(size), InstructionOne::Push => 0x0A | size_to_byte(size),
InstructionOne::Pop => 0x1A | size_to_byte(size), InstructionOne::Pop => 0x1A | size_to_byte(size),
InstructionOne::Int => 0x2C | size_to_byte(size), InstructionOne::Int => 0x2C | size_to_byte(size),
InstructionOne::Tlb => 0x2D | size_to_byte(size),
} }
} }
AstNode::OperationTwo {size, instruction, ..} => { AstNode::OperationTwo {size, instruction, ..} => {