From 6ee280abec546d718caa5cfea13973798533cecb Mon Sep 17 00:00:00 2001 From: hugova Date: Sun, 13 Jul 2025 21:57:14 +0200 Subject: [PATCH] improve memset with code unrolling --- wip-hugo/routines/memory/memset.s | 24 +++++++++++++++--------- wip-hugo/source.s | 20 ++++++++++---------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/wip-hugo/routines/memory/memset.s b/wip-hugo/routines/memory/memset.s index 4696260..1322528 100755 --- a/wip-hugo/routines/memory/memset.s +++ b/wip-hugo/routines/memory/memset.s @@ -8,28 +8,34 @@ ;; big_set sets the memory in $ff chunks. ;; skipp if length >= $ff LDX length +1 -BEQ small_set +BNE big_set +JMP small_set -big_set: + +big_set: ;sets $ff of memory LDY #$ff -big_set_loop: + .repeat $ff STA (A_start), Y DEY - BNE big_set_loop - STA (A_start), Y ; don't forget Y=0 - ;;maybe move to next chunk + .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 - BNE big_set + 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 + LDY length small_set_loop: STA (A_start), Y DEY BNE small_set_loop STA (A_start), Y RTS - .endproc diff --git a/wip-hugo/source.s b/wip-hugo/source.s index 542565f..1f19dfc 100644 --- a/wip-hugo/source.s +++ b/wip-hugo/source.s @@ -8,17 +8,17 @@ .include "STARTUP.s" ;.include "dubbel_buffer/raster_irqs.s" -;.include "routines/arithmatic/mult_test.s" -;.include "routines/arithmatic/div_test.s" -;.include "routines/circle/circle_test.s" -;.include "routines/circle/circle_test_size.s" -;.include "routines/circle/circle_test_position.s" -;.include "routines/line/line_test.s" -;.include "routines/text/char_draw_test.s" -;.include "routines/pixel/pixel_test.s" -;.include "routines/memory/memcpy_test.s" +.include "routines/arithmatic/mult_test.s" +.include "routines/arithmatic/div_test.s" +.include "routines/circle/circle_test.s" +.include "routines/circle/circle_test_size.s" +.include "routines/circle/circle_test_position.s" +.include "routines/line/line_test.s" +.include "routines/text/char_draw_test.s" +.include "routines/pixel/pixel_test.s" +.include "routines/memory/memcpy_test.s" .include "routines/memory/memset_test.s" -;.include "routines/triangle/triangle_test.s" +.include "routines/triangle/triangle_test.s" exit: JMP exit .include "../wip-duuqnd/public.inc"