Right now to do a single-bit arithetic shift right, can cmp(0x80) and then rotate right with carry a >>>>#= 1.
If you want to shift more, you can wrap the code in an inline for, but it's kinda inconvenient. Also, the unrolled shift loop becomes less efficient than other methods after the shift count exceeds 2 places.
(in 6502 asm), this is more efficient on space and cycle time when N is >= 3.
eor #$80
lsr a
lsr a
lsr a
lsr a
clc ; optional if not rounding
adc #<-(128 >> N)
If there was a way to do this as an inline macro, or an opt-in feature to enable >> (rather than >>> logical right shift) to mean an optimized sequence of shifts to accomplish the result, this would be kind of neat.
Right now to do a single-bit arithetic shift right, can
cmp(0x80)
and then rotate right with carrya >>>>#= 1
.If you want to shift more, you can wrap the code in an
inline for
, but it's kinda inconvenient. Also, the unrolled shift loop becomes less efficient than other methods after the shift count exceeds 2 places.(in 6502 asm), this is more efficient on space and cycle time when N is >= 3.
If there was a way to do this as an inline macro, or an opt-in feature to enable
>>
(rather than>>>
logical right shift) to mean an optimized sequence of shifts to accomplish the result, this would be kind of neat.