In the following code snippet, I used !ror instead of PB's builtin ROTATE RIGHT (timings give an excellent speedup)
The SAR and ROR mnemonics seem to behave without any side effects, well, as far as I know.
Is there any downside to this?
Similarly, in this code I use !sar x,4 instead of a SHIFT RIGHT x,4 - or an explicit integer divide eg x \= 16
Much faster to use SAR. But am I living dangerously or is it quite permissible here?
The SAR and ROR mnemonics seem to behave without any side effects, well, as far as I know.
Is there any downside to this?
Code:
function ChkSum(byval pFCBName as byte ptr) as byte local sum as byte register idx as long for idx = 0 to 10 !ror sum, 1 sum += @pFcbName[idx] next function = sum end function
Much faster to use SAR. But am I living dangerously or is it quite permissible here?
Code:
function SumOfNibbles(byval x as long) as long register sum as long while x sum += x and 15 !sar x, 4 wend function = sum end function
Comment