Manipulating bits
ROL
instruction: rotate left
Rol.B number,bin value
Rol.W number,bin value
Rol.L number,bin value
ROL is the AMOS Professional Basic version of the ROL command available from 68000 assembly language. It takes the given binary value, and rotates it the specified number of places to the left. The value can be a normal variable, or an expression. Expressions will be treated as a memory location, and AMOS Professional will change the value at the address of the result.
This command allows instant rotation of any part of the Amiga's memory, and it must be used with extreme caution! If variables are confused with bit numbers, your machine will crash. Take heed of the next lines:
X> A=1 Rol.l 1,A : Rem This is fine Rol.l A,1 : Rem This is lethal. DO NOT DO IT!
There are three forms of the ROL instruction:
ROL.B rotates the first eight bits of the valueThe ROL command is invaluable as a rapid method of multiplying and positive number by a power of two, like this:
E> B=1 Rol.l 2,B Print B
Here is an example routine:
E> Curs Off : Locate 0,20 : Centre "Press a key to ROL the number" Locate 0,0 : Print "Binary version" Locate 0,4 : Print "Decimal version" B=1 : Rem Set initial value Do Locate 0,2: Print Bin$(B,32) : Rem Display number in binary Locate 0,6: Print B;" "; : Rem Nine spaces Wait Key Rol.l 1,B : Rem Try ROL.W and ROL.B too Loop