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 revisionBoth sides next revision
base:advanced_optimizing [2022-01-14 12:26] – [Incrementing related pointers] 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 ======
  
base/advanced_optimizing.txt · Last modified: 2024-03-03 11:06 by bitbreaker