diff options
Diffstat (limited to 'src/14/part2')
| -rw-r--r-- | src/14/part2 | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/14/part2 b/src/14/part2 new file mode 100644 index 0000000..ee110aa --- /dev/null +++ b/src/14/part2 @@ -0,0 +1,67 @@ +--- Part Two --- + +For some reason, the sea port's computer system still can't communicate with your ferry's docking +program. It must be using [1m[37mversion 2[0m of the decoder chip! + +A version 2 decoder chip doesn't modify the values being written at all. Instead, it acts as a +memory address decoder. Immediately before a value is written to memory, each bit in the bitmask +modifies the corresponding bit of the destination [1m[37mmemory address[0m in the following way: + + + - If the bitmask bit is 0, the corresponding memory address bit is [1m[37munchanged[0m. + - If the bitmask bit is 1, the corresponding memory address bit is [1m[37moverwritten with 1[0m. + - If the bitmask bit is X, the corresponding memory address bit is [1m[37mfloating[0m. + + +A [1m[37mfloating[0m bit is not connected to anything and instead fluctuates unpredictably. In +practice, this means the floating bits will take on [1m[37mall possible values[0m, potentially +causing many memory addresses to be written all at once! + +For example, consider the following program: + +mask = 000000000000000000000000000000X1001X +mem[42] = 100 +mask = 00000000000000000000000000000000X0XX +mem[26] = 1 + +When this program goes to write to memory address 42, it first applies the bitmask: + +address: 000000000000000000000000000000101010 (decimal 42) +mask: 000000000000000000000000000000X1001X +result: 000000000000000000000000000000[1m[37mX1[0m10[1m[37m1X[0m + +After applying the mask, four bits are overwritten, three of which are different, and two of which +are [1m[37mfloating[0m. Floating bits take on every possible combination of values; with two +floating bits, four actual memory addresses are written: + +000000000000000000000000000000[1m[37m0[0m1101[1m[37m0[0m (decimal 26) +000000000000000000000000000000[1m[37m0[0m1101[1m[37m1[0m (decimal 27) +000000000000000000000000000000[1m[37m1[0m1101[1m[37m0[0m (decimal 58) +000000000000000000000000000000[1m[37m1[0m1101[1m[37m1[0m (decimal 59) + +Next, the program is about to write to memory address 26 with a different bitmask: + +address: 000000000000000000000000000000011010 (decimal 26) +mask: 00000000000000000000000000000000X0XX +result: 00000000000000000000000000000001[1m[37mX[0m0[1m[37mXX[0m + +This results in an address with three floating bits, causing writes to [1m[37meight[0m memory +addresses: + +00000000000000000000000000000001[1m[37m0[0m0[1m[37m00[0m (decimal 16) +00000000000000000000000000000001[1m[37m0[0m0[1m[37m01[0m (decimal 17) +00000000000000000000000000000001[1m[37m0[0m0[1m[37m10[0m (decimal 18) +00000000000000000000000000000001[1m[37m0[0m0[1m[37m11[0m (decimal 19) +00000000000000000000000000000001[1m[37m1[0m0[1m[37m00[0m (decimal 24) +00000000000000000000000000000001[1m[37m1[0m0[1m[37m01[0m (decimal 25) +00000000000000000000000000000001[1m[37m1[0m0[1m[37m10[0m (decimal 26) +00000000000000000000000000000001[1m[37m1[0m0[1m[37m11[0m (decimal 27) + +The entire 36-bit address space still begins initialized to the value 0 at every address, and you +still need the sum of all values left in memory at the end of the program. In this example, the sum +is [1m[37m208[0m. + +Execute the initialization program using an emulator for a version 2 decoder chip. [1m[37mWhat is +the sum of all values left in memory after it completes?[0m + + |
