read/write int64_t (for sane support)

This commit is contained in:
Kelvin Sherlock 2013-02-20 23:10:00 -05:00
parent e56a311c2e
commit bba0679650
2 changed files with 39 additions and 2 deletions

View File

@ -16,9 +16,11 @@ extern uint8_t *memoryPointer(uint32_t address);
extern UBY memoryReadByte(ULO address);
extern UWO memoryReadWord(ULO address);
extern ULO memoryReadLong(ULO address);
extern uint64_t memoryReadLongLong(ULO address);
extern void memoryWriteByte(UBY data, ULO address);
extern void memoryWriteWord(UWO data, ULO address);
extern void memoryWriteLong(ULO data, ULO address);
extern void memoryWriteLongLong(uint64_t data, ULO address);
extern UWO memoryChipReadWord(ULO address);
extern void memoryChipWriteWord(UWO data, ULO address);

View File

@ -108,15 +108,27 @@ ULO memoryReadLong(ULO address)
if (address & 0x01) memoryOddRead(address);
if (address + 1 < MemorySize)
if (address + 3 < MemorySize)
return (Memory[address++] << 24)
| (Memory[address++] << 16)
| (Memory[address++] << 8)
| (Memory[address++] << 0);
return 0;
}
uint64_t memoryReadLongLong(ULO address)
{
uint64_t tmp;
tmp = memoryReadLong(address);
tmp <<= 32;
tmp |= memoryReadLong(address + 4);
return tmp;
}
void memoryWriteByte(UBY data, ULO address)
{
if (address < MemoryGlobalLog)
@ -168,3 +180,26 @@ void memoryWriteLong(ULO data, ULO address)
}
void memoryWriteLongLong(uint64_t data, ULO address)
{
if (address < MemoryGlobalLog)
{
fprintf(stderr, "memoryWriteLongLong(%08llx, %08x)\n", data, address);
}
if (address & 0x01) memoryOddWrite(address);
if (address + 7 < MemorySize)
{
Memory[address++] = data >> 56;
Memory[address++] = data >> 48;
Memory[address++] = data >> 40;
Memory[address++] = data >> 32;
Memory[address++] = data >> 24;
Memory[address++] = data >> 16;
Memory[address++] = data >> 8;
Memory[address++] = data >> 0;
}
}