summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorAlexander Sisco <36649949+devspeare@users.noreply.github.com>2025-02-02 21:01:25 -0800
committerAlexander Sisco <36649949+devspeare@users.noreply.github.com>2025-02-03 23:24:34 -0800
commit3faad6e17b03f13e91d4b93a525e6608c72c8ace (patch)
treefa7795cc50f25bf82a8dca5a555e66bddad905ed /build.zig
parentfabedb4a24e86548673dfed53fd8da261b0c6547 (diff)
Suggesting a third exercise for bit manipulation
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index e528552..9774833 100644
--- a/build.zig
+++ b/build.zig
@@ -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 =