Advertisement
Guest User

Untitled

a guest
Jun 11th, 2019
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *=$C000
  2.  
  3. memcpySrc = $FB
  4. memcpyDst = $FD
  5. memcpyLen = $9B
  6.  
  7.  
  8. ; set for characters
  9.      lda #$95
  10.      sta memcpySrc
  11.      lda #$35
  12.      sta memcpySrc+1
  13.  
  14.      lda #$00
  15.      sta memcpyDst
  16.      lda #$04
  17.      sta memcpyDst+1
  18.  
  19.      lda #$E8
  20.      sta memcpyLen
  21.      lda #$03
  22.      sta memcpyLen+1
  23.  
  24.      jsr memcpy
  25.  
  26. ; set for attributes
  27.      lda #$95
  28.      sta memcpySrc
  29.      lda #$39
  30.      sta memcpySrc+1
  31.  
  32.      lda #$00
  33.      sta memcpyDst
  34.      lda #$d8
  35.      sta memcpyDst+1
  36.  
  37.      lda #$E8
  38.      sta memcpyLen
  39.      lda #$03
  40.      sta memcpyLen+1
  41.  
  42.      jsr memcpy
  43.  
  44. ; and we're done.
  45.      rts
  46.  
  47.  
  48. memcpy
  49.      ldy #0
  50.      ldx memcpyLen+1
  51.      beq memcpyShort           ; We need only the short version for <1 pages
  52.  
  53. memcpyLoopLong                 ; Copy X pages
  54.      lda (memcpySrc),y         ; Loop unrolling can be done with confidence here
  55.      sta (memcpyDst),y         ; any power of 2 will work
  56.      iny
  57.      bne memcpyLoopLong
  58.      dex
  59.      beq memcpyShort
  60.      inc memcpySrc+1           ; Go to the next page
  61.      inc memcpyDst+1
  62.      jmp memcpyLoopLong
  63.  
  64. memcpyShort                    ; Copy remaining bytes
  65.      inc memcpySrc+1           ; should these two lines be here to
  66.      inc memcpyDst+1           ; increment the page number?
  67.      ldx memcpyLen
  68.      beq memcpyEnd
  69.  
  70. memcpyLoopShort                ; Copy X bytes
  71.      lda (memcpySrc),y
  72.      sta (memcpyDst),y
  73.      iny
  74.      dex
  75.      bne memcpyLoopShort
  76.  
  77. memcpyEnd
  78.      rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement