fox32+fox32asm: Add proper support for greater than and less than
This adds IFGT, IFGTEQ, IFLT, and IFLTEQ, which makes it easier to check for these conditions.
This commit is contained in:
parent
492e8d51a1
commit
9fb445f688
|
@ -58,7 +58,11 @@ condition = @{
|
||||||
"ifz" |
|
"ifz" |
|
||||||
"ifnz" |
|
"ifnz" |
|
||||||
"ifc" |
|
"ifc" |
|
||||||
"ifnc"
|
"ifnc" |
|
||||||
|
"ifgteq" |
|
||||||
|
"ifgt" |
|
||||||
|
"iflteq" |
|
||||||
|
"iflt"
|
||||||
}
|
}
|
||||||
|
|
||||||
instruction = {
|
instruction = {
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -205,6 +205,10 @@ enum Condition {
|
||||||
NotZero,
|
NotZero,
|
||||||
Carry,
|
Carry,
|
||||||
NotCarry,
|
NotCarry,
|
||||||
|
GreaterThan,
|
||||||
|
// GreaterThanEqualTo is equivalent to NotCarry
|
||||||
|
// LessThan is equivalent to Carry
|
||||||
|
LessThanEqualTo,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Clone)]
|
#[derive(PartialEq, Debug, Clone)]
|
||||||
|
@ -561,6 +565,10 @@ fn parse_condition(pair: &pest::iterators::Pair<Rule>) -> Condition {
|
||||||
"ifnz" => Condition::NotZero,
|
"ifnz" => Condition::NotZero,
|
||||||
"ifc" => Condition::Carry,
|
"ifc" => Condition::Carry,
|
||||||
"ifnc" => Condition::NotCarry,
|
"ifnc" => Condition::NotCarry,
|
||||||
|
"ifgt" => Condition::GreaterThan,
|
||||||
|
"ifgteq" => Condition::NotCarry,
|
||||||
|
"iflt" => Condition::Carry,
|
||||||
|
"iflteq" => Condition::LessThanEqualTo,
|
||||||
_ => panic!("Unsupported condition: {}", pair.as_str()),
|
_ => panic!("Unsupported condition: {}", pair.as_str()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -976,6 +984,8 @@ fn condition_source_destination_to_byte(node: &AstNode) -> u8 {
|
||||||
Condition::NotZero => 0x20,
|
Condition::NotZero => 0x20,
|
||||||
Condition::Carry => 0x30,
|
Condition::Carry => 0x30,
|
||||||
Condition::NotCarry => 0x40,
|
Condition::NotCarry => 0x40,
|
||||||
|
Condition::GreaterThan => 0x50,
|
||||||
|
Condition::LessThanEqualTo => 0x60,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AstNode::OperationOne {condition, ..} => {
|
AstNode::OperationOne {condition, ..} => {
|
||||||
|
@ -985,6 +995,8 @@ fn condition_source_destination_to_byte(node: &AstNode) -> u8 {
|
||||||
Condition::NotZero => 0x20,
|
Condition::NotZero => 0x20,
|
||||||
Condition::Carry => 0x30,
|
Condition::Carry => 0x30,
|
||||||
Condition::NotCarry => 0x40,
|
Condition::NotCarry => 0x40,
|
||||||
|
Condition::GreaterThan => 0x50,
|
||||||
|
Condition::LessThanEqualTo => 0x60,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AstNode::OperationTwo {condition, ..} => {
|
AstNode::OperationTwo {condition, ..} => {
|
||||||
|
@ -994,6 +1006,8 @@ fn condition_source_destination_to_byte(node: &AstNode) -> u8 {
|
||||||
Condition::NotZero => 0x20,
|
Condition::NotZero => 0x20,
|
||||||
Condition::Carry => 0x30,
|
Condition::Carry => 0x30,
|
||||||
Condition::NotCarry => 0x40,
|
Condition::NotCarry => 0x40,
|
||||||
|
Condition::GreaterThan => 0x50,
|
||||||
|
Condition::LessThanEqualTo => 0x60,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => panic!("Attempting to parse a non-instruction AST node as an instruction: {:#?}", node),
|
_ => panic!("Attempting to parse a non-instruction AST node as an instruction: {:#?}", node),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user