-- Chapter 6 - Program 6 with Ada.Text_IO, Interfaces; use Ada.Text_IO, Interfaces; procedure Modular2 is My_Byte : Interfaces.UNSIGNED_8; My_Mask : Interfaces.UNSIGNED_8; package Byte_IO is new Ada.Text_IO.Modular_IO(Interfaces.UNSIGNED_8); use Byte_IO; Small_Modular : Interfaces.UNSIGNED_8; Medium_Modular : Interfaces.UNSIGNED_16; Big_Modular : Interfaces.UNSIGNED_32; begin My_Byte := 2#10100011#; My_Mask := 1; Put_Line(" Byte Mask and or xor and not"); for Index in 1..8 loop Put(My_Byte, 6); Put(My_Mask, 6); Put(My_Byte and My_Mask, 6); Put(My_Byte or My_Mask, 6); Put(My_Byte xor My_Mask, 6); Put(My_Byte and My_Mask, 6); Put(not My_Mask, 6); New_Line; My_Mask := Interfaces.Shift_Left(My_Mask, 1); end loop; My_Mask := 1; New_Line; Put(" Byte Mask and or xor and"); Put_Line(" not"); for Index in 1..8 loop Put(My_Byte, 8, 16); Put(My_Mask, 8, 16); Put(My_Byte and My_Mask, 8, 16); Put(My_Byte or My_Mask, 8, 16); Put(My_Byte xor My_Mask, 8, 16); Put(My_Byte and My_Mask, 8, 16); Put(not My_Mask, 13, 2); New_Line; My_Mask := Interfaces.Shift_Left(My_Mask, 1); end loop; end Modular2; -- Result of execution -- -- Byte Mask and or xor and not -- 163 1 1 163 162 1 254 -- 163 2 2 163 161 2 253 -- 163 4 0 167 167 0 251 -- 163 8 0 171 171 0 247 -- 163 16 0 179 179 0 239 -- 163 32 32 163 131 32 223 -- 163 64 0 227 227 0 191 -- 163 128 128 163 35 128 127 -- -- Byte Mask and or xor and not -- 16#A3# 16#1# 16#1# 16#A3# 16#A2# 16#1# 2#11111110# -- 16#A3# 16#2# 16#1# 16#A3# 16#A1# 16#2# 2#11111101# -- 16#A3# 16#4# 16#0# 16#A7# 16#A7# 16#0# 2#11111011# -- 16#A3# 16#8# 16#0# 16#AB# 16#AB# 16#0# 2#11110111# -- 16#A3# 16#10# 16#0# 16#B3# 16#B3# 16#0# 2#11101111# -- 16#A3# 16#20# 16#20# 16#A3# 16#83# 16#20# 2#11011111# -- 16#A3# 16#40# 16#0# 16#E3# 16#E3# 16#0# 2#10111111# -- 16#A3# 16#80# 16#80# 16#A3# 16#23# 16#80# 2#1111111#