add memcopy16
This commit is contained in:
parent
25d0fcfb90
commit
fc0dba6c9c
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user