mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:02:43 +00:00 
			
		
		
		
	UserspaceEmulator: Implement the LODSB/LODSW/LODSD instructions
Look how nice they look with the new loop instruction helpers. :^)
This commit is contained in:
		
							parent
							
								
									c3441719ea
								
							
						
					
					
						commit
						41bbedc41d
					
				
					 1 changed files with 26 additions and 3 deletions
				
			
		|  | @ -1369,9 +1369,32 @@ void SoftCPU::LGS_reg32_mem32(const X86::Instruction&) { TODO(); } | ||||||
| void SoftCPU::LIDT(const X86::Instruction&) { TODO(); } | void SoftCPU::LIDT(const X86::Instruction&) { TODO(); } | ||||||
| void SoftCPU::LLDT_RM16(const X86::Instruction&) { TODO(); } | void SoftCPU::LLDT_RM16(const X86::Instruction&) { TODO(); } | ||||||
| void SoftCPU::LMSW_RM16(const X86::Instruction&) { TODO(); } | void SoftCPU::LMSW_RM16(const X86::Instruction&) { TODO(); } | ||||||
| void SoftCPU::LODSB(const X86::Instruction&) { TODO(); } | 
 | ||||||
| void SoftCPU::LODSD(const X86::Instruction&) { TODO(); } | template<typename T> | ||||||
| void SoftCPU::LODSW(const X86::Instruction&) { TODO(); } | ALWAYS_INLINE static void do_lods(SoftCPU& cpu, const X86::Instruction& insn) | ||||||
|  | { | ||||||
|  |     auto src_segment = cpu.segment(insn.segment_prefix().value_or(X86::SegmentRegister::DS)); | ||||||
|  |     cpu.do_once_or_repeat<true>(insn, [&] { | ||||||
|  |         auto src = cpu.read_memory<T>({ src_segment, cpu.source_index(insn.a32()) }); | ||||||
|  |         cpu.gpr<T>(X86::RegisterAL) = src; | ||||||
|  |         cpu.step_source_index(insn.a32(), sizeof(T)); | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void SoftCPU::LODSB(const X86::Instruction& insn) | ||||||
|  | { | ||||||
|  |     do_lods<u8>(*this, insn); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void SoftCPU::LODSD(const X86::Instruction& insn) | ||||||
|  | { | ||||||
|  |     do_lods<u32>(*this, insn); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void SoftCPU::LODSW(const X86::Instruction& insn) | ||||||
|  | { | ||||||
|  |     do_lods<u16>(*this, insn); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void SoftCPU::LOOPNZ_imm8(const X86::Instruction& insn) | void SoftCPU::LOOPNZ_imm8(const X86::Instruction& insn) | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling