Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *=$C000
- memcpySrc = $FB
- memcpyDst = $FD
- memcpyLen = $9B
- ; set for characters
- lda #$95
- sta memcpySrc
- lda #$35
- sta memcpySrc+1
- lda #$00
- sta memcpyDst
- lda #$04
- sta memcpyDst+1
- lda #$E8
- sta memcpyLen
- lda #$03
- sta memcpyLen+1
- jsr memcpy
- ; set for attributes
- lda #$95
- sta memcpySrc
- lda #$39
- sta memcpySrc+1
- lda #$00
- sta memcpyDst
- lda #$d8
- sta memcpyDst+1
- lda #$E8
- sta memcpyLen
- lda #$03
- sta memcpyLen+1
- jsr memcpy
- ; and we're done.
- rts
- memcpy
- ldy #0
- ldx memcpyLen+1
- beq memcpyShort ; We need only the short version for <1 pages
- memcpyLoopLong ; Copy X pages
- lda (memcpySrc),y ; Loop unrolling can be done with confidence here
- sta (memcpyDst),y ; any power of 2 will work
- iny
- bne memcpyLoopLong
- dex
- beq memcpyShort
- inc memcpySrc+1 ; Go to the next page
- inc memcpyDst+1
- jmp memcpyLoopLong
- memcpyShort ; Copy remaining bytes
- inc memcpySrc+1 ; should these two lines be here to
- inc memcpyDst+1 ; increment the page number?
- ldx memcpyLen
- beq memcpyEnd
- memcpyLoopShort ; Copy X bytes
- lda (memcpySrc),y
- sta (memcpyDst),y
- iny
- dex
- bne memcpyLoopShort
- memcpyEnd
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement