c64-livecoding/wip-hugo/routines/memory/memset.s
2025-07-15 22:37:56 +02:00

40 lines
999 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
BNE big_set
JMP small_set
big_set: ;sets $ff of memory
;; Y value do not matter, will go through all anyway!
.repeat $ff
STA (A_start), Y
DEY
.endrepeat
STA (A_start), Y ; dont forget Y =0
big_set_end:
;;set all hole $ff memory chunks!
INC A_start + 1
DEX ;; length +1 --
BEQ small_set
JMP big_set
;;sets the rest of the memory
;; note that this can use code above (smc) or the same method. may implement later.
small_set:
LDY length
small_set_loop:
STA (A_start), Y
DEY
BNE small_set_loop
STA (A_start), Y
RTS
.endproc