Skip to content

Commit

Permalink
Working on FPU
Browse files Browse the repository at this point in the history
  • Loading branch information
captainys committed Sep 29, 2021
1 parent 92e8a05 commit 7dc815a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/cpu/i486.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class i486DX : public CPU
std::vector <std::string> GetStateText(void) const;

// Returns clocks passed.
unsigned int FCHS(i486DX &cpu);
unsigned int FLD1(i486DX &cpu);
unsigned int FLDL2T(i486DX &cpu);
unsigned int FLDZ(i486DX &cpu);
Expand Down
20 changes: 16 additions & 4 deletions src/cpu/i486inst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ void i486DX::FetchOperand(CPUCLASS &cpu,Instruction &inst,Operand &op1,Operand &
{
unsigned int MODR_M;
FUNCCLASS::PeekOperand8(cpu,MODR_M,inst,ptr,seg,offset,mem);
if(0xF0<=MODR_M && MODR_M<=0xFF)
if(0xE0==MODR_M || (0xF0<=MODR_M && MODR_M<=0xFF))
{
FUNCCLASS::FetchOperand8(cpu,inst,ptr,seg,offset,mem);
}
Expand Down Expand Up @@ -2169,6 +2169,17 @@ std::string i486DX::Instruction::Disassemble(const Operand &op1In,const Operand
{
disasm="?FPUINST"+cpputil::Ubtox(opCode)+" "+cpputil::Ubtox(operand[0]);
}
else if(0xC0<=operand[0] && operand[0]<=0xC7)
{
disasm="FLD ";
disasm+="ST(";
disasm.push_back('0'+operand[0]-0xC0);
disasm+=")";
}
else if(0xE0==operand[0])
{
disasm="FCHS";
}
else if(0xE8==operand[0])
{
disasm="FLD1";
Expand Down Expand Up @@ -5513,19 +5524,20 @@ unsigned int i486DX::RunOneInstruction(Memory &mem,InOut &io)
if(0xF0<=inst.operand[0] && inst.operand[0]<=0xFF)
{
}
else if(0xE0==inst.operand[0])
{
clocksPassed=state.fpuState.FCHS(*this);
}
else if(0xE8==inst.operand[0])
{
// FLD1
clocksPassed=state.fpuState.FLD1(*this);
}
else if(0xE9==inst.operand[0])
{
// FLDL2T
clocksPassed=state.fpuState.FLDL2T(*this);
}
else if(0xEE==inst.operand[0])
{
// FLDZ
clocksPassed=state.fpuState.FLDZ(*this);
}
else
Expand Down
16 changes: 16 additions & 0 deletions src/cpu/i487.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ std::vector <std::string> i486DX::FPUState::GetStateText(void) const
return text;
}

unsigned int i486DX::FPUState::FCHS(i486DX &cpu)
{
if(true==enabled)
{
if(0<stackPtr)
{
stack[stackPtr-1].value=-stack[stackPtr-1].value;
return 4;
}
else
{
// Raise NM exception.
}
}
return 0; // Let it abort.
}
unsigned int i486DX::FPUState::FLD1(i486DX &cpuState)
{
if(true==enabled)
Expand Down

0 comments on commit 7dc815a

Please sign in to comment.