base:advanced_optimizing
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
base:advanced_optimizing [2021-04-19 08:26] – [LAX] bitbreaker | base: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: | ||
+ | |||
+ | < | ||
+ | lda #%11111111 | ||
+ | clc | ||
+ | rol | ||
+ | rol | ||
+ | ;-> A = %11111101 | ||
+ | ; ^ | ||
+ | ; gap :-( | ||
+ | </ | ||
+ | |||
+ | To avoid that behaviour there' | ||
+ | |||
+ | < | ||
+ | lda #%11111111 | ||
+ | asl | ||
+ | adc #0 | ||
+ | | ||
+ | ... | ||
+ | | ||
+ | lda #%11111111 | ||
+ | anc #$ff | ||
+ | rol | ||
+ | | ||
+ | ... | ||
+ | | ||
+ | lda #%11111111 | ||
+ | cmp #$80 | ||
+ | rol | ||
+ | </ | ||
+ | |||
+ | This way bit 7 is copied to carry first and then shifted in on the right end again. | ||
====== Jumpcode ====== | ====== Jumpcode ====== | ||
Line 1539: | Line 1573: | ||
< | < | ||
- | 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