Sub topic 18
Worked GATE-Style Problem Patterns
Assume you know binary and hexadecimal numbers, basic logic gates, registers, and memory. These problems test whether you can apply definitions carefully rather than memorize isolated formulas.
A reliable solving method
For each question:
- Write the field sizes and the quantity being counted.
- Separate an address from the value stored at that address.
- Keep carry and signed overflow as different flags.
- State whether a control-store size is measured in words, bits, or bytes.
Instruction encoding
A 16-bit instruction has a 4-bit opcode and two 6-bit address fields. Fourteen two-address opcodes are already assigned. How many one-address instructions can be encoded using the remaining opcode prefixes?
There are \(2^4=16\) possible 4-bit prefixes. Two prefixes remain unused. Each unused prefix can be followed by a 6-bit address field:
\[ 2 \times 2^6 = 128 \]
Therefore, the answer is 128 one-address instructions.
If 100 of these one-address codes are assigned, the remaining 28 prefixes can each be followed by two 6-bit fields. Thus, the number of zero-address instructions is:
\[ 28 \times 2^6 = 1792 \]
This is the expanding-opcode method: shorter instructions free opcode prefixes, and those prefixes are extended with fewer address fields.
Addressing-mode calculation
Suppose memory contains \(M[100]=500\) and \(M[500]=7\). Register R1 contains 100. Find the operand for each mode when the instruction field is 100.
| Mode | Effective address | Operand |
|---|---|---|
| Direct | 100 | \(M[100]=500\) |
| Indirect | \(M[100]=500\) | \(M[500]=7\) |
| Register indirect | \(R1=100\) | \(M[100]=500\) |
Direct addressing treats the field as the address. Indirect addressing performs one extra memory lookup. Register-indirect addressing takes the address from a register.
Flags and control memory
For 8-bit addition, \(0x7F+0x01=0x80\). There is no carry out, but signed overflow is 1 because two positive numbers produced a negative signed result.
For \(0xFF+0x01=0x00\), carry out is 1, but signed overflow is 0 because \(-1+1=0\).
A microprogrammed control unit has 512 microinstructions, each 40 bits wide. The control store capacity is:
\[ 512 \times 40 = 20{,}480\text{ bits}=2560\text{ bytes} \]
The microaddress requires \(\log_2 512=9\) bits.
Exercise
An instruction has a 5-bit opcode and a 7-bit address field. How many distinct one-address instructions are possible if all opcode patterns are available?
Show answer
\(2^5 \times 2^7 = 2^{12}=4096\) instructions.