From b35bc82cf7e7110e5fc06f83ed78cc01cc9b0563 Mon Sep 17 00:00:00 2001 From: Ry Date: Mon, 15 Aug 2022 17:22:40 -0700 Subject: [PATCH] Add `mse`, `mcl`, and `tlb` instructions, bump version to 0.3.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/fox32.pest | 7 +++++-- src/main.rs | 10 +++++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f05b8f..de849b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,7 +128,7 @@ dependencies = [ [[package]] name = "fox32asm" -version = "0.1.0" +version = "0.3.0" dependencies = [ "anyhow", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 3fc31ee..deb1750 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fox32asm" -version = "0.2.0" +version = "0.3.0" edition = "2021" build = "build.rs" diff --git a/src/fox32.pest b/src/fox32.pest index fd1f407..e917224 100644 --- a/src/fox32.pest +++ b/src/fox32.pest @@ -90,7 +90,9 @@ instruction_zero = @{ "reti" | "ret" | "ise" | - "icl" + "icl" | + "mse" | + "mcl" } instruction_one = @{ @@ -105,7 +107,8 @@ instruction_one = @{ "rloop" | "push" | "pop" | - "int" + "int" | + "tlb" } instruction_two = @{ diff --git a/src/main.rs b/src/main.rs index 81c5900..0a11d9b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,6 +161,8 @@ enum InstructionZero { Reti, Ise, Icl, + Mse, + Mcl, } #[derive(PartialEq, Debug, Clone, Copy)] @@ -178,6 +180,7 @@ enum InstructionOne { Push, Pop, Int, + Tlb, } #[derive(PartialEq, Debug, Clone, Copy)] @@ -849,6 +852,8 @@ fn parse_instruction_zero(pair: pest::iterators::Pair, condition: Conditio "reti" => InstructionZero::Reti, "ise" => InstructionZero::Ise, "icl" => InstructionZero::Icl, + "mse" => InstructionZero::Mse, + "mcl" => InstructionZero::Mcl, _ => panic!("Unsupported conditional instruction (zero): {}", pair.as_str()), }, } @@ -898,6 +903,7 @@ fn parse_instruction_one(pair: pest::iterators::Pair, mut operand: AstNode "push" => InstructionOne::Push, "pop" => InstructionOne::Pop, "int" => InstructionOne::Int, + "tlb" => InstructionOne::Tlb, _ => panic!("Unsupported conditional instruction (one): {}", pair.as_str()), }, operand: Box::new(operand), @@ -1020,6 +1026,8 @@ fn instruction_to_byte(node: &AstNode) -> u8 { InstructionZero::Reti => 0x3A | size_to_byte(&Size::Word), InstructionZero::Ise => 0x0C | 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, ..} => { @@ -1036,7 +1044,7 @@ fn instruction_to_byte(node: &AstNode) -> u8 { InstructionOne::Push => 0x0A | size_to_byte(size), InstructionOne::Pop => 0x1A | size_to_byte(size), InstructionOne::Int => 0x2C | size_to_byte(size), - + InstructionOne::Tlb => 0x2D | size_to_byte(size), } } AstNode::OperationTwo {size, instruction, ..} => {