The 8-Bit Mark Register That Shows 12 Instead of 268
At a government higher secondary school in Coimbatore, the computer club stores each student's three subject marks (each 0–100) in an 8-bit unsigned register before sending them to a display board. There are 40 students. For student roll 17, the marks are 92, 88 and 88; the program adds them and stores the total in one 8-bit register. The display shows 12 instead of 268. A second bug appears when a student is absent: the teacher enters −1, and the board shows 255. The club also wants to print the total in hexadecimal on a seven-segment display and to send marks to a PC as ASCII characters. The teacher insists that absent must never be confused with a genuine mark of 0. The club has one week and must keep the circuit simple, but it can add a second register if needed.
1. Explain, using place values, why the display shows 12 for a true total of 268. State the smallest register width that can hold any possible total, and justify it.
Read the worked answer
An 8-bit unsigned register can hold only 0–255. The true total is 92 + 88 + 88 = 268. In binary, 268 = 1 0000 1100₂, which needs 9 bits. The register keeps the low 8 bits, 0000 1100₂ = 12, and the ninth bit (the 256 carry) is lost. This is unsigned overflow: the stored value is effectively 268 mod 256 = 12. The maximum possible total is 300, and 2⁸ = 256 < 300 ≤ 512 = 2⁹, so at least 9 bits are required for the total. A 16-bit register is the practical choice because it matches byte/word boundaries and leaves room for future subjects. Widening the register alone does not fix absence handling; that needs a separate flag or a signed representation used consistently.
2. The club must store three marks, the total and an absent flag for each student. Propose a bit layout and explain how it prevents the 255/−1 confusion.
Read the worked answer
Use a 32-bit record: three mark fields of 7 bits each (0–100 fits in 0–127), a 9-bit total (0–300), a 1-bit absent flag and 1 spare bit: 21 + 9 + 1 + 1 = 32. The absent flag is the authoritative indicator. If a student is absent, set the flag to 1 and store 0 in that mark field; software must check the flag before treating 0 as a score. Alternatively, store each mark as a signed 8-bit value and reserve −1 for absent, but then all arithmetic must be signed. The current bug is exactly a signed −1 (1111 1111₂) being displayed as unsigned 255. Keeping the flag separate avoids overloading the value range and makes the meaning unambiguous to both the display and the PC transfer.
3. Convert 268 to hexadecimal and describe how the same value would be transmitted as ASCII, stating how many bytes are needed.
Read the worked answer
268 ÷ 16 = 16 remainder 12 (C); 16 ÷ 16 = 1 remainder 0; 1 ÷ 16 = 0 remainder 1. Reading remainders upward gives 10C₁₆, written 0x10C (12 bits). As ASCII, the digits are characters: '2' = 0x32, '6' = 0x36, '8' = 0x38, so three bytes 32 36 38 are sent, often followed by a newline or terminator. ASCII is a character code, not a number; the receiver must parse the three characters to recover 268. If the receiver expects a binary integer, 0x10C fits in two bytes (for example 01 0C in big-endian). Mixing the two representations is a common cause of display errors, so the protocol must state which one is used.