PowerPC: HostR/W float/double added

This commit is contained in:
Sepalani 2016-12-09 17:16:47 +00:00
parent 1cd75f9b19
commit 048513183e
2 changed files with 40 additions and 0 deletions

View File

@ -581,6 +581,26 @@ u64 HostRead_U64(const u32 address)
return ReadFromHardware<XCheckTLBFlag::NoException, u64>(address);
}
float HostRead_F32(const u32 address)
{
const u32 integral = HostRead_U32(address);
float real;
std::memcpy(&real, &integral, sizeof(float));
return real;
}
double HostRead_F64(const u32 address)
{
const u64 integral = HostRead_U64(address);
double real;
std::memcpy(&real, &integral, sizeof(double));
return real;
}
void HostWrite_U8(const u8 var, const u32 address)
{
WriteToHardware<XCheckTLBFlag::NoException, u8>(address, var);
@ -601,6 +621,22 @@ void HostWrite_U64(const u64 var, const u32 address)
WriteToHardware<XCheckTLBFlag::NoException, u64>(address, var);
}
void HostWrite_F32(const float var, const u32 address)
{
u32 integral;
std::memcpy(&integral, &var, sizeof(u32));
HostWrite_U32(integral, address);
}
void HostWrite_F64(const double var, const u32 address)
{
u64 integral;
std::memcpy(&integral, &var, sizeof(u64));
HostWrite_U64(integral, address);
}
std::string HostGetString(u32 address, size_t size)
{
std::string s;

View File

@ -218,12 +218,16 @@ u8 HostRead_U8(u32 address);
u16 HostRead_U16(u32 address);
u32 HostRead_U32(u32 address);
u64 HostRead_U64(u32 address);
float HostRead_F32(u32 address);
double HostRead_F64(u32 address);
u32 HostRead_Instruction(u32 address);
void HostWrite_U8(u8 var, u32 address);
void HostWrite_U16(u16 var, u32 address);
void HostWrite_U32(u32 var, u32 address);
void HostWrite_U64(u64 var, u32 address);
void HostWrite_F32(float var, u32 address);
void HostWrite_F64(double var, u32 address);
// Returns whether a read or write to the given address will resolve to a RAM
// access given the current CPU state.