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
342c3e6061
commit
998646cb80
18
encoding.md
18
encoding.md
|
@ -22,13 +22,17 @@ If the instruction doesn't allow variable sizes or a size was not specified, set
|
|||
| 3- | | DEC[.8,16,32] | REM[.8,16,32] | NOT[.8,16,32] | | | | | | RTA | RETI | | | | | |
|
||||
|
||||
# Condition table
|
||||
| | |
|
||||
| :---: | -------- |
|
||||
| 0b000 | (always) |
|
||||
| 0b001 | IFZ |
|
||||
| 0b010 | IFNZ |
|
||||
| 0b011 | IFC |
|
||||
| 0b100 | IFNC |
|
||||
| | | |
|
||||
| :---: | ------ | --------------------------------------------- |
|
||||
| 0b000 | --- | always |
|
||||
| 0b001 | IFZ | zero |
|
||||
| 0b010 | IFNZ | not zero |
|
||||
| 0b011 | IFC | carry |
|
||||
| 0b011 | IFLT | less than (equivalent to IFC) |
|
||||
| 0b100 | IFNC | not carry |
|
||||
| 0b100 | IFGTEQ | greater than or equal to (equivalent to IFNC) |
|
||||
| 0b101 | IFGT | greater than |
|
||||
| 0b110 | IFLTEQ | less than or equal to |
|
||||
|
||||
# Destination table
|
||||
| | |
|
||||
|
|
|
@ -73,6 +73,8 @@ impl Cpu {
|
|||
Condition::NotZero => !self.flag.zero,
|
||||
Condition::Carry => self.flag.carry,
|
||||
Condition::NotCarry => !self.flag.carry,
|
||||
Condition::GreaterThan => !self.flag.carry && !self.flag.zero,
|
||||
Condition::LessThanEqualTo => self.flag.carry || self.flag.zero,
|
||||
}
|
||||
}
|
||||
fn relative_to_absolute(&self, relative_address: u32) -> u32 {
|
||||
|
@ -2689,6 +2691,10 @@ enum Condition {
|
|||
NotZero,
|
||||
Carry,
|
||||
NotCarry,
|
||||
GreaterThan,
|
||||
// GreaterThanEqualTo is equivalent to NotCarry
|
||||
// LessThan is equivalent to Carry
|
||||
LessThanEqualTo,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -2783,6 +2789,8 @@ impl Instruction {
|
|||
0x20 => Condition::NotZero,
|
||||
0x30 => Condition::Carry,
|
||||
0x40 => Condition::NotCarry,
|
||||
0x50 => Condition::GreaterThan,
|
||||
0x60 => Condition::LessThanEqualTo,
|
||||
_ => return None,
|
||||
};
|
||||
match opcode {
|
||||
|
|
Loading…
Reference in New Issue
Block a user