From fc0dba6c9ca10bd40bd1210530b88fa8184e4e44 Mon Sep 17 00:00:00 2001 From: "Matthias@Dell" Date: Wed, 27 Dec 2023 16:55:40 +0100 Subject: [PATCH] add memcopy16 --- programs/memcopy.s65 | 51 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/programs/memcopy.s65 b/programs/memcopy.s65 index 53c3fc6..b1b877c 100644 --- a/programs/memcopy.s65 +++ b/programs/memcopy.s65 @@ -3,15 +3,16 @@ INCLUDE_MEMCOPY = 1 .include "system.h65" -.export memcopy +.export memcopy,memcopy16 .code -;******************************************************************************** -; @function Copy a block of memory to a different address -; @param ARG0-1: Source address -; @param ARG2-3: Target address -; @param y: Number of bytes to copy -;******************************************************************************** +;;******************************************************************************** +;; @function Copy a block of memory to a different address +;; @param ARG0-1: Source address +;; @param ARG2-3: Target address +;; @param Y: Number of bytes to copy +;; @modifies: A,Y +;;******************************************************************************** .proc memcopy cpy #0 beq @rts @@ -24,5 +25,41 @@ INCLUDE_MEMCOPY = 1 @rts: rts .endproc + +;;******************************************************************************** +;; @function Copy a block of memory to a different address +;; @param ARG0-1: Source address +;; @param ARG2-3: Target address +;; @param ARG5-6: Number of bytes to copy (LE) +;; @modifies: A,Y +;;******************************************************************************** +.proc memcopy16 + lda ARG6 + beq @last_page ; no full page + ldy #$ff + bra @copy_byte +@next_page: ; y is 0 + lda ARG6 + beq @rts ; done + inc ARG1 + inc ARG3 + dec ARG6 + beq @last_page + ldy #$ff +@copy_byte: + lda (ARG0),y + sta (ARG2),y +@dec_y: + dey + beq @next_page + bra @copy_byte +@last_page: + ldy ARG5 + dey + bra @copy_byte +@rts: + rts +.endproc + .endif ; guard