User Tools

Site Tools


base:advanced_optimizing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
base:advanced_optimizing [2021-03-05 16:57] – [Forming terms] bitbreakerbase:advanced_optimizing [2022-02-08 13:56] – [Shifting] bitbreaker
Line 718: Line 718:
  
 The advantage is, that you can move bits also across registers and are not restricted to the accumulator only. The advantage is, that you can move bits also across registers and are not restricted to the accumulator only.
 +
 +When shifting, we handle 9 bits, as the bit falling out at one edge of the byte will be stored in the carry, and the carry will be shifted in. This will introduce a gap of one bit, when we wrap around bits:
 +
 +<code>
 +        lda #%11111111
 +        clc
 +        rol
 +        rol
 +        ;-> A = %11111101
 +        ;              ^
 +        ;             gap :-(
 +</code>
 +
 +To avoid that behaviour there's several ways around it:
 +
 +<code>
 +        lda #%11111111
 +        asl
 +        adc #0
 +        
 +        ...
 +        
 +        lda #%11111111
 +        anc #$ff
 +        rol
 +        
 +        ...
 +        
 +        lda #%11111111
 +        cmp #$80
 +        rol
 +</code>
 +
 +This way bit 7 is copied to carry first and then shifted in on the right end again.
 ====== Jumpcode ====== ====== Jumpcode ======
  
Line 901: Line 935:
 Actually you can use LAX also with an immediate value, but it behaves a bit unstable regarding the given immediate value. However when simply doing an LAX #$00 you are fine. Actually you can use LAX also with an immediate value, but it behaves a bit unstable regarding the given immediate value. However when simply doing an LAX #$00 you are fine.
  
 +
 +lda $xxxx,y is not available as 8 bit version, so an lda $xx,y is not possible. With lax $xx,y there is howeever a way to imitate a lda $xx,y at the cost of destroying x.
 ===== SAX/SHA ===== ===== SAX/SHA =====
  
Line 1537: Line 1573:
  
 <code> <code>
-        lda bmp+        lda bmp       ;could also use lax bmp, sbx #$08, stx bmp to save more cycles
         sec         sec
         sbc #$08         sbc #$08
base/advanced_optimizing.txt · Last modified: 2024-03-03 11:06 by bitbreaker