01How Computers Work (online)

Fully solved problem book

ALU and condition flags

Set 10 of 10 · 12 worked questions. Predict your result before expanding the solution.

These worked traces are meant to build fluency through controlled variation. If several answers feel identical, try the next difficult value and look for the point where a carry, sign, branch, or selected memory address changes the outcome.

ALU diagnostics · Problem 0289

For A=11110100 and B=01111001, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11110100 and B=01111001 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 244 + 121 = 365.
  4. Reduce the result modulo 256: 109.
  5. The eight output bits are 01101101.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=0, because the most significant output bit is 0.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -12 and 121; their true signed result is 109.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result 109 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 01101101; they help later control logic interpret the outcome.

Final answer: 01101101; Z0 N0 C1 V0

ALU diagnostics · Problem 0290

For A=11111010 and B=01001110, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111010 and B=01001110 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 250 + 78 = 328.
  4. Reduce the result modulo 256: 72.
  5. The eight output bits are 01001000.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=0, because the most significant output bit is 0.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -6 and 78; their true signed result is 72.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result 72 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 01001000; they help later control logic interpret the outcome.

Final answer: 01001000; Z0 N0 C1 V0

ALU diagnostics · Problem 0291

For A=11111010 and B=01001111, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111010 and B=01001111 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 250 + 79 = 329.
  4. Reduce the result modulo 256: 73.
  5. The eight output bits are 01001001.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=0, because the most significant output bit is 0.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -6 and 79; their true signed result is 73.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result 73 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 01001001; they help later control logic interpret the outcome.

Final answer: 01001001; Z0 N0 C1 V0

ALU diagnostics · Problem 0292

For A=11111011 and B=10001100, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111011 and B=10001100 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 251 + 140 = 391.
  4. Reduce the result modulo 256: 135.
  5. The eight output bits are 10000111.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=1, because the most significant output bit is 1.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -5 and -116; their true signed result is -121.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result -121 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 10000111; they help later control logic interpret the outcome.

Final answer: 10000111; Z0 N1 C1 V0

ALU diagnostics · Problem 0293

For A=11111011 and B=11110110, run SUB; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111011 and B=11110110 as the input bit patterns.
  2. Execute SUB; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 251 − 246 = 5.
  4. Reduce the result modulo 256: 5.
  5. The eight output bits are 00000101.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=0, because the most significant output bit is 0.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -5 and -10; their true signed result is 5.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result 5 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 00000101; they help later control logic interpret the outcome.

Final answer: 00000101; Z0 N0 C1 V0

ALU diagnostics · Problem 0294

For A=11111100 and B=11001000, run SUB; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111100 and B=11001000 as the input bit patterns.
  2. Execute SUB; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 252 − 200 = 52.
  4. Reduce the result modulo 256: 52.
  5. The eight output bits are 00110100.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=0, because the most significant output bit is 0.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -4 and -56; their true signed result is 52.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result 52 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 00110100; they help later control logic interpret the outcome.

Final answer: 00110100; Z0 N0 C1 V0

ALU diagnostics · Problem 0295

For A=11111101 and B=00011101, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111101 and B=00011101 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 253 + 29 = 282.
  4. Reduce the result modulo 256: 26.
  5. The eight output bits are 00011010.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=0, because the most significant output bit is 0.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -3 and 29; their true signed result is 26.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result 26 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 00011010; they help later control logic interpret the outcome.

Final answer: 00011010; Z0 N0 C1 V0

ALU diagnostics · Problem 0296

For A=11111110 and B=01010111, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111110 and B=01010111 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 254 + 87 = 341.
  4. Reduce the result modulo 256: 85.
  5. The eight output bits are 01010101.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=0, because the most significant output bit is 0.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -2 and 87; their true signed result is 85.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result 85 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 01010101; they help later control logic interpret the outcome.

Final answer: 01010101; Z0 N0 C1 V0

ALU diagnostics · Problem 0297

For A=11111110 and B=10000110, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111110 and B=10000110 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 254 + 134 = 388.
  4. Reduce the result modulo 256: 132.
  5. The eight output bits are 10000100.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=1, because the most significant output bit is 1.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -2 and -122; their true signed result is -124.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result -124 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 10000100; they help later control logic interpret the outcome.

Final answer: 10000100; Z0 N1 C1 V0

ALU diagnostics · Problem 0298

For A=11111110 and B=10011001, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111110 and B=10011001 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 254 + 153 = 407.
  4. Reduce the result modulo 256: 151.
  5. The eight output bits are 10010111.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=1, because the most significant output bit is 1.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -2 and -103; their true signed result is -105.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result -105 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 10010111; they help later control logic interpret the outcome.

Final answer: 10010111; Z0 N1 C1 V0

ALU diagnostics · Problem 0299

For A=11111110 and B=11000011, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111110 and B=11000011 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 254 + 195 = 449.
  4. Reduce the result modulo 256: 193.
  5. The eight output bits are 11000001.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=1, because the most significant output bit is 1.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -2 and -61; their true signed result is -63.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result -63 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 11000001; they help later control logic interpret the outcome.

Final answer: 11000001; Z0 N1 C1 V0

ALU diagnostics · Problem 0300

For A=11111111 and B=00010001, run ADD; find the low byte and Z, N, C, V.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Treat A=11111111 and B=00010001 as the input bit patterns.
  2. Execute ADD; compute the mathematical integer expression using the input patterns.
  3. The ordinary unsigned calculation yields 255 + 17 = 272.
  4. Reduce the result modulo 256: 16.
  5. The eight output bits are 00010000.
  6. Zero flag Z=0, because the stored output is nonzero.
  7. Negative flag N=0, because the most significant output bit is 0.
  8. Carry flag C=1 under the selected convention (ADD uses carry-out; SUB uses no-borrow).
  9. Signed readings are -1 and 17; their true signed result is 16.
  10. The signed result range is −128 through 127.
  11. Overflow flag V=0; signed result 16 is inside the 8-bit signed range.
  12. The flags do not change the stored byte 00010000; they help later control logic interpret the outcome.

Final answer: 00010000; Z0 N0 C1 V0