mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-25 04:31:52 +00:00
xp support for reading 80-bit extended numbers on platforms without a native 80-bit extended type.
previously this meant win32 and linux arm, now this includes Apple ARM as well.
This commit is contained in:
parent
58f2557df5
commit
0cca883287
@ -40,13 +40,13 @@
|
|||||||
|
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
|
|
||||||
|
|
||||||
#include <sane/floating_point.h>
|
#include <sane/floating_point.h>
|
||||||
#include <sane/sane.h>
|
#include <sane/sane.h>
|
||||||
#include <sane/comp.h>
|
#include <sane/comp.h>
|
||||||
|
|
||||||
using ToolBox::Log;
|
using ToolBox::Log;
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SIGDIGLEN = 20,
|
SIGDIGLEN = 20,
|
||||||
};
|
};
|
||||||
@ -171,25 +171,17 @@ namespace fp = floating_point;
|
|||||||
template<>
|
template<>
|
||||||
long double readnum<long double>(uint32_t address)
|
long double readnum<long double>(uint32_t address)
|
||||||
{
|
{
|
||||||
char buffer[16];
|
uint8_t buffer[16];
|
||||||
|
long double ld;
|
||||||
static_assert(sizeof(long double) == 16, "unexpected long double size");
|
|
||||||
|
|
||||||
|
|
||||||
// read and swap 10 bytes
|
|
||||||
// this is very much little endian.
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < 10; ++i)
|
for (unsigned i = 0; i < 10; ++i)
|
||||||
{
|
buffer[i] = memoryReadByte(address + i);
|
||||||
buffer[9 - i] = memoryReadByte(address + i);
|
|
||||||
}
|
|
||||||
// remainder are 0-filled.
|
|
||||||
for (unsigned i = 10; i < 16; ++i)
|
|
||||||
buffer[i] = 0;
|
|
||||||
|
|
||||||
// now cast...
|
fp::info fpi;
|
||||||
|
fpi.read(fp::format<10, endian::big>{}, buffer);
|
||||||
|
|
||||||
return *((long double *)buffer);
|
fpi.write(ld);
|
||||||
|
return ld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -239,16 +231,15 @@ namespace fp = floating_point;
|
|||||||
template<>
|
template<>
|
||||||
void writenum<long double>(long double value, uint32_t address)
|
void writenum<long double>(long double value, uint32_t address)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(value) == 16, "unexpected long double size");
|
uint8_t buffer[16];
|
||||||
|
|
||||||
char buffer[16];
|
fp::info fpi;
|
||||||
|
fpi.read(value);
|
||||||
|
|
||||||
std::memcpy(buffer, &value, sizeof(value));
|
fpi.write(fp::format<10, endian::big>{}, buffer);
|
||||||
|
|
||||||
// copy 10 bytes over
|
for (unsigned i = 0; i < 10; ++i)
|
||||||
// little-endian specific.
|
memoryWriteByte(buffer[i], address + i);
|
||||||
for(unsigned i = 0; i < 10; ++i)
|
|
||||||
memoryWriteByte(buffer[9 - i], address + i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
decform read_decform(uint32_t address)
|
decform read_decform(uint32_t address)
|
||||||
|
Loading…
Reference in New Issue
Block a user