;;; -*- 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 LDY #$ff .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 DEC 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