c64-livecoding/wip-hugo/routines/memory/memset.s

35 lines
787 B
ArmAsm
Executable file

;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;; Sets memory in 'A'-registry to all addresses from 'A_start' until 'A_start' + 'length'
;; Modifies A, X and A_start
.proc memset
.include "mem.inc"
;; big_set sets the memory in $ff chunks.
;; skipp if length >= $ff
LDX length +1
BEQ small_set
big_set:
LDY #$ff
big_set_loop:
STA (A_start), Y
DEY
BNE big_set_loop
STA (A_start), Y ; don't forget Y=0
;;maybe move to next chunk
INC A_start + 1
DEC length + 1
BNE big_set
;;sets the rest of the memory
small_set:
LDY length
small_set_loop:
STA (A_start), Y
DEY
BNE small_set_loop
STA (A_start), Y
RTS
.endproc