Project

General

Profile

Actions

Emulator Issues #11860

closed

Interpreter: bcx bug

Added by nwplayer123 over 4 years ago. Updated over 4 years ago.

Status:
Working as intended
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp#L39 should be ^!, not ==, according to the manual.

Here's my implementation, using that formula. Seems to work fine on my end.
https://pastebin.com/kEht05sg


Files

Screenshot_90.png (42.3 KB) Screenshot_90.png nwplayer123, 09/19/2019 08:41 PM
Screenshot_89.png (103 KB) Screenshot_89.png nwplayer123, 09/19/2019 08:41 PM
Screenshot_91.png (12.9 KB) Screenshot_91.png nwplayer123, 09/19/2019 08:41 PM
Actions #1

Updated by AdmiralCurtiss over 4 years ago

For posterity, since I don't trust pastebin to actually keep stuff around forever, that link contains:

	#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;
		}
	}
Actions #2

Updated by flacs over 4 years ago

  • Status changed from New to Working as intended

There is no difference between x ^ !y and x == y (other than readability :P).

Actions #3

Updated by nwplayer123 over 4 years ago

It mattered when I was testing in my code, but now that I think about it, that seems logical, must be some compiler/typecasting issue on my end

Actions

Also available in: Atom PDF