optimise memset_alt.s
This commit is contained in:
parent
bf7021a3a9
commit
38070296d0
3 changed files with 18 additions and 13 deletions
|
@ -9,3 +9,4 @@
|
||||||
data_to_write = $D8
|
data_to_write = $D8
|
||||||
length_copy = $d9 ; 16-bit vale (uses da)
|
length_copy = $d9 ; 16-bit vale (uses da)
|
||||||
instruction_backup = $db
|
instruction_backup = $db
|
||||||
|
Y_copy =$dc
|
||||||
|
|
|
@ -32,25 +32,29 @@ small_set:
|
||||||
STA length_copy
|
STA length_copy
|
||||||
|
|
||||||
;; calculate rts-position
|
;; calculate rts-position
|
||||||
LDA #$00
|
LDX #$00
|
||||||
STA length + 1
|
STX length + 1
|
||||||
;; 4 bytes = STA DEY NOP = seting 1 byte of memory.
|
;; 3 bytes = STA DEY NOP = seting 1 byte of memory.
|
||||||
;; So we need to calculate: length*4
|
;; So we need to calculate: length*3
|
||||||
Mult_16 length, length + 1
|
Mult_16 length, length + 1
|
||||||
Add_16 length, length + 1, length_copy, #$00
|
; A= length_copy
|
||||||
;; Now RTS_pointer = length*4 + big_set_label
|
|
||||||
CLC
|
|
||||||
LDA #<big_set
|
|
||||||
ADC length
|
ADC length
|
||||||
|
TAY
|
||||||
|
LDA length + 1
|
||||||
|
ADC #$00
|
||||||
|
STA length + 1
|
||||||
|
|
||||||
|
;; Now RTS_pointer + Y = length*3 + big_set_label
|
||||||
|
LDA #<big_set
|
||||||
STA RTS_pointer
|
STA RTS_pointer
|
||||||
LDA #>big_set
|
LDA #>big_set
|
||||||
ADC length + 1
|
ADC length + 1
|
||||||
STA RTS_pointer + 1
|
STA RTS_pointer + 1
|
||||||
|
|
||||||
;; read data we will change to RTS
|
;; read data we will change to RTS
|
||||||
LDY #$00
|
STY Y_copy
|
||||||
LDA (RTS_pointer), Y
|
LDA (RTS_pointer), Y
|
||||||
STA instruction_backup
|
TAX
|
||||||
|
|
||||||
;; set RTS in big_set
|
;; set RTS in big_set
|
||||||
LDA #$60
|
LDA #$60
|
||||||
|
@ -63,8 +67,8 @@ small_set:
|
||||||
JSR big_set
|
JSR big_set
|
||||||
|
|
||||||
;; revert changes
|
;; revert changes
|
||||||
LDY #$00
|
LDY Y_copy
|
||||||
LDA instruction_backup
|
TXA
|
||||||
STA (RTS_pointer), Y
|
STA (RTS_pointer), Y
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
|
@ -28,7 +28,7 @@ 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.s"
|
.include "routines/memory/memset_alt.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