diff --git a/cpu/fmem.h b/cpu/fmem.h index 3ab96ee..d5b3e17 100644 --- a/cpu/fmem.h +++ b/cpu/fmem.h @@ -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); diff --git a/cpu/memory.c b/cpu/memory.c index b93617d..a7d532c 100644 --- a/cpu/memory.c +++ b/cpu/memory.c @@ -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; + } + +} +