Implement instructions 0x03C-0x053, add flag constants and fix execute dispatch
This commit is contained in:
@@ -154,20 +154,75 @@ namespace spider {
|
||||
// TODO: Implement JIF
|
||||
}
|
||||
|
||||
/**
|
||||
* 0x03C — Jump Relative.
|
||||
* Adds a signed offset (Dst) to the instruction register.
|
||||
*/
|
||||
void CPU::JMR() {
|
||||
// TODO: Implement JMR
|
||||
fetchOperDst();
|
||||
i64 offset;
|
||||
switch (_size) {
|
||||
case 0b00: offset = static_cast<i64>(_dst->_i8); break; // 1 byte
|
||||
case 0b01: offset = static_cast<i64>(_dst->_i16); break; // 2 bytes
|
||||
case 0b10: offset = static_cast<i64>(_dst->_i32); break; // 4 bytes
|
||||
case 0b11: offset = _dst->_i64; break; // 8 bytes
|
||||
}
|
||||
RI = static_cast<u64>(static_cast<i64>(RI) + offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 0x03D — Jump Relative if Equal.
|
||||
* Adds a signed offset (Dst) to RI only if the Equal flag (bit 10) is set.
|
||||
*/
|
||||
void CPU::JER() {
|
||||
// TODO: Implement JER
|
||||
fetchOperDst();
|
||||
if (RF & CPU::FLAG_EQUAL) {
|
||||
i64 offset;
|
||||
switch (_size) {
|
||||
case 0b00: offset = static_cast<i64>(_dst->_i8); break;
|
||||
case 0b01: offset = static_cast<i64>(_dst->_i16); break;
|
||||
case 0b10: offset = static_cast<i64>(_dst->_i32); break;
|
||||
case 0b11: offset = _dst->_i64; break;
|
||||
}
|
||||
RI = static_cast<u64>(static_cast<i64>(RI) + offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 0x03E — Jump Relative if Not Equal.
|
||||
* Adds a signed offset (Dst) to RI only if the Equal flag (bit 10) is cleared.
|
||||
*/
|
||||
void CPU::JNR() {
|
||||
// TODO: Implement JNR
|
||||
fetchOperDst();
|
||||
if (!(RF & CPU::FLAG_EQUAL)) {
|
||||
i64 offset;
|
||||
switch (_size) {
|
||||
case 0b00: offset = static_cast<i64>(_dst->_i8); break;
|
||||
case 0b01: offset = static_cast<i64>(_dst->_i16); break;
|
||||
case 0b10: offset = static_cast<i64>(_dst->_i32); break;
|
||||
case 0b11: offset = _dst->_i64; break;
|
||||
}
|
||||
RI = static_cast<u64>(static_cast<i64>(RI) + offset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 0x03F — Jump Relative if Src is true.
|
||||
* Adds a signed offset (Dst) to RI only if Src is booleanly true (non-zero).
|
||||
*/
|
||||
void CPU::JIR() {
|
||||
// TODO: Implement JIR
|
||||
fetchOperSrc();
|
||||
fetchOperDst();
|
||||
if (_src->_u64 != 0) {
|
||||
i64 offset;
|
||||
switch (_size) {
|
||||
case 0b00: offset = static_cast<i64>(_dst->_i8); break;
|
||||
case 0b01: offset = static_cast<i64>(_dst->_i16); break;
|
||||
case 0b10: offset = static_cast<i64>(_dst->_i32); break;
|
||||
case 0b11: offset = _dst->_i64; break;
|
||||
}
|
||||
RI = static_cast<u64>(static_cast<i64>(RI) + offset);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user