home *** CD-ROM | disk | FTP | other *** search
- Program Rotate;
-
- (**************************************************************************
-
- Written for John Mix by Bob Breeedlove.
- Released to the public domain.
- Compiled under turbo pascal 4.0.
- Rotate bits in a byte.
-
- **************************************************************************)
-
-
- Var
- Test,
- Num, Rot : Byte;
-
-
- Function RotateRight(i,r : Byte) : Byte;
- Begin
- Inline(
- $8A/$8E/>R
- /$8A/$AE/>I
- /$D2/$CD { ror BYTE ch,cl}
- /$88/$AE/>I { mov [>i [BP]],ch}
- );
- RotateRight := i;
- end; { RotateRight }
-
- FUNCTION RotateLeft(i,r : byte) : byte;
- begin
- Inline(
- $8A/$8E/>R { mov cl,BYTE [>r [BP]]}
- /$8A/$AE/>I { mov ch,BYTE [>i [BP]]}
- /$D2/$C5 { rol BYTE ch,cl}
- /$88/$AE/>I { mov [>i [BP]],ch}
- );
- RotateLeft := i;
- end; { RotateLeft }
-
- begin
- writeLn('> ');
- Num := 128; Rot := 6;
- WriteLn(Num);
- Test := RotateRight(Num,Rot);
- writeln('R = ',Test);
- WriteLn('L = ',RotateLeft(Test,Rot));
- end.