Suggesting a third exercise for bit manipulation

This commit is contained in:
Alexander Sisco
2025-02-02 21:01:25 -08:00
parent fabedb4a24
commit 3faad6e17b
2 changed files with 475 additions and 0 deletions

View File

@@ -1208,6 +1208,38 @@ const exercises = [_]Exercise{
\\Max difference (new fn): 0.014
,
},
.{ .main_file = "110_bit_manipulation3.zig", .output =
\\Set pins with OR on PORTB
\\-------------------------
\\ 1001 // (initial state of PORTB)
\\| 0100 // (bitmask)
\\= 1101
\\
\\ 1001 // (reset state)
\\| 0100 // (bitmask)
\\= 1101
\\
\\Clear pins with AND and NOT on PORTB
\\------------------------------------
\\ 1110 // (initial state of PORTB)
\\& 1011 // (bitmask)
\\= 1010
\\
\\ 0111 // (reset state)
\\& 1110 // (bitmask)
\\= 0110
\\
\\
\\Toggle pins with XOR on PORTB
\\-----------------------------
\\ 1100 // (initial state of PORTB)
\\^ 0101 // (bitmask)
\\= 1001
\\
\\ 1100 // (initial state of PORTB)
\\^ 0011 // (bitmask)
\\= 1111
},
.{
.main_file = "999_the_end.zig",
.output =