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
|
||||
length_copy = $d9 ; 16-bit vale (uses da)
|
||||
instruction_backup = $db
|
||||
Y_copy =$dc
|
||||
|
|
|
@ -32,25 +32,29 @@ small_set:
|
|||
STA length_copy
|
||||
|
||||
;; calculate rts-position
|
||||
LDA #$00
|
||||
STA length + 1
|
||||
;; 4 bytes = STA DEY NOP = seting 1 byte of memory.
|
||||
;; So we need to calculate: length*4
|
||||
LDX #$00
|
||||
STX length + 1
|
||||
;; 3 bytes = STA DEY NOP = seting 1 byte of memory.
|
||||
;; So we need to calculate: length*3
|
||||
Mult_16 length, length + 1
|
||||
Add_16 length, length + 1, length_copy, #$00
|
||||
;; Now RTS_pointer = length*4 + big_set_label
|
||||
CLC
|
||||
LDA #<big_set
|
||||
; A= length_copy
|
||||
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
|
||||
LDA #>big_set
|
||||
ADC length + 1
|
||||
STA RTS_pointer + 1
|
||||
|
||||
;; read data we will change to RTS
|
||||
LDY #$00
|
||||
STY Y_copy
|
||||
LDA (RTS_pointer), Y
|
||||
STA instruction_backup
|
||||
TAX
|
||||
|
||||
;; set RTS in big_set
|
||||
LDA #$60
|
||||
|
@ -63,8 +67,8 @@ small_set:
|
|||
JSR big_set
|
||||
|
||||
;; revert changes
|
||||
LDY #$00
|
||||
LDA instruction_backup
|
||||
LDY Y_copy
|
||||
TXA
|
||||
STA (RTS_pointer), Y
|
||||
|
||||
RTS
|
||||
|
|
|
@ -28,7 +28,7 @@ JMP exit
|
|||
.include "routines/pixel/pixel_draw.s"
|
||||
.include "routines/pixel/pixel_calc.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/arithmatic/mult.s"
|
||||
.include "routines/arithmatic/div.s"
|
||||
|
|
Loading…
Add table
Reference in a new issue