Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define inst_BO_0 (inst.BO & (1 << 4)) //if set, ignore BO_TRUE
- #define inst_BO_1 (inst.BO & (1 << 3)) //if set, check if condition is TRUE
- #define inst_BO_2 (inst.BO & (1 << 2)) //if set, ignore CTR
- #define inst_BO_3 (inst.BO & (1 << 1)) //if set, branch if CTR is 0 (else != 0)
- #define inst_BO_4 (inst.BO & (1 << 0)) //branch predictor hint ("+")
- bool CR::getbit(u8 index) {
- return (this->hex >> (31 - index)) & 1;
- }
- void bcx(gekko::instruction& inst, std::unique_ptr<gekko::cpu>& cpu) { //opcode 16
- if (!inst_BO_2) cpu->ctr--; //not ignoring ctr, decrement
- ctr_ok = inst_BO_2 || ((cpu->ctr != 0) ^ inst_BO_3);
- cond_ok = inst_BO_0 || (cpu->CR.getbit(inst.BI) ^ !inst_BO_1);
- if (ctr_ok && cond_ok) {
- if (inst.LK) //linking, update link register
- cpu->lr = cpu->pc + 4;
- if (inst.AA) //absolute address
- cpu->pc = EXTS(inst.BD << 2);
- else //relative, add (will go backwards if negative)
- cpu->pc += EXTS(inst.BD << 2);
- }
- else {
- cpu->pc += 4;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement