mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-11-03 23:28:48 +00:00 
			
		
		
		
	Merge pull request #354 from lioncash/usaduflow
armemu: Fix underflows in USAD8/USADA8
This commit is contained in:
		
						commit
						762f16c4ad
					
				
					 3 changed files with 14 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -6672,10 +6672,10 @@ L_stm_s_takeabort:
 | 
			
		|||
                const u32 rm_val = state->Reg[rm_idx];
 | 
			
		||||
                const u32 rn_val = state->Reg[rn_idx];
 | 
			
		||||
 | 
			
		||||
                const u8 diff1 = (u8)std::labs((rn_val & 0xFF) - (rm_val & 0xFF));
 | 
			
		||||
                const u8 diff2 = (u8)std::labs(((rn_val >> 8) & 0xFF) - ((rm_val >> 8) & 0xFF));
 | 
			
		||||
                const u8 diff3 = (u8)std::labs(((rn_val >> 16) & 0xFF) - ((rm_val >> 16) & 0xFF));
 | 
			
		||||
                const u8 diff4 = (u8)std::labs(((rn_val >> 24) & 0xFF) - ((rm_val >> 24) & 0xFF));
 | 
			
		||||
                const u8 diff1 = ARMul_UnsignedAbsoluteDifference(rn_val & 0xFF, rm_val & 0xFF);
 | 
			
		||||
                const u8 diff2 = ARMul_UnsignedAbsoluteDifference((rn_val >> 8) & 0xFF, (rm_val >> 8) & 0xFF);
 | 
			
		||||
                const u8 diff3 = ARMul_UnsignedAbsoluteDifference((rn_val >> 16) & 0xFF, (rm_val >> 16) & 0xFF);
 | 
			
		||||
                const u8 diff4 = ARMul_UnsignedAbsoluteDifference((rn_val >> 24) & 0xFF, (rm_val >> 24) & 0xFF);
 | 
			
		||||
 | 
			
		||||
                u32 finalDif = (diff1 + diff2 + diff3 + diff4);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -392,6 +392,15 @@ ARMul_NthReg (ARMword instr, unsigned number)
 | 
			
		|||
    return (bit - 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Unsigned sum of absolute difference */
 | 
			
		||||
u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right)
 | 
			
		||||
{
 | 
			
		||||
	if (left > right)
 | 
			
		||||
		return left - right;
 | 
			
		||||
 | 
			
		||||
	return right - left;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Assigns the N and Z flags depending on the value of result.  */
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -600,6 +600,7 @@ extern ARMword ARMul_SwitchMode (ARMul_State *, ARMword, ARMword);
 | 
			
		|||
extern ARMword ARMul_Align (ARMul_State *, ARMword, ARMword);
 | 
			
		||||
extern ARMword ARMul_SwitchMode (ARMul_State *, ARMword, ARMword);
 | 
			
		||||
extern void ARMul_MSRCpsr (ARMul_State *, ARMword, ARMword);
 | 
			
		||||
extern u8 ARMul_UnsignedAbsoluteDifference(u8, u8);
 | 
			
		||||
extern void ARMul_SubOverflow (ARMul_State *, ARMword, ARMword, ARMword);
 | 
			
		||||
extern void ARMul_AddOverflow (ARMul_State *, ARMword, ARMword, ARMword);
 | 
			
		||||
extern void ARMul_AddOverflowQ(ARMul_State*, ARMword, ARMword);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue