mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:52:44 +00:00 
			
		
		
		
	UserspaceEmulator: Improve FCOMI/FCOMIP/FUCOMI/FUCOMIP
These instructions now operate on the specified FPU stack entry instead of always using ST(0) and ST(1). FUCOMI and FUCOMIP also handle NaN values slightly better.
This commit is contained in:
		
							parent
							
								
									d4509647d8
								
							
						
					
					
						commit
						60ff27c633
					
				
					 1 changed files with 16 additions and 8 deletions
				
			
		|  | @ -1709,24 +1709,32 @@ void SoftCPU::FNINIT(const X86::Instruction&) { TODO_INSN(); } | ||||||
| void SoftCPU::FNSETPM(const X86::Instruction&) { TODO_INSN(); } | void SoftCPU::FNSETPM(const X86::Instruction&) { TODO_INSN(); } | ||||||
| void SoftCPU::FLD_RM80(const X86::Instruction&) { TODO_INSN(); } | void SoftCPU::FLD_RM80(const X86::Instruction&) { TODO_INSN(); } | ||||||
| 
 | 
 | ||||||
| void SoftCPU::FUCOMI(const X86::Instruction&) | void SoftCPU::FUCOMI(const X86::Instruction& insn) | ||||||
| { | { | ||||||
|  |     auto i = insn.rm() & 7; | ||||||
|     // FIXME: Unordered comparison checks.
 |     // FIXME: Unordered comparison checks.
 | ||||||
|     // FIXME: QNaN / exception handling.
 |     // FIXME: QNaN / exception handling.
 | ||||||
|     // FIXME: Set C0, C2, C3 in FPU status word.
 |     // FIXME: Set C0, C2, C3 in FPU status word.
 | ||||||
|     set_zf(fpu_get(0) == fpu_get(1)); |     if (__builtin_isnan(fpu_get(0)) || __builtin_isnan(fpu_get(i))) { | ||||||
|     set_pf(false); |         set_zf(true); | ||||||
|     set_cf(fpu_get(0) < fpu_get(1)); |         set_pf(true); | ||||||
|     set_of(false); |         set_cf(true); | ||||||
|  |     } else { | ||||||
|  |         set_zf(fpu_get(0) == fpu_get(i)); | ||||||
|  |         set_pf(false); | ||||||
|  |         set_cf(fpu_get(0) < fpu_get(i)); | ||||||
|  |         set_of(false); | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void SoftCPU::FCOMI(const X86::Instruction&) | void SoftCPU::FCOMI(const X86::Instruction& insn) | ||||||
| { | { | ||||||
|  |     auto i = insn.rm() & 7; | ||||||
|     // FIXME: QNaN / exception handling.
 |     // FIXME: QNaN / exception handling.
 | ||||||
|     // FIXME: Set C0, C2, C3 in FPU status word.
 |     // FIXME: Set C0, C2, C3 in FPU status word.
 | ||||||
|     set_zf(fpu_get(0) == fpu_get(1)); |     set_zf(fpu_get(0) == fpu_get(i)); | ||||||
|     set_pf(false); |     set_pf(false); | ||||||
|     set_cf(fpu_get(0) < fpu_get(1)); |     set_cf(fpu_get(0) < fpu_get(i)); | ||||||
|     set_of(false); |     set_of(false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling