.ifndef INCLUDE_MEMCOPY INCLUDE_MEMCOPY = 1 .include "system.h65" .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 ;; @modifies A,Y ;;******************************************************************************** .proc memcopy cpy #0 beq @rts @copy_byte: dey lda (ARG0),y sta (ARG2),y cpy #0 bne @copy_byte @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