improve memset with code unrolling

This commit is contained in:
hugova 2025-07-13 21:57:14 +02:00
parent fea2a85b54
commit 6ee280abec
2 changed files with 25 additions and 19 deletions

View file

@ -8,21 +8,28 @@
;; big_set sets the memory in $ff chunks. ;; big_set sets the memory in $ff chunks.
;; skipp if length >= $ff ;; skipp if length >= $ff
LDX length +1 LDX length +1
BEQ small_set BNE big_set
JMP small_set
big_set:
big_set: ;sets $ff of memory
LDY #$ff LDY #$ff
big_set_loop: .repeat $ff
STA (A_start), Y STA (A_start), Y
DEY DEY
BNE big_set_loop .endrepeat
STA (A_start), Y ; don't forget Y=0 STA (A_start), Y ; dont forget Y =0
;;maybe move to next chunk big_set_end:
;;set all hole $ff memory chunks!
INC A_start + 1 INC A_start + 1
DEC length + 1 DEC length + 1
BNE big_set BEQ small_set
JMP big_set
;;sets the rest of the memory ;;sets the rest of the memory
;; note that this can use code above (smc) or the same method. may implement later.
small_set: small_set:
LDY length LDY length
small_set_loop: small_set_loop:
@ -31,5 +38,4 @@ small_set_loop:
BNE small_set_loop BNE small_set_loop
STA (A_start), Y STA (A_start), Y
RTS RTS
.endproc .endproc

View file

@ -8,17 +8,17 @@
.include "STARTUP.s" .include "STARTUP.s"
;.include "dubbel_buffer/raster_irqs.s" ;.include "dubbel_buffer/raster_irqs.s"
;.include "routines/arithmatic/mult_test.s" .include "routines/arithmatic/mult_test.s"
;.include "routines/arithmatic/div_test.s" .include "routines/arithmatic/div_test.s"
;.include "routines/circle/circle_test.s" .include "routines/circle/circle_test.s"
;.include "routines/circle/circle_test_size.s" .include "routines/circle/circle_test_size.s"
;.include "routines/circle/circle_test_position.s" .include "routines/circle/circle_test_position.s"
;.include "routines/line/line_test.s" .include "routines/line/line_test.s"
;.include "routines/text/char_draw_test.s" .include "routines/text/char_draw_test.s"
;.include "routines/pixel/pixel_test.s" .include "routines/pixel/pixel_test.s"
;.include "routines/memory/memcpy_test.s" .include "routines/memory/memcpy_test.s"
.include "routines/memory/memset_test.s" .include "routines/memory/memset_test.s"
;.include "routines/triangle/triangle_test.s" .include "routines/triangle/triangle_test.s"
exit: exit:
JMP exit JMP exit
.include "../wip-duuqnd/public.inc" .include "../wip-duuqnd/public.inc"