mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-06-11 01:20:00 +00:00
57 lines
1.9 KiB
Diff
57 lines
1.9 KiB
Diff
--- exercises/113_quiz9.zig 2025-08-15 15:17:57.840348083 +0200
|
|
+++ answers/113_quiz9.zig 2026-04-02 10:51:15.821831851 +0200
|
|
@@ -84,7 +84,7 @@
|
|
PORTB = 0b1100;
|
|
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
|
print("^ {b:0>4} // (bitmask)\n", .{0b0101});
|
|
- PORTB ^= (1 << 1) | (1 << 0); // What's wrong here?
|
|
+ PORTB ^= (1 << 2) | (1 << 0);
|
|
checkAnswer(0b1001, PORTB);
|
|
|
|
newline();
|
|
@@ -92,7 +92,7 @@
|
|
PORTB = 0b1100;
|
|
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
|
print("^ {b:0>4} // (bitmask)\n", .{0b0011});
|
|
- PORTB ^= (1 << 1) & (1 << 0); // What's wrong here?
|
|
+ PORTB ^= (1 << 1) | (1 << 0);
|
|
checkAnswer(0b1111, PORTB);
|
|
|
|
newline();
|
|
@@ -103,7 +103,7 @@
|
|
PORTB = 0b1001; // reset PORTB
|
|
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
|
print("| {b:0>4} // (bitmask)\n", .{0b0100});
|
|
- PORTB = PORTB ??? (1 << 2); // What's missing here?
|
|
+ PORTB = PORTB | (1 << 2);
|
|
checkAnswer(0b1101, PORTB);
|
|
|
|
newline();
|
|
@@ -111,7 +111,7 @@
|
|
PORTB = 0b1001; // reset PORTB
|
|
print(" {b:0>4} // (reset state)\n", .{PORTB});
|
|
print("| {b:0>4} // (bitmask)\n", .{0b0100});
|
|
- PORTB ??? (1 << 2); // What's missing here?
|
|
+ PORTB |= (1 << 2);
|
|
checkAnswer(0b1101, PORTB);
|
|
|
|
newline();
|
|
@@ -122,7 +122,7 @@
|
|
PORTB = 0b1110; // reset PORTB
|
|
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
|
print("& {b:0>4} // (bitmask)\n", .{0b1011});
|
|
- PORTB = PORTB & ???@as(u4, 1 << 2); // What character is missing here?
|
|
+ PORTB = PORTB & ~@as(u4, 1 << 2);
|
|
checkAnswer(0b1010, PORTB);
|
|
|
|
newline();
|
|
@@ -130,7 +130,7 @@
|
|
PORTB = 0b0111; // reset PORTB
|
|
print(" {b:0>4} // (reset state)\n", .{PORTB});
|
|
print("& {b:0>4} // (bitmask)\n", .{0b1110});
|
|
- PORTB &= ~(1 << 0); // What's missing here?
|
|
+ PORTB &= ~@as(u4, 1 << 0);
|
|
checkAnswer(0b0110, PORTB);
|
|
|
|
newline();
|