| |
mhindsbo
Registered: Dec 2014 Posts: 51 |
ROL'in a byte onto itself
What is the fastest and/or shortest code for rolling a pattern through a byte? I use it to trigger an action following a certain pattern. I came up with (18 cycles worst case / 12 bytes):
clc
lda pattern
bpl no_carry
sec
no_carry rol pattern
bcs take_action
if your pattern ends on a 1 (bit 0 = 1) then you could also do (17 cycles worst case / 13 bytes)
lda pattern
bne @cont
lda #%00110101 ; restore pattern
@cont asl
sta pattern
bcs take_action
any other variations? |
|
... 30 posts hidden. Click here to view all posts.... |
| |
Perplex
Registered: Feb 2009 Posts: 255 |
Edit: nevermind. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
yeah hype it some more, most beautiful 3 lines of code I've ever seen. I mean, really! :) |
Previous - 1 | 2 | 3 | 4 - Next |