use faster memset algoritm.
This commit is contained in:
parent
7f136b9ed2
commit
ef22e5a2ff
2 changed files with 80 additions and 41 deletions
56
wip-hugo/routines/memory/memset.s
Executable file → Normal file
56
wip-hugo/routines/memory/memset.s
Executable file → Normal file
|
@ -25,16 +25,54 @@ big_set_end:
|
||||||
BEQ small_set
|
BEQ small_set
|
||||||
JMP big_set
|
JMP big_set
|
||||||
|
|
||||||
|
;; Note that cpu cykels total: cy_tot = 66 to 69
|
||||||
|
;; But we skipp a BNE (cy = 2*) * [length (mod 255)]
|
||||||
|
;; The BNE case has an avrige of 2*255/2 = 255 so this is faster (on avrige.)
|
||||||
|
|
||||||
|
|
||||||
;;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
|
STA data_to_write ; cy = 3
|
||||||
small_set_loop:
|
LDA length ; cy = 3
|
||||||
STA (A_start), Y
|
STA length_copy ; cy = 3
|
||||||
DEY
|
|
||||||
BNE small_set_loop
|
;; calculate rts-position
|
||||||
STA (A_start), Y
|
LDX #$00 ; cy = 2
|
||||||
|
STX length + 1 ; cy = 3
|
||||||
|
;; 3 bytes = STA DEY NOP = seting 1 byte of memory.
|
||||||
|
;; So we need to calculate: length*3
|
||||||
|
Mult_16 A, length + 1 ; cy = 7
|
||||||
|
; A= length
|
||||||
|
ADC length_copy ; cy = 3
|
||||||
|
TAY
|
||||||
|
LDA length + 1 ; cy = 3
|
||||||
|
ADC #$00 ; cy = 2
|
||||||
|
STA length + 1 ; cy = 3
|
||||||
|
|
||||||
|
;; Now RTS_pointer + Y = length*3 + big_set_label
|
||||||
|
LDA #<big_set ; cy = 2
|
||||||
|
STA RTS_pointer ; cy = 3
|
||||||
|
LDA #>big_set ; cy = 2
|
||||||
|
ADC length + 1 ; cy = 3
|
||||||
|
STA RTS_pointer + 1 ; cy = 3
|
||||||
|
|
||||||
|
;; read data we will change to RTS
|
||||||
|
STY Y_copy ; cy = 3
|
||||||
|
LDA (RTS_pointer), Y ; cy = 5*
|
||||||
|
TAX ; cy = 2
|
||||||
|
|
||||||
|
;; set RTS in big_set
|
||||||
|
LDA #$60 ; cy = 2
|
||||||
|
STA (RTS_pointer), Y ; cy = 5*
|
||||||
|
|
||||||
|
;; JSR to modified big_set
|
||||||
|
LDY length_copy ; cy = 3
|
||||||
|
DEY ; because we want to count to Y=0 :)
|
||||||
|
LDA data_to_write ; cy = 3
|
||||||
|
JSR big_set ; cy = 6
|
||||||
|
|
||||||
|
;; revert changes
|
||||||
|
LDY Y_copy ; cy = 3
|
||||||
|
TXA ; cy = 2
|
||||||
|
STA (RTS_pointer), Y ; cy = 5*
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
.endproc
|
.endproc
|
||||||
|
|
|
@ -33,7 +33,8 @@ JMP exit
|
||||||
.include "routines/pixel/pixel_draw.s"
|
.include "routines/pixel/pixel_draw.s"
|
||||||
.include "routines/pixel/pixel_calc.s"
|
.include "routines/pixel/pixel_calc.s"
|
||||||
.include "routines/text/char_draw.s"
|
.include "routines/text/char_draw.s"
|
||||||
.include "routines/memory/memset_alt.s"
|
.include "routines/memory/memset.s"
|
||||||
|
;.include "routines/memory/clear_screen.s"
|
||||||
.include "routines/memory/memcpy.s"
|
.include "routines/memory/memcpy.s"
|
||||||
.include "routines/arithmatic/mult.s"
|
.include "routines/arithmatic/mult.s"
|
||||||
.include "routines/arithmatic/div.s"
|
.include "routines/arithmatic/div.s"
|
||||||
|
|
Loading…
Add table
Reference in a new issue