From 9687f1c387e232cbdc5b4c1b5b1fcbc1f04682ae Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 7 Feb 2013 23:44:58 -0500 Subject: [PATCH] Add BlockMove --- toolbox/mm.cpp | 49 ++++++++++++++++++++++++++++++++++++++++----- toolbox/mm.h | 1 + toolbox/toolbox.cpp | 5 +++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/toolbox/mm.cpp b/toolbox/mm.cpp index 5be9f7d..56a3472 100644 --- a/toolbox/mm.cpp +++ b/toolbox/mm.cpp @@ -73,19 +73,58 @@ namespace MM return true; } - uint16_t NewPtr(uint16_t trap) + + uint16_t BlockMove(uint16_t trap) { - /* on entry: - * A0 Number of logical bytes requested + /* + * on entry: + * A0 Pointer to source + * A1 Pointer to destination + * D0 Number of bytes to copy + * * on exit: * A0 Address of the new block or NIL * D0 Result code + * + */ + + uint32_t source = cpuGetAReg(0); + uint32_t dest = cpuGetAReg(1); + uint32_t count = cpuGetDReg(0); + + fprintf(stderr, "%04x BlockMove(%08x, %08x, %08x)\n", + trap, source, dest, count); + + // TODO -- 32-bit clean? + // TODO -- verify within MemorySize? + + #if 0 + if (source == 0 || dest == 0 || count == 0) + return 0; + #endif + + std::memmove(Memory + dest, Memory + source, count); + + return 0; + } + + + uint16_t NewPtr(uint16_t trap) + { + /* + * on entry: + * D0 Number of logical bytes requested + * + * on exit: + * A0 Address of the new block or NIL + * D0 Result code + * */ bool clear = trap & (1 << 9); - bool sys = trap & (1 << 10); + //bool sys = trap & (1 << 10); - uint32_t size = cpuGetAReg(0); + uint32_t size = cpuGetDReg(0); fprintf(stderr, "%04x NewPtr(%08x)\n", trap, size); diff --git a/toolbox/mm.h b/toolbox/mm.h index 5d483eb..72774a4 100644 --- a/toolbox/mm.h +++ b/toolbox/mm.h @@ -12,6 +12,7 @@ namespace MM bool Init(uint8_t *memory, uint32_t memorySize, uint32_t reserved); + uint16_t BlockMove(uint16_t trap); uint16_t NewPtr(uint16_t trap); } diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index ef56123..d7cb55a 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -23,6 +23,11 @@ namespace ToolBox { switch (trap) { + // BlockMove (sourcePtr,destPtr: Ptr; byteCount: Size); + case 0xa02e: + d0 = MM::BlockMove(trap); + break; + // NewPtr [Sys, Clear] (logicalSize: Size): Ptr; case 0xa11e: case 0xa31e: