c64-livecoding/wip-hugo/routines/memory/memcpy.s
hugova 7f56f90613 Changed 16-bit value syntax from using > and < in addresses to using +1.
This was recomended by dicander and duunqnd because  A =$ABAC
looks like one address and not 2 zero-page addresses.
2025-04-28 12:56:52 +02:00

33 lines
900 B
ArmAsm

;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;;Move memory from B_start B_end to A_start , (implied address)
;;Modifies A,X and B_start gets modified
.proc memcpy
.include "mem.inc"
;; Let Y + A_start lower nibble represent A_start
;; therefor: A_start = Y - A_start
;; With Y we mean what Y will represent later aka >B_start
Sub_16 A_start, A_start + 1, B_start, #$00
;;Lets move B_start lover-nibble to Y
LDY B_start
LDA #$00
STA B_start
loop:
Lag_16 B_end, B_end + 1, A, B_start, end_loop
LDA (B_start), Y
STA (A_start), Y
;Tip save time by counting downward, fast to check if Y ==0 // hugo
INY
TYA
CMP #$ff
BNE loop
;; Fix overflow
LDY #$00
INC A_start + 1
INC B_start + 1
JMP loop
end_loop:
RTS
.endproc