23 lines
711 B
Plaintext
23 lines
711 B
Plaintext
MODULE Bitwise EXPORTS Main;
|
|
|
|
IMPORT IO, Fmt, Word;
|
|
|
|
VAR c: Word.T;
|
|
|
|
PROCEDURE Bitwise(a, b: INTEGER) =
|
|
BEGIN
|
|
IO.Put("a AND b: " & Fmt.Int(Word.And(a, b)) & "\n");
|
|
IO.Put("a OR b: " & Fmt.Int(Word.Or(a, b)) & "\n");
|
|
IO.Put("a XOR b: " & Fmt.Int(Word.Xor(a, b)) & "\n");
|
|
IO.Put("NOT a: " & Fmt.Int(Word.Not(a)) & "\n");
|
|
c := a;
|
|
IO.Put("c LeftShift b: " & Fmt.Unsigned(Word.LeftShift(c, b)) & "\n");
|
|
IO.Put("c RightShift b: " & Fmt.Unsigned(Word.RightShift(c, b)) & "\n");
|
|
IO.Put("c LeftRotate b: " & Fmt.Unsigned(Word.LeftRotate(c, b)) & "\n");
|
|
IO.Put("c RightRotate b: " & Fmt.Unsigned(Word.RightRotate(c, b)) & "\n");
|
|
END Bitwise;
|
|
|
|
BEGIN
|
|
Bitwise(255, 5);
|
|
END Bitwise.
|