Add int instruction, bump version to 0.2.0

This commit is contained in:
Ry 2022-08-09 01:43:13 -07:00
parent a40b9fccc6
commit ee98141e1d
3 changed files with 7 additions and 2 deletions

View File

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

View File

@ -104,7 +104,8 @@ instruction_one = @{
"rcall" | "rcall" |
"rloop" | "rloop" |
"push" | "push" |
"pop" "pop" |
"int"
} }
instruction_two = @{ instruction_two = @{

View File

@ -177,6 +177,7 @@ enum InstructionOne {
Rloop, Rloop,
Push, Push,
Pop, Pop,
Int,
} }
#[derive(PartialEq, Debug, Clone, Copy)] #[derive(PartialEq, Debug, Clone, Copy)]
@ -896,6 +897,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,
_ => panic!("Unsupported conditional instruction (one): {}", pair.as_str()), _ => panic!("Unsupported conditional instruction (one): {}", pair.as_str()),
}, },
operand: Box::new(operand), operand: Box::new(operand),
@ -1033,6 +1035,8 @@ fn instruction_to_byte(node: &AstNode) -> u8 {
InstructionOne::Rloop => 0x29 | size_to_byte(size), InstructionOne::Rloop => 0x29 | size_to_byte(size),
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),
} }
} }
AstNode::OperationTwo {size, instruction, ..} => { AstNode::OperationTwo {size, instruction, ..} => {