From ee98141e1dc3ac41e2e346dd155e2880db7edaae Mon Sep 17 00:00:00 2001 From: Ry Date: Tue, 9 Aug 2022 01:43:13 -0700 Subject: [PATCH] Add `int` instruction, bump version to 0.2.0 --- Cargo.toml | 2 +- src/fox32.pest | 3 ++- src/main.rs | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 89f7d78..3fc31ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fox32asm" -version = "0.1.0" +version = "0.2.0" edition = "2021" build = "build.rs" diff --git a/src/fox32.pest b/src/fox32.pest index f8874b7..fd1f407 100644 --- a/src/fox32.pest +++ b/src/fox32.pest @@ -104,7 +104,8 @@ instruction_one = @{ "rcall" | "rloop" | "push" | - "pop" + "pop" | + "int" } instruction_two = @{ diff --git a/src/main.rs b/src/main.rs index ca116d8..81c5900 100644 --- a/src/main.rs +++ b/src/main.rs @@ -177,6 +177,7 @@ enum InstructionOne { Rloop, Push, Pop, + Int, } #[derive(PartialEq, Debug, Clone, Copy)] @@ -896,6 +897,7 @@ fn parse_instruction_one(pair: pest::iterators::Pair, mut operand: AstNode }, "push" => InstructionOne::Push, "pop" => InstructionOne::Pop, + "int" => InstructionOne::Int, _ => panic!("Unsupported conditional instruction (one): {}", pair.as_str()), }, operand: Box::new(operand), @@ -1033,6 +1035,8 @@ fn instruction_to_byte(node: &AstNode) -> u8 { InstructionOne::Rloop => 0x29 | size_to_byte(size), InstructionOne::Push => 0x0A | size_to_byte(size), InstructionOne::Pop => 0x1A | size_to_byte(size), + InstructionOne::Int => 0x2C | size_to_byte(size), + } } AstNode::OperationTwo {size, instruction, ..} => {