CPU 48 Option Base 0 ' necessary ' variables to be rotated need to be in an array as we can't pass the names of arbitrary variables. Dim Integer Vars=3,x' Vars is the number of 64 bit integers in the array, change this as necessary Dim Integer B(Vars) ' B() is the buffer for our integers to shift. Byte 0, bit 63 is MSB, Byte[Vars], bit 0 is LSB 'some demonstration code B(Vars)=1 ?"In:" For x=0 To Vars ? Bin$(B(x),64)+" "; Next ?:? BigSRL(256,1) ?"Out:" For x=0 To Vars ? Bin$(B(x),64)+" "; Next ? BigSRR(253,1) ?"Out:" For x=0 To Vars ? Bin$(B(x),64)+" "; Next ?
'shift or rotate left B() bits. opt: 0=Shift, 1=rotate Sub BigSRL(bits as Integer,opt) Local Integer m,n,c For m=1 To bits c=(B(0) And &h8000000000000000)<>0 For n=0 To Vars B(n)=B(n)<<1 If n<Vars Then If B(n+1) And &h8000000000000000 Then ' &B1000000000000000000000000000000000000000000000000000000000000000 63rd bit B(n)=B(n) Or 1 EndIf EndIf Next If opt Then B(Vars)=B(Vars) Or c Next End Sub 'shift or rotate right B() bits. opt: 0=Shift, 1=rotate Sub BigSRR(bits as Integer,opt) Local Integer m,n,c For m=1 To bits c=(B(Vars) And 1)*&h8000000000000000 For n=Vars To 0 Step-1 B(n)=B(n)>>1 If n Then If B(n-1) And 1 Then B(n)=B(n) Or &h8000000000000000 EndIf EndIf Next If opt Then B(0)=B(0) Or c Next End Sub