GATE / CS ARCHIVE

SUBJECT COLLECTION

Computer Organization & Architecture · Instructions & Addressing Modes

62 questions, newest first

GATE CSE has asked 62 questions on Instructions & Addressing Modes (Computer Organization & Architecture) from 1991 to 2026, in 32 of the 46 papers; the most recent is in GATE CSE 2026 Set 2. In the last five years it carried 1.6 marks per 100-mark paper on average, against 1.3 since 2003. Since 2014 the questions have been 9 MCQ, 9 NAT and 1 MSQ. 11 groups of questions here are solved the same way; “One per method” keeps the newest of each.

Browse topics
Show
1 mark · MCQ
Report issue

Matching addressing modes to data

Instructions & Addressing Modes

Question 14, GATE 2026: Match P immediate, Q indirect, R base with index, S base with offset to 1 array element, 2 pointer, 3 record field, 4 constant. The choices give different permutations of these matches.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Givens and goal

Match P immediate, Q indirect, R base with index, S base with offset to 1 array element, 2 pointer, 3 record field, 4 constant. The choices give different permutations of these matches.

Approach

Write the effective operand or effective address for each addressing mode and identify the high-level data access it implements.

Step-by-step solution

1. Immediate addressing puts the operand value directly in the instruction, such as an encoded literal 7. It naturally represents a constant, so P→4.
2. Indirect addressing obtains an operand’s address through another location or register. A pointer holds an address and is dereferenced to find the actual data, so Q→2.
3. Base-plus-index addressing computes an address from an array base and an index-dependent displacement, conceptually base+i·element_size. Varying i chooses an array element, so R→1.
4. Base-plus-fixed-offset addressing selects a field at a fixed byte displacement from the start of a record, such as record_base+offset_of_field. Thus S→3.
5. The complete mapping is (P,Q,R,S)→(4,2,1,3), option B. The key distinction is a varying index for array positions versus a fixed layout displacement for a named record field; both may ultimately use addition in the hardware.

Original paper, page 11 · Answer key

1 mark · MCQ
Report issue

Implementing addition on a load-store ISA

Instructions & Addressing Modes

Question 15, GATE 2026: X, Y and Z are memory locations. R0, R1 and R2 are registers. In a load-store architecture with destination-first syntax, select the instruction sequence implementing Z=X+Y. Options A–C use memory directly in an ADD; D loads X and Y, adds registers, and stores the result.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Givens and goal

X, Y and Z are memory locations. R0, R1 and R2 are registers. In a load-store architecture with destination-first syntax, select the instruction sequence implementing Z=X+Y. Options A–C use memory directly in an ADD; D loads X and Y, adds registers, and stores the result.

Approach

Separate data movement from arithmetic and trace where each value resides after every instruction.

Step-by-step solution

1. A load-store ISA permits ordinary arithmetic instructions to use registers, not arbitrary memory operands. First execute LOAD R0,X, giving R0=memory[X].
2. Execute LOAD R1,Y, giving R1=memory[Y]. Both operands of the addition are now available in registers.
3. Execute ADD R2,R0,R1. Destination-first syntax means R2 receives R0+R1; it does not mean R0 is overwritten.
4. Execute STORE Z,R2. This copies the sum from R2 to memory[Z], completing the high-level assignment. This four-instruction sequence is option D.
5. A tries ADD Z,X,Y with all three operands in memory. B loads only X and still uses memory for Y and the ADD destination. C computes ADD R0,X,Y without loading either source. These violate the stated load-store arithmetic restriction even if some other ISA might allow them.

Original paper, page 12 · Answer key

2 marks · MCQ
Report issue

Allocating variable-length opcodes

Instructions & Addressing Modes

Question 44, GATE 2026: Instructions are 16 bits and there are 16 registers. An M instruction has two register operands plus a 6-bit immediate; R has three register operands; C has one register plus a 6-bit offset. Given 2 M opcodes and 7 R opcodes, maximize C opcodes. Options: A 8; B 4; C 64; D 16.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Givens and goal

Instructions are 16 bits and there are 16 registers. An M instruction has two register operands plus a 6-bit immediate; R has three register operands; C has one register plus a 6-bit offset. Given 2 M opcodes and 7 R opcodes, maximize C opcodes. Options: A 8; B 4; C 64; D 16.

Approach

Count occupied instruction encodings, then show the remaining space can be decoded unambiguously.

Step-by-step solution

1. Each register field needs log₂16=4 bits. M operands use 4+4+6=14 bits, leaving a 2-bit opcode. Each M opcode covers 2¹⁴ instruction words; two cover 2¹⁵, half of all 2¹⁶ words.
2. R operands use 12 bits, leaving a 4-bit opcode. Seven R opcodes cover 7×2¹²=28672 words, or 7/16 of the full space. M and R together occupy 1/2+7/16=15/16.
3. C operands use 4+6=10 bits, leaving a 6-bit opcode. Each C opcode covers 2¹⁰ words. The remaining capacity is (1/16)×2¹⁶=4096 words, so at most 4096/1024=4 C opcodes fit.
4. This upper bound is achievable with prefixes: use 00 and 01 for M. Of the eight remaining length-four prefixes 1000 through 1111, reserve seven for R. Extend the last prefix 1111 by 00,01,10,11 for four six-bit C opcodes.
5. No instruction format’s opcode is a prefix of another assigned opcode in this construction. Therefore four is both feasible and maximal, giving B. Simply observing that six bits permit 64 values ignores the already occupied encoding space.

Original paper, page 30 · Answer key

2 marks · MCQ
Report issue

Allocating bits in an instruction format

Instructions & Addressing Modes

Question 37, GATE 2025: A processor has 64 general-purpose registers, 50 instruction types, and fixed 32-bit instructions. For ADD R1,#25, meaning R1=R1+25, what is the maximum immediate field width in the conventional fixed-width opcode/register-field model? A 16; B 20; C 22; D 24 bits.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Approach: Reserve the minimum bits needed for the opcode and the explicitly encoded register, then assign the remainder to the immediate.
There must be at least 50 opcode patterns. Five bits provide only 32 patterns, while six provide 64, so the opcode requires ceil(log₂50)=6 bits. Selecting among 64 registers requires log₂64=6 bits.
This two-address instruction uses R1 both as a source and as the destination; the same register is encoded once, not in two independent fields. Thus the immediate can occupy 32−6−6=20 bits, option B.
The calculation assumes a uniform opcode field and no additional mode or reserved fields, as intended by the question. A 16-bit immediate would leave unused capacity under those assumptions, while 22 or 24 bits would not leave enough room for both required fields. An instruction-set design with variable-length opcodes would need additional specification before such a maximum could be established.

Original paper, page 37 · Answer key

1 mark · MSQ
Report issue

Instructions & Addressing Modes

Question 28, GATE 2025: Select the processor properties that belong to its Instruction Set Architecture (ISA).
Options: A. cache capacity; B. processor clock frequency; C. number of cache levels; D. total number of registers.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: D

An ISA is the programmer-visible contract implemented by a processor, including instruction meanings, operand formats, and architectural registers. Therefore the number of registers that machine instructions can name belongs to that contract, making D the intended selection.

Cache capacity and the number of cache levels are generally microarchitectural implementation choices. Two processors may execute the same machine code while using different cache hierarchies. Clock frequency likewise affects execution speed, but is not a definition of the instruction set. Thus A, B, and C are not ISA properties in this question.

There is a necessary terminology qualification: “total number of registers” must mean the architectural register set. Physical registers used for renaming, pipeline latches, and other hidden internal storage need not be specified by the ISA and can vary across implementations. Under the intended architectural interpretation, select D only.

Original paper, page 22 · Answer key

2 marks · NAT
Report issue

Allocate fixed-width instruction fields

Instructions & Addressing Modes

Question 57, GATE 2024: A 32-bit instruction contains opcode, addressing-mode field, two register operands, and a 16-bit scalar. The processor has 16 general-purpose registers and 8 addressing modes. What maximum number of opcodes is possible for each mode?
Tap to enlarge
Answer & solution

Official answer: 32

Approach: Reserve enough binary codes for each independent fixed-width field, then count the remaining opcode patterns.

1. Derivation. Each of 16 registers requires 4 bits, so the two register fields use 8 bits. Eight addressing modes require 3 bits and the scalar field uses 16. The opcode therefore has 32−8−3−16=5 bits, supporting 2⁵=32 unique opcodes for each mode under the separate fixed-field format.

2. Explanation and checks. A register identifier uses ceil(log2 16)=4 bits even though an operand value may occupy many more bits. The two fields therefore cost eight bits, not sixteen or thirty-two. The mode field needs ceil(log2 8)=3 bits. After allocating these and the scalar there are five opcode bits. The question asks per addressing mode, so the eight mode patterns are not multiplied into the number of distinct opcode-field encodings.

Original paper, page 37 · Answer key

2 marks · NAT
Report issue

Account for a type tag and register fields

Instructions & Addressing Modes

Question 61, GATE 2024: A 32-bit ISA has 150 instructions, 75 each of R-type and I-type, and 50 registers. OPCODE includes a 1-bit type tag plus operation bits. R-type fields: OPCODE, UNUSED, DST, SRC1, SRC2. I-type: OPCODE, DST, SRC, immediate/address. Equal-sized register fields are used. If UNUSED, OPCODE and immediate/address sizes are X,Y,Z, find X+2Y+Z.
Tap to enlarge
Answer & solution

Official answer: 34

Approach: Count the operation bits within each type, add the type bit, then subtract register fields from each format.

1. Derivation. There are 75 operations per instruction type, requiring 7 operation bits plus the 1-bit type tag, so Y=8. Each of 50 architectural registers requires 6 bits. The R-type unused field has X=32−8−3×6=6 bits; the I-type immediate field has Z=32−8−2×6=12 bits. Hence X+2Y+Z=6+16+12=34.

2. Explanation and checks. Six bits encode only 64 operations, insufficient for 75, so seven operation bits are necessary. The one-bit type discriminator brings the full opcode width to eight. Similarly five register bits encode only 32 names, while six accommodate 50. The R-type equation is X+Y+18=32 and the I-type equation is Y+12+Z=32. Adding those equations directly gives X+2Y+Z=64−30=34, which independently checks the field-by-field calculation.

Original paper, page 39 · Answer key

2 marks · MCQ
Report issue

Instructions & Addressing Modes

Question 41, GATE 2023: Translate for(i=0;i<10;i++) a[i]=b[i]*8, with 32-bit ints and byte addressing. r1=0,r2=10 and r3,r4 point to a,b. L01 tests r1==r2 and exits; L02 loads from r4; L03 shifts left by U1; L04 stores at r3; L05,L06 add U2,U3 to r3,r4; L07 increments r1; L08 jumps to U4. Find U1,U2,U3,U4.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Multiplication by 8 is a left shift by 3, so U1=3. A32-bit int occupies 4 bytes in the stated byte-addressed memory, so both source and destination pointers advance 4: U2=U3=4. Each iteration must revisit the termination test at L01, making U4=L01. Answer B, under the usual arithmetic range assumptions for this translation.

Teaching detail. The loop counter r1 counts elements, so its increment is one; the address registers count bytes, so their increments differ. Shifting by 3 multiplies a representable nonnegative binary value by 2³, whereas shifting by 8 would multiply by 256. A jump to L02 would skip the test on later iterations and make termination incorrect. Translating signed C shifts or overflow in full generality requires care, but the intended machine-code comparison is element addressing and multiplication by a power of two within the assumed range.

Original paper, page 42 · Answer key

2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 55, GATE 2021: A byte-addressable machine starts this sequence at address 1000. Instruction, semantics, size in bytes: MOV R1,(5000): R1=MEMORY[5000],4; MOV R2,(R3): R2=MEMORY[R3],4; ADD R2,R1: R2=R1+R2,2; MOV (R3),R2: MEMORY[R3]=R2,4; INC R3: R3=R3+1,2; DEC R1: R1=R1−1,2; BNZ 1004: branch to absolute address 1004 if not zero,2; HALT: stop,1. Initially MEMORY[5000]=10, R3=3000, and MEMORY[3000] through MEMORY[3010] are all 50. All numbers are decimal. Find MEMORY[3010] after execution.
Tap to enlarge
Answer & solution

Official answer: 50

The four-byte first instruction at address 1000 initializes R1=10, and address 1004 is the next instruction, the loop entry. Each loop iteration updates MEMORY[R3], then increments R3 and decrements R1. BNZ tests the zero condition left by that decrement and returns to 1004 while R1 is nonzero. Exactly ten iterations update locations 3000 through 3009. After the tenth, R3 is 3010 and R1 is zero, so the program halts before writing location 3010. Its original value 50 is unchanged.

Instruction addresses are 1000,1004,1008,1010,1014,1016,1018,1020. Thus branching to 1004 skips the initialization at 1000. At iteration k=1,...,10 the address updated is 2999+k and R1 before decrement is 11−k, so memory values written are 60,59,...,51 at 3000,...,3009. The final increment makes R3=3010, but DEC makes R1=0 and the branch falls through to HALT. Merely pointing at 3010 does not write to it.

Original paper, page 41 · Answer key

2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 44, GATE 2020: A processor has 64 registers and 16-bit instructions. I-type has opcode, one register and a 4-bit immediate; R-type has opcode and two registers. Given 8 I-type opcodes, what is the maximum number of distinct R-type opcodes?
Tap to enlarge
Answer & solution

Official answer: 14

Worked explanation

A register number occupies log2 64=6 bits. I-type operands occupy 6+4=10 bits, leaving a 6-bit opcode; R-type operands occupy 12 bits, leaving a 4-bit opcode. Their opcode spaces cannot be independently filled because every complete 16-bit word needs an unambiguous interpretation. Each chosen I opcode consumes 210 words, so eight consume 8192. R opcodes each need 212 distinct operand combinations; the 57344 words left permit 14. Constructively, use four-bit prefixes 0000 through 1101 for R instructions. Reserve 1110 and 1111, extending each by two bits to obtain the eight six-bit I opcodes. This proves attainability as well as the counting bound.

Derivation and answer

Each register field needs 6 bits. An I-type opcode leaves 10 operand bits, so 8 I-type opcodes reserve 8*210=8192 of the 65536 instruction words. An R-type opcode needs 12 operand bits, consuming 4096 words. The remaining 57344 words allow 57344/4096=14 R-type opcodes. Achievability: reserve two four-bit opcode prefixes for the eight six-bit I-opcodes and use the other 14 four-bit prefixes for R-type instructions.

Original paper, page 14 · Answer key

1 mark · MCQ
Report issue

Textbook RISC characteristics

Instructions & Addressing Modes

Question 5, GATE 2018: Which characterize conventional RISC design? I arithmetic only register-to-register; II fixed-length instructions; III hardwired control. Choices: A I,II; B II,III; C I,III; D all three.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Method

A load/store design keeps arithmetic operands in registers and uses separate instructions for memory transfers. Regular instruction lengths simplify fetching and decoding, while simple instruction semantics support direct hardwired control instead of a large microprogram. These properties work together to simplify pipelining. The question asks about the conventional design model; modern instruction-set families can have compressed encodings or other extensions without making the textbook characterization invalid.

Solution

The conventional RISC design combines register-to-register arithmetic, fixed-length instruction encoding and hardwired control. All three listed characteristics apply, D. These are textbook design characteristics, not a claim that every modern RISC extension has identical instruction lengths.

Original paper, page 5 · Answer key

2 marks · NAT
Report issue

Expanding opcodes and register fields

Instructions & Addressing Modes

Question 51, GATE 2018: A 16-bit instruction set has 16 integer and 64 floating registers. Four type-1 instructions use 3 integer operands; eight type-2 use 2 floating operands; fourteen type-3 use 1 integer+1 floating; N type-4 use 1 floating. Find maximal N.
Tap to enlarge
Answer & solution

Official answer: 32

Method

An integer register needs 4 bits and a floating register 6 bits. Operand bits are therefore 12,12,10,6 for the four categories, leaving variable opcode widths 4,4,6,10. Counting complete instruction words avoids assigning incompatible fixed-length opcodes. Each opcode must reserve all combinations of its operands. After subtracting the first three categories from the 65536 available words, divide the remaining words by 64 per type-4 instruction. The prefix construction below verifies that this counting bound can actually be encoded.

Solution

There are 216 instruction encodings. A three-integer-register instruction uses 212 encodings, as does a two-floating-register instruction. Each mixed register instruction uses 210 encodings. The remaining space is 65536−4*4096−8*4096−14*1024=2048. Each type4 opcode needs 64 encodings, so N≤2048/64=32. This bound is achievable with expanding opcodes: allocate 12 four-bit prefixes to types 1/2; the remaining 4 prefixes yield 16 six-bit prefixes, 14 for type3, leaving 2 prefixes expandable to 32 ten-bit type4 opcodes.

Original paper, page 21 · Answer key

1 mark · MCQ
Report issue

Instructions & Addressing Modes

Question 11, GATE 2017: C declaration: struct data { int marks[100]; char grade; int cnumber; }; struct data student; Register R1 holds the base address of student. How to access student.grade efficiently? A postincrement (R1)+; B predecrement −(R1); C register direct R1; D indexed X(R1), with signed 16-bit displacement X.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. A structure layout assigns each member a fixed byte offset from its base. The compiler determines grade’s offset after the marks array, accounting for the implementation’s layout rules.

2. R1 already contains the base. Computing effective address R1+X directly selects grade without traversing the array or modifying R1.

3. That is displacement/index addressing X(R1), D. Register direct accesses the register rather than the field; predecrement and postincrement unnecessarily change the base. No assumed int width is needed.

Original paper, page 6 · Answer key

2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 49, GATE 2017: A RISC instruction is 4 bytes. Branch offsets are byte offsets relative to the NEXT instruction. Instructions are i:add R2,R3,R4; i+1:sub R5,R6,R7; i+2:cmp R1,R9,R10; i+3:beq R1,Offset. Branch target is i. Find signed decimal Offset.
Tap to enlarge
Answer & solution

Official answer: -16.0 to -16.0

Our answer: -16

1. Let the byte address of instruction i be A. Then i+1,i+2,i+3 have addresses A+4,A+8,A+12.

2. The branch uses the next instruction as reference, which is i+4 at A+16, not the branch’s own address A+12.

3. Offset=target−reference=A−(A+16)=−16 bytes. The negative sign denotes a backward branch. Counting three instruction gaps from the branch itself would incorrectly give −12.

Original paper, page 22 · Answer key

1 mark · NAT
Report issue

Instructions & Addressing Modes

Question 10, GATE 2016: A processor has 40 instructions and 24 general-purpose registers. Its 32-bit instruction has an opcode, two register fields and an immediate field. How many bits remain for the immediate?
Tap to enlarge
Answer & solution

Official answer: 16.0 : 16.0

Our answer: 16

Forty opcodes require ceil(log₂40)=6 bits. Each of 24 registers requires 5 bits, so two register fields need 10. The immediate field has 32−6−10=16 bits.

An r-bit identifier distinguishes at most 2r possibilities. Five opcode bits cover only 32 instructions, so six are needed; four register bits cover only 16 registers, so five are needed per operand. Some encodings remain unused, but fractional bit fields are impossible in this fixed-field format.

Original paper, page 27 · Answer key

2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 31, GATE 2016: A machine has 64 registers and 12 instructions. Each instruction has opcode, two source registers, one destination register, and a 12-bit immediate. Instructions must be individually byte aligned. Find bytes used by 100 instructions.
Tap to enlarge
Answer & solution

Official answer: 500.0 : 500.0

Our answer: 500

Twelve opcodes need 4 bits; each of three register identifiers needs 6 bits for 64 registers; immediate uses 12. Total 34 bits per instruction. Byte alignment requires ceiling(34/8)=5 bytes per instruction, so 100 instructions occupy 500 bytes.

The bit fields require 4+6+6+6+12=34 bits. Individually byte-aligned storage rounds each instruction up to 40 bits, leaving six padding bits per instruction. Rounding only the aggregate 3400 bits would give 425 bytes but pack subsequent instructions at nonbyte boundaries, contrary to the stated alignment rule.

Original paper, page 33 · Answer key

1 mark · MCQ
Report issue

Instructions & Addressing Modes

Question 22, GATE 2015: In a three-address instruction format, what may an address field specify? S1 memory operand; S2 processor register; S3 implied accumulator register. A either S1 or S2; B either S2 or S3; C only S2 and S3; D all S1,S2,S3.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

An instruction such as ADD destination,source1,source2 names its explicit operands. Depending on the instruction-set architecture, these fields can select memory locations or registers. An implied accumulator needs no address field because its identity is determined by the opcode or architecture. The issue is explicit versus implicit designation, not whether an accumulator physically exists.

Solution: Three-address instruction operands can refer to registers or memory as defined by the architecture. An accumulator is implicit in an accumulator architecture, not required as one of these explicit operand addresses. Thus A.

Original paper, page 9 · Answer key

2 marks · MCQ
Report issue

Instructions & Addressing Modes

Question 54, GATE 2015: A byte-addressed machine has two-byte registers and an upward-growing stack. SP is 016E hexadecimal and PC is 5FA0 immediately before a two-word CALL that pushes PC and PSW. What is the resulting SP? A 016A; B 016C; C 0170; D 0172.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

CALL pushes the two-byte PC and two-byte PSW onto an upward-growing stack, adding 4 to SP. Thus hexadecimal 016E+4=0172, D. Instruction length affects the return-address value pushed, not the number of bytes added to this stack.

Each pushed register consumes two bytes. Two pushes therefore add four to the stack pointer: 0x016E+0x0004=0x0172. The two-word length of the CALL affects the saved return PC, not how many registers are pushed. Similarly, the current PC value is not an address increment to add to SP. A downward-growing stack would subtract four, but the question explicitly gives upward growth, ruling out 016A.

Original paper, page 47 · Answer key

1 mark · NAT
Report issue

Instructions & Addressing Modes

Question 9, GATE 2014: A machine uses 32-bit words and one-word instructions. It has 64 registers, each 32 bits long. There are 45 instructions, each containing an unsigned immediate and two register operands. Find the largest representable immediate.
Tap to enlarge
Answer & solution

Official answer: 16383

1. Method and setup. Encoding 45 instruction choices needs six bits, since five bits distinguish only 32 choices. Each register identifier also needs six bits; the physical width of a register does not determine the width of its identifier. Allocate opcode and register fields first, then use all remaining bits for the immediate.

2. Work through the result and its assumptions. The opcode needs ceil(log₂45)=6 bits and each of two register fields needs log₂64=6 bits. The32-bit word leaves 32−6−12=14 immediate bits, whose unsigned maximum is 2¹⁴−1=16383.

Original paper, page 9 · Answer key

1 mark · MCQ
Report issue

Base-plus-displacement addressing

Instructions & Addressing Modes

Question 21, GATE 2011: The instruction LW R1,20(R2) loads a 32-bit memory word into R1. Its effective address is 20 plus the contents of R2. Which listed addressing mode best describes the memory operand?

(A) Immediate addressing
(B) Register addressing
(C) Register indirect scaled addressing
(D) Base indexed addressing
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The effective address is the content of R2 plus the displacement 20. The memory operand is neither the literal 20 nor a register value, and no scale factor is applied. Among the options this is called base indexed addressing, D; base-plus-displacement is a more precise description.

The operation can be written R1←Memory[R2+20]. Immediate addressing would use 20 itself as data; register addressing would take the operand directly from a register. Scaled indexing would multiply an index by an element size, which is absent here. Thus the listed base-indexed choice is the closest match. The memory word being 32 bits affects the load size, not the formula used to locate that word.

Original paper, page 5 · Answer key

2 marks · MCQ
Report issue

Auto-increment addressing properties

Instructions & Addressing Modes

Question 33, GATE 2008: Which statements about auto-increment addressing are true? I: useful for self-relocating code. II: including it in an ISA requires an additional ALU for effective-address calculation. III: increment amount depends on the accessed data-item size.

(A) I only
(B) II only
(C) III only
(D) II and III only
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Auto-increment addressing uses a register as an operand address and advances it after the access. To point at the next element, the increment must match the item’s byte size: III is true.
2. It does not inherently make code relocation-independent, so I is not a property of this mode.
3. An implementation can reuse existing arithmetic hardware; an additional ALU is not logically required. II is false, leaving C.

Original paper, page 6

2 marks · MCQ
Report issue

Return-from-exception instruction requirements

Instructions & Addressing Modes

Question 34, GATE 2008: Which must be true of RFE (return from exception) on a general-purpose processor? I: it must be a trap instruction. II: it must be privileged. III: no exception can be allowed during its execution.

(A) I only
(B) II only
(C) I and II only
(D) I,II,III
Tap to enlarge
Your answer
Answer & solution

Answer: B in the conventional privileged-return model (no official key was published)

1. RFE restores saved execution/control state and may change privilege, so the conventional architecture restricts its use to privileged code: II. It returns from a trap rather than being required to generate one, so I is false.
2. A processor may define exceptions/faults during a return, for example invalid saved state, so III is not universally required. Therefore B under the conventional model.
3. Architectures can instead permit restricted unprivileged returns that cannot escalate privilege, so the broad must wording is architecture-dependent.

Original paper, page 6

2 marks · MCQ
Report issue

Benefits of overlapping register windows

Instructions & Addressing Modes

Question 37, GATE 2008: Overlapping multiple register windows reduce memory accesses for which items? I: function locals and parameters. II: register saves and restores. III: instruction fetches.

(A) I only
(B) II only
(C) III only
(D) I,II,III
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. A function’s locals and parameters can stay in its register window instead of memory, reducing I.
2. Overlap exposes caller arguments as callee inputs, and window rotation avoids many explicit saves/restores, reducing II.
3. Eliminating save/restore instructions also removes their instruction fetches, reducing III. Therefore all three are benefits, D. Overflowing the available windows still requires spills, so the reduction is not elimination of all memory traffic.

Original paper, page 7

2 marks · MCQ
Report issue

Data memory references in a loop

Instructions & Addressing Modes

Question 71, GATE 2007: R1,R2,R3 are general-purpose registers. The program, operation, and size in words are:
MOV R1,(3000): R1←M[3000], 2 words
LOOP: MOV R2,(R3): R2←M[R3], 1 word
ADD R2,R1: R2←R1+R2, 1 word
MOV (R3),R2: M[R3]←R2, 1 word
INC R3: R3←R3+1, 1 word
DEC R1: R1←R1−1, 1 word
BNZ LOOP: branch if the result is nonzero, 2 words
HALT: stop, 1 word.
Initially M[3000]=10, R3=2000 and each location 2000–2010 contains 100. The program begins at location 1000; all these numbers are decimal.
Assume word-addressable memory. How many data-memory references occur while running the whole program?
Options:
(A) 10
(B) 11
(C) 20
(D) 21
Question 71, GATE 2007: R1,R2,R3 are general-purpose registers. The program, operation, and size in words are:
MOV R1,(3000): R1←M[3000], 2 words
LOOP: MOV R2,(R3): R2←M[R3], 1 word
ADD R2,R1: R2←R1+R2, 1 word
MOV (R3),R2: M[R3]←R2, 1 word
INC R3: R3←R3+1, 1 word
DEC R1: R1←R1−1, 1 word
BNZ LOOP: branch if the result is nonzero, 2 words
HALT: stop, 1 word.
Initially M[3000]=10, R3=2000 and each location 2000–2010 contains 100. The program begins at location 1000; all these numbers are decimal.
Assume word-addressable memory. How many data-memory references occur while running the whole program?
Options:
(A) 10
(B) 11
(C) 20
(D) 21
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Approach. R1 is the countdown and starts at ten. Separate instruction fetches from data accesses: only the initial load and the two memory-operand MOVs inside each iteration count.

2. Derivation and interpretation. The initial MOV reads M[3000] once and sets R1=10. Each of 10 iterations reads M[R3] once and writes it once. All other operand operations are on registers; instruction fetches are not data references. Total data memory references = 1+10*2=21, option D.

Original paper, page 18

2 marks · MCQ
Report issue

Final value beyond loop write range

Instructions & Addressing Modes

Question 72, GATE 2007: R1,R2,R3 are general-purpose registers. The program, operation, and size in words are:
MOV R1,(3000): R1←M[3000], 2 words
LOOP: MOV R2,(R3): R2←M[R3], 1 word
ADD R2,R1: R2←R1+R2, 1 word
MOV (R3),R2: M[R3]←R2, 1 word
INC R3: R3←R3+1, 1 word
DEC R1: R1←R1−1, 1 word
BNZ LOOP: branch if the result is nonzero, 2 words
HALT: stop, 1 word.
Initially M[3000]=10, R3=2000 and each location 2000–2010 contains 100. The program begins at location 1000; all these numbers are decimal.
Assume word-addressable memory. What is the final content of location 2010?
Options:
(A) 100
(B) 101
(C) 102
(D) 110
Question 72, GATE 2007: R1,R2,R3 are general-purpose registers. The program, operation, and size in words are:
MOV R1,(3000): R1←M[3000], 2 words
LOOP: MOV R2,(R3): R2←M[R3], 1 word
ADD R2,R1: R2←R1+R2, 1 word
MOV (R3),R2: M[R3]←R2, 1 word
INC R3: R3←R3+1, 1 word
DEC R1: R1←R1−1, 1 word
BNZ LOOP: branch if the result is nonzero, 2 words
HALT: stop, 1 word.
Initially M[3000]=10, R3=2000 and each location 2000–2010 contains 100. The program begins at location 1000; all these numbers are decimal.
Assume word-addressable memory. What is the final content of location 2010?
Options:
(A) 100
(B) 101
(C) 102
(D) 110
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Approach. Track the address used before INC R3, not after it. The first iteration uses 2000; after ten iterations R3 reaches 2010 only when the loop is about to terminate.

2. Derivation and interpretation. R3 starts at 2000. The 10 loop iterations access addresses 2000 through 2009, then R3 becomes 2010 and R1 becomes zero, ending the loop. Address 2010 is never written, so its initial content 100 remains. Answer A.

Original paper, page 18

1 mark · MCQ
Report issue

Instruction address alignment

Instructions & Addressing Modes

Question 9, GATE 2006: A CPU has fixed 24-bit instructions and a program beginning at decimal address 300. Which listed decimal value is a legal program counter in that instruction stream? The conventional byte-addressing assumption is implicit in the reproduction.
Options:
(A) 400
(B) 500
(C) 600
(D) 700
Tap to enlarge
Your answer
Answer & solution

Answer: C under byte addressing (no official key was published)

1. With byte-addressed memory and fixed 24-bit instructions, each instruction occupies 3 bytes. Addresses in this instruction stream are 300+3k.

2. Only600 among the listed values differs from 300 by a multiple of 3, so C. Instruction width alone does not establish byte addressing or prohibit other instruction streams; those are the conventional implicit assumptions.

3. Teaching check: Convert instruction width from bits to bytes before testing alignment: 24/8=3. The differences from the starting address are 100,200,300,400; only 300 is divisible by three. This checks positions in the given instruction stream, not all arbitrary code addresses in memory.

Original paper, page 2

2 marks · MCQ
Report issue

Single-bit branch mask

Instructions & Addressing Modes

Question 43, GATE 2006: The instruction bbs reg,pos,label branches if bit pos of a 32-bit register is 1; positions 0…31 start at the least-significant bit. Emulate it by temp←reg & mask, then branch if temp≠0. How should mask be computed?
Options:
(A) 0x1 << pos
(B) 0xffffffff >> pos
(C) pos
(D) 0xf
Question 43, GATE 2006: The instruction bbs reg,pos,label branches if bit pos of a 32-bit register is 1; positions 0…31 start at the least-significant bit. Emulate it by temp←reg & mask, then branch if temp≠0. How should mask be computed?
Options:
(A) 0x1 << pos
(B) 0xffffffff >> pos
(C) pos
(D) 0xf
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. The mask must contain exactly one set bit at position pos: mask=0x1 << pos. AND with the register is nonzero exactly when that bit is set.

2. Thus A. These are register-level pseudocode shifts; a literal C implementation should use an unsigned 32-bit 1 to handle position 31 safely.

3. Teaching check: A one-hot mask isolates exactly the requested bit; an all-ones mask shifted right would generally retain several bits. If implemented in C rather than register pseudocode, use a suitably wide unsigned constant to avoid undefined signed left-shift behavior at the top bit.

Original paper, page 6

2 marks · MCQ
Report issue

Memory cycles for indexed and indirect addition

Instructions & Addressing Modes

Question 65, GATE 2005: Three-word ADD A[R0],@B uses destination indexed address A+R0 and source memory-indirect address M[B]. Opcode/modes are word 1, A and B are words 2/3. How many memory cycles in execution? A3; B4; C5; D6. Distinguish opcode-only fetch boundary from fetching all instruction words before execution.
Tap to enlarge
Your answer
Answer & solution

Answer: D if operand words fetched in execution; B if all three instruction words already fetched (no official key was published)

After fetching the opcode word, execution reads instruction word A and instruction word B (two cycles), reads destination M[A+R0] (one), reads the indirect pointer M[B] and then source M[M[B]] (two), and writes the sum to M[A+R0] (one). This totals six, D. If the phrase execution cycle instead excludes fetching ALL three instruction words, only the four operand accesses remain, B. The paper lack an explicit fetch-cycle boundary; the six-cycle answer uses the conventional opcode-only initial fetch assumed by this style of question. The total including all instruction words is seven memory accesses, with no overlap or cache effects specified.

Separate instruction-word reads from operand-addressing reads. After an opcode-only fetch, two more reads retrieve A and B. Indexed destination contributes one read of its old value; indirect source contributes one read for the pointer and one for its pointed-to value. Finally one write stores the sum. That is 2+1+2+1=6. If all three instruction words were already fetched, only four accesses remain; the missing boundary definition is therefore material, not a computational error.

Original paper, page 8

2 marks · MCQ
Report issue

Natural addressing modes

Instructions & Addressing Modes

Question 66, GATE 2005: Match 1 A[I]=B[J]; 2 while(*A++); 3 int temp=*x; to (a)indirect,(b)indexed,(c)autoincrement addressing. A (1, c),(2, b),(3, a); B (1, a),(2, c),(3, b); C (1, b),(2, c),(3, a); D (1, b),(2, b),(3, c). GFG D begins (1, b); GateForum D begins (1, a).
Question 66, GATE 2005: Match 1 A[I]=B[J]; 2 while(*A++); 3 int temp=*x; to (a)indirect,(b)indexed,(c)autoincrement addressing. A (1, c),(2, b),(3, a); B (1, a),(2, c),(3, b); C (1, b),(2, c),(3, a); D (1, b),(2, b),(3, c). GFG D begins (1, b); GateForum D begins (1, a).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Array indexing A[I]=B[J] naturally uses indexed addressing; walking a pointer with *A++ uses autoincrement; dereferencing *x uses indirect addressing. The matching is (1, b),(2, c),(3, a), option C.

Indexed addressing adds a scaled index to an array base, matching 1. Autoincrement supplies the current pointer address and advances the pointer, matching 2. Plain dereference uses an address stored in a register or variable without an index, matching 3. Thus the mapping is 1b2c3a. These are natural implementation correspondences, not claims that a compiler must choose exactly these machine instructions.

Original paper, page 8

1 mark · MCQ
Report issue

Relocation-friendly addressing modes

Instructions & Addressing Modes

Question 20, GATE 2004: Which addressing modes support program relocation at runtime? (i) Absolute; (ii) Based; (iii) Relative; (iv) Indirect.
Options:
(A) i and iv
(B) i and ii
(C) ii and iii
(D) i,ii and iv
Question 20, GATE 2004: Which addressing modes support program relocation at runtime? (i) Absolute; (ii) Based; (iii) Relative; (iv) Indirect.
Options:
(A) i and iv
(B) i and ii
(C) ii and iii
(D) i,ii and iv
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Base addressing forms an address as relocation base plus displacement, while PC-relative addressing uses a displacement from the moving instruction location. Both preserve relative positions when code is relocated, so ii and iii, C.

2. Absolute embedded addresses require adjustment; indirection alone does not guarantee that stored pointer values relocate correctly.

3. Teaching check: If relocation shifts all code by Δ, a PC-relative target shifts with the PC while its displacement stays fixed. A base-addressed target shifts when the base register is updated. An arbitrary indirect pointer can still contain an obsolete absolute address, so indirection alone is not a relocation guarantee.

Original paper, page 3

2 marks · MCQ
Report issue

Counting set bits with carry rotations

Instructions & Addressing Modes

Question 48, GATE 2003: A, B and C are 8-bit registers in a hypothetical processor. The program is:
MOV B,#0       ; B=0
MOV C,#8       ; C=8
Z: CMP C,#0    ; compare C with zero
JZ X          ; jump if zero flag is set
SUB C,#1      ; C=C-1
RRC A,#1      ; rotate A right through carry once
JC Y          ; jump if carry is set
JMP Z
Y: ADD B,#1   ; B=B+1
JMP Z
X:
RRC transforms A=a7...a0 and carry=c into A=ca7...a1 and carry=a0. Use the instruction effects listed for this hypothetical machine.
If A initially equals A0, what is B after execution?
A. Number of 0 bits in A0
B. Number of 1 bits in A0
C. A0
D. 8
Question 48, GATE 2003: A, B and C are 8-bit registers in a hypothetical processor. The program is:
MOV B,#0       ; B=0
MOV C,#8       ; C=8
Z: CMP C,#0    ; compare C with zero
JZ X          ; jump if zero flag is set
SUB C,#1      ; C=C-1
RRC A,#1      ; rotate A right through carry once
JC Y          ; jump if carry is set
JMP Z
Y: ADD B,#1   ; B=B+1
JMP Z
X:
RRC transforms A=a7...a0 and carry=c into A=ca7...a1 and carry=a0. Use the instruction effects listed for this hypothetical machine.
If A initially equals A0, what is B after execution?
A. Number of 0 bits in A0
B. Number of 1 bits in A0
C. A0
D. 8
Question 48, GATE 2003: A, B and C are 8-bit registers in a hypothetical processor. The program is:
MOV B,#0       ; B=0
MOV C,#8       ; C=8
Z: CMP C,#0    ; compare C with zero
JZ X          ; jump if zero flag is set
SUB C,#1      ; C=C-1
RRC A,#1      ; rotate A right through carry once
JC Y          ; jump if carry is set
JMP Z
Y: ADD B,#1   ; B=B+1
JMP Z
X:
RRC transforms A=a7...a0 and carry=c into A=ca7...a1 and carry=a0. Use the instruction effects listed for this hypothetical machine.
If A initially equals A0, what is B after execution?
A. Number of 0 bits in A0
B. Number of 1 bits in A0
C. A0
D. 8
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. The C test is before the decrement: C=8,7,...,1 each enters the body, while C=0 exits. There are exactly eight rotations.
2. Write the original bits as a7...a0. The successive carry outputs are a0,a1,...,a7. Any incoming carry sits at the top and cannot emerge until a ninth rotation.
3. Only JC Y reaches ADD B,#1. Thus B increases once for every outgoing 1 and never for an outgoing 0. Starting from zero it ends at a0+...+a7, the population count: B.

Solution: The counter C starts at eight and the loop performs exactly eight one-bit right rotations through carry. The carry tested immediately after the kth rotation is the kth original low-to-high bit of A. Newly inserted carry bits cannot reach the outgoing low position during these eight iterations. B starts at zero and is incremented exactly when the outgoing bit is one, so B is the population count of the original A, option B.

Original paper, page 7

2 marks · MCQ
Report issue

Restoring an eight-bit register after through-carry rotations

Instructions & Addressing Modes

Question 49, GATE 2003: A, B and C are 8-bit registers in a hypothetical processor. The program is:
MOV B,#0       ; B=0
MOV C,#8       ; C=8
Z: CMP C,#0    ; compare C with zero
JZ X          ; jump if zero flag is set
SUB C,#1      ; C=C-1
RRC A,#1      ; rotate A right through carry once
JC Y          ; jump if carry is set
JMP Z
Y: ADD B,#1   ; B=B+1
JMP Z
X:
RRC transforms A=a7...a0 and carry=c into A=ca7...a1 and carry=a0. Use the instruction effects listed for this hypothetical machine.
Which instruction inserted at X ensures that A ends with its original value?
A. RRC A,#1
B. NOP (no operation)
C. LRC A,#1 (rotate A left through carry once)
D. ADD A,#1
Question 49, GATE 2003: A, B and C are 8-bit registers in a hypothetical processor. The program is:
MOV B,#0       ; B=0
MOV C,#8       ; C=8
Z: CMP C,#0    ; compare C with zero
JZ X          ; jump if zero flag is set
SUB C,#1      ; C=C-1
RRC A,#1      ; rotate A right through carry once
JC Y          ; jump if carry is set
JMP Z
Y: ADD B,#1   ; B=B+1
JMP Z
X:
RRC transforms A=a7...a0 and carry=c into A=ca7...a1 and carry=a0. Use the instruction effects listed for this hypothetical machine.
Which instruction inserted at X ensures that A ends with its original value?
A. RRC A,#1
B. NOP (no operation)
C. LRC A,#1 (rotate A left through carry once)
D. ADD A,#1
Question 49, GATE 2003: A, B and C are 8-bit registers in a hypothetical processor. The program is:
MOV B,#0       ; B=0
MOV C,#8       ; C=8
Z: CMP C,#0    ; compare C with zero
JZ X          ; jump if zero flag is set
SUB C,#1      ; C=C-1
RRC A,#1      ; rotate A right through carry once
JC Y          ; jump if carry is set
JMP Z
Y: ADD B,#1   ; B=B+1
JMP Z
X:
RRC transforms A=a7...a0 and carry=c into A=ca7...a1 and carry=a0. Use the instruction effects listed for this hypothetical machine.
Which instruction inserted at X ensures that A ends with its original value?
A. RRC A,#1
B. NOP (no operation)
C. LRC A,#1 (rotate A left through carry once)
D. ADD A,#1
Tap to enlarge
Your answer
Answer & solution

Answer: A under the stated instruction effects (no official key was published)

1. Include carry in the state: (c,a7,a6,...,a0) is a nine-position ring. One RRC moves this ring one position right.
2. The loop performs eight rotations, so its accumulated permutation is R8. Since R9 is the identity, another RRC restores all nine bits.
3. NOP leaves R8 unchanged; one left rotation gives R7, not identity; adding 1 is not a bit-position inverse. Hence A works under the given instruction effects. This explicitly relies on other listed instructions not modifying carry.

Solution: Treat carry and A together as a nine-bit circular register and use the instruction effects stated for this hypothetical processor. Eight right rotations leave one right rotation short of a full nine-bit cycle. Inserting RRC A,#1 at X therefore restores A, irrespective of the initial carry value, giving A. This reasoning uses carry preservation by instructions whose listed effects do not change carry; importing different flag side effects from a real ISA would require a new analysis.

Original paper, page 7

1 mark · MCQ
Report issue

Program counter during instruction execution

Instructions & Addressing Modes

Question 1.10, GATE 2002: Which 8085 instructions modify the program counter?
(A) Only PCHL; (B) Only ADD instructions; (C) Only JMP and CALL; (D) All instructions.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: Include the fetch phase, not only the instruction’s explicit operation.

Step 2: An arithmetic instruction still consumes its opcode and possibly operand bytes from the instruction stream. The PC must move beyond those bytes so execution can continue. A jump changes where execution continues, but this extra change does not make jumps the only PC-modifying instructions.

Conclusion: The program counter advances during instruction fetching even for instructions that do not explicitly branch. Branch, call and PCHL instructions additionally replace its value. Therefore it is not modified only by a special instruction subset: D in the ordinary 8085 instruction-fetch model.

Original paper, page 2

1 mark · MCQ
Report issue

Absolute addressing

Instructions & Addressing Modes

Question 1.24, GATE 2002: In absolute addressing, which statement is correct?
(A) The instruction contains the operand.
(B) The instruction contains the operand’s address.
(C) The instruction specifies a register that holds the operand’s address.
(D) The operand’s location is implicit.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Locate the address in each addressing mode.

Step 2: For a conceptual instruction LOAD R,[1000], the instruction’s address field 1000 identifies memory containing the operand: absolute addressing. LOAD R,#1000 instead uses 1000 itself as an immediate value. LOAD R,[S] obtains the address from register S. These distinctions correspond to the different answer descriptions.

Conclusion: In absolute/direct addressing the instruction supplies the operand’s address, B. Supplying the operand value is immediate addressing; naming a register containing its address is register-indirect addressing.

Original paper, page 3

1 mark · MCQ
Report issue

Calls without a dedicated stack-pointer register

Instructions & Addressing Modes

Question 1.10, GATE 2001: A processor has no dedicated stack-pointer register. Does this prohibit subroutine calls, permit calls but not nesting, permit nesting but not interrupts, or still allow nested calls and interrupts?
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: A call must preserve a return address, but that address need not be pushed by a special hardware SP. A link register, a general-purpose register used as a software pointer, or explicit memory stores can preserve it.

Step 2: Before a nested call overwrites a link register, software saves the old value in a memory record and restores it on return. Interrupt context can be preserved by analogous hardware/software mechanisms.

Thus the absence of a dedicated stack-pointer register does not rule out nested calls or interrupts: D, assuming the processor otherwise provides the necessary control-transfer and storage operations.

Original paper, page 2

1 mark · MCQ
Report issue

Returning from privileged mode to user mode

Instructions & Addressing Modes

Question 1.13, GATE 2001: A CPU has privileged and nonprivileged modes. How does the conventional architecture return from privileged to nonprivileged execution? Choices are hardware interrupt, software interrupt, a privileged non-interrupting instruction, or a nonprivileged non-interrupting instruction.
Tap to enlarge
Your answer
Answer & solution

Answer: C under the conventional mode-control architecture (no official key was published)

Step 1: Interrupts and traps normally enter privileged mode. The reverse transition occurs when the OS restores a user context and returns to its instruction stream.

Step 2: A privileged return-from-trap or mode-control instruction can perform that transition without generating a new interrupt, corresponding to C. It is executed while the processor is still privileged.

Qualification: The prompt does not specify an ISA. Some architectures may provide other controlled privilege-dropping mechanisms; the answer uses the standard textbook protection model, not a universal instruction-set theorem.

Original paper, page 2

2 marks · MCQ
Report issue

Matching addressing modes to uses

Instructions & Addressing Modes

Question 2.9, GATE 2001: Match indirect, indexed, and base-register addressing to passing an array as a parameter, implementing an array, and relocatable code. Option A pairs indirect with parameter passing, indexed with arrays, and base-register with relocation; the other choices permute these assignments.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: Passing an array by address gives a pointer to its elements; indirect addressing accesses memory through that pointer, matching X with III.

Step 2: Indexed addressing combines an array base with an index/offset, matching Y with I. Base-register addressing expresses locations relative to a relocatable base; changing that base allows the same relative offsets to address relocated code/data, matching Z with II.

Together the matches are(X,III),(Y,I),(Z,II), A.

Original paper, page 5

1 mark · MCQ
Report issue

Addressing-mode applications

Instructions & Addressing Modes

Question 1.10, GATE 2000: Match X indirect,Y immediate,Z autodecrement addressing to 1 loops,2 pointers,3 constants. Options are permutations; C gives X2,Y3,Z1.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Indirect addressing follows a stored address, so it naturally implements pointer access: X→2. Immediate addressing embeds an operand value, so it is suited to constants: Y→3.

Step 2: Autodecrement combines a register decrement with addressing, useful when iterating backward through a sequence or maintaining a loop-related address: Z→1 among the supplied uses.

Therefore C. These are representative uses, not claims that each mode has only one application.

Original paper, page 2

2 marks · MSQ
Report issue

Typical RISC characteristics

Instructions & Addressing Modes

Question 2.22, GATE 1999: Relative to CISC, does RISC typically have fewer instructions,fewer addressing modes,more registers,and easier hardwired control?
Tap to enlarge
Select all that apply
Answer & solution

Answer: A,B,C,D (no official key was published)

A smaller, more regular instruction repertoire and fewer addressing forms simplify instruction decoding. A load/store style relies heavily on register operands, encouraging a larger register file. Regular simple instruction behavior also makes hardwired control easier to design than for many complex multi-step instructions. These support all four listed typical characteristics. They are historical design tendencies, as the word typically indicates, not strict necessary conditions that classify every modern hybrid processor.

Original paper, page 5

2 marks · MSQ
Report issue

Addressing modes versus implementability

Instructions & Addressing Modes

Question 2.23, GATE 1999: With only immediate and direct addressing, which cannot be implemented: pointers,arrays,records,recursive procedures with locals?
Tap to enlarge
Select all that apply
Answer & solution

Answer: No unconditional impossibility; A,B,D under a restricted direct-code model (no official key was published)

A direct instruction names a fixed address; it cannot in one ordinary memory operation follow a runtime pointer or index. Records with fixed field offsets can use fixed addresses, while pointers, variable array indices and runtime stack frames naturally need computed-address access. This motivates A,B,D only under a model excluding software emulation and code modification. Literally, however, a finite address space permits a dispatch chain: compare the desired address with each legal address and execute the matching direct load/store. Such an interpreter can implement all these features, albeit inefficiently; self-modifying code supplies another possible route if allowed. Therefore the given addressing-mode restriction alone does not prove impossibility, and no unsupported official choice is assigned.

Original paper, page 5

2 marks · Descriptive
Report issue

Trace the population-count loop

Instructions & Addressing Modes

Question 17(a), GATE 1999: For the assembly below with initial (R1,R2,R3)=(5,0,0), find R1 and R3 on reaching Z:
X: CMP R1,0
   JZ Z
   MOV R2,R1
   SHR R1
   SHL R1
   CMP R2,R1
   JZ Y
   INC R3
Y: SHR R1
   JMP X
Z: ...
CMP sets comparison flags; JZ jumps on equality; MOV copies its second operand into its first; SHR/SHL shift by one bit.
Question 17(a), GATE 1999: For the assembly below with initial (R1,R2,R3)=(5,0,0), find R1 and R3 on reaching Z:
X: CMP R1,0
   JZ Z
   MOV R2,R1
   SHR R1
   SHL R1
   CMP R2,R1
   JZ Y
   INC R3
Y: SHR R1
   JMP X
Z: ...
CMP sets comparison flags; JZ jumps on equality; MOV copies its second operand into its first; SHR/SHL shift by one bit.
Question 17(a), GATE 1999: For the assembly below with initial (R1,R2,R3)=(5,0,0), find R1 and R3 on reaching Z:
X: CMP R1,0
   JZ Z
   MOV R2,R1
   SHR R1
   SHL R1
   CMP R2,R1
   JZ Y
   INC R3
Y: SHR R1
   JMP X
Z: ...
CMP sets comparison flags; JZ jumps on equality; MOV copies its second operand into its first; SHR/SHL shift by one bit.
Tap to enlarge
Answer & solution

Answer: R1=0, R3=2 (no official key was published)

The SHR followed by SHL clears the least significant bit. Comparing the result against saved R2 detects whether that bit was 1. If so, increment R3. The SHR at Y then advances to the next bit. With nonnegative logical shifts the trace is:

Entry R1 | R2 after MOV | after SHR,SHL | R3 after test | R1 after Y
5 (101)  | 5            | 4 (100)       | 1             | 2
2 (010)  | 2            | 2 (010)       | 1             | 1
1 (001)  | 1            | 0 (000)       | 2             | 0

At the next X, R1=0 makes JZ Z branch before another iteration. Hence final R1=0 and R3=2. R2 happens to remain 1, though it is not requested. The two right shifts in the body do not skip two input bits because the intervening left shift restores the higher-bit positions.

Original paper, page 8

3 marks · Descriptive
Report issue

Prove population-count behavior

Instructions & Addressing Modes

Question 17(b), GATE 1999: For the same assembly with initial (R1,R2,R3)=(n,0,0), determine R3 on reaching Z:
X: CMP R1,0
   JZ Z
   MOV R2,R1
   SHR R1
   SHL R1
   CMP R2,R1
   JZ Y
   INC R3
Y: SHR R1
   JMP X
Z: ...
CMP sets comparison flags; JZ jumps on equality; MOV copies its second operand into its first; SHR/SHL shift by one bit.
Question 17(b), GATE 1999: For the same assembly with initial (R1,R2,R3)=(n,0,0), determine R3 on reaching Z:
X: CMP R1,0
   JZ Z
   MOV R2,R1
   SHR R1
   SHL R1
   CMP R2,R1
   JZ Y
   INC R3
Y: SHR R1
   JMP X
Z: ...
CMP sets comparison flags; JZ jumps on equality; MOV copies its second operand into its first; SHR/SHL shift by one bit.
Question 17(b), GATE 1999: For the same assembly with initial (R1,R2,R3)=(n,0,0), determine R3 on reaching Z:
X: CMP R1,0
   JZ Z
   MOV R2,R1
   SHR R1
   SHL R1
   CMP R2,R1
   JZ Y
   INC R3
Y: SHR R1
   JMP X
Z: ...
CMP sets comparison flags; JZ jumps on equality; MOV copies its second operand into its first; SHR/SHL shift by one bit.
Tap to enlarge
Answer & solution

Answer: R3=popcount(n), the number of 1 bits in n. (no official key was published)

For nonnegative integer n (or an unsigned fixed-width register with logical SHR), write current R1=2k+b, where b∈{0,1}. SHR then SHL yields 2k, so CMP detects inequality exactly when b=1; R3 therefore increases by b. The SHR at Y sets R1=k. After t iterations, R1=floor(n/2t) and R3 equals the number of ones in the t low-order bits removed from n. This invariant holds initially and is preserved by the decomposition 2k+b. Termination occurs when R1=0, after all significant bits have been examined, so R3 is the binary population count of n. For n=0 the initial branch exits immediately and R3=0. For negative signed inputs the outcome requires a specified word width and right-shift convention; arithmetic SHR is not covered by this nonnegative-integer proof.

Original paper, page 8

1 mark · MCQ
Report issue

Relocation without modifying instructions

Instructions & Addressing Modes

Question 1.19, GATE 1998: Which addressing mode permits relocation without changing code: indirect, indexed, base-register, PC-relative?
Tap to enlarge
Your answer
Answer & solution

Answer: C for general base relocation; D also supports relative references (no official key was published)

Base-register addressing forms effective address=base+stored displacement. Moving the program requires changing the base register, leaving its instruction displacements unchanged, which explains intended C. PC-relative addressing also preserves references within a uniformly moved block because both target and current PC increase by the same relocation amount; their difference stays fixed. Thus D has relocation capability too, though it is not a general replacement for every external/data reference. The scope of relocation is unstated, so C is the standard general mechanism rather than the only conceivable invariant addressing form.

Original paper, page 2

1 mark · MCQ
Report issue

Position-independent addressing

Instructions & Addressing Modes

Question 1.16, GATE 1996: Relative addressing is most relevant to writing which application: (A) coroutines, (B) position-independent code, (C) shareable code, or (D) interrupt handlers?
Question 1.16, GATE 1996: Relative addressing is most relevant to writing which application: (A) coroutines, (B) position-independent code, (C) shareable code, or (D) interrupt handlers?
Tap to enlarge
Your answer
Answer & solution

Answer: B: position-independent code (no official key was published)

A PC-relative instruction stores an offset rather than an absolute target address. Its effective target is PC plus that offset. If both instruction and target move by the same relocation amount, the difference between them is unchanged, so the stored offset still works. Absolute addressing instead embeds a location that generally needs relocation. This is why relative addressing is associated with position-independent control transfers, subject to the architecture’s offset range and exact PC convention.

Original paper, page 2

1 mark · MCQ
Report issue

8085 RET machine cycles

Instructions & Addressing Modes

Question 1.22, GATE 1996: How many machine cycles does an ordinary 8085 RET instruction require?
Tap to enlarge
Your answer
Answer & solution

Answer: C: 3 (no official key was published)

RET first fetches its opcode. It then reads the two bytes of the saved return address from the stack, requiring two memory-read machine cycles. Those bytes restore the program counter and the stack pointer advances by two. Thus the total is one opcode-fetch cycle plus two memory-read cycles, or three. Machine cycles are not individual clock T-states, so counting clock periods instead would confuse two different timing measures.

Original paper, page 3

Descriptive
Report issue

Trace an output-port counter

Instructions & Addressing Modes

Question 6(a), GATE 1996: For an 8085-style system with output port 00H, analyze the program ORG 0100H; MVI A,00H; LXI H,0105H; OUT 00H; INR A; PCHL; HLT. What does it do to the port? GFG includes OUT and INR but calls the CPU 8052; GateForum calls it 8085 but omits OUT and INR.
Question 6(a), GATE 1996: For an 8085-style system with output port 00H, analyze the program ORG 0100H; MVI A,00H; LXI H,0105H; OUT 00H; INR A; PCHL; HLT. What does it do to the port? GFG includes OUT and INR but calls the CPU 8052; GateForum calls it 8085 but omits OUT and INR.
Tap to enlarge
Answer & solution

Answer: Outputs 00H, 01H, …, FFH repeatedly (no official key was published)

Interpret the instructions as 8085 instructions: PCHL copies HL into the program counter. The byte addresses are 0100–0101 for MVI A,00H and 0102–0104 for LXI H,0105H. Therefore the next instruction, OUT 00H, starts at 0105H. OUT occupies two bytes, INR A one, PCHL one, so the loop is OUT at 0105H, INR at 0107H, PCHL at 0108H. HLT at 0109H is never reached.

Initialization sets A=0 and HL=0105H once. Each iteration writes A to the port, increments A modulo 256, then jumps back to OUT. Consequently the port receives 0,1,2,…,255,0,…, an indefinitely repeating eight-bit count. An external DAC would turn this into a staircase ramp, but a DAC is not part of the stated hardware.

The two reproductions cannot be treated as one literal program. Thus the port remains at its previous value, which is unspecified.

Original paper, page 7

1 mark · MCQ
Report issue

Clearing the low nibble

Instructions & Addressing Modes

Question 1.1, GATE 1995: Which 8085 instruction clears the accumulator’s lower four bits while retaining the upper four: XRI 0FH, ANI F0H, XRI F0H, or ANI 0FH?
Tap to enlarge
Your answer
Answer & solution

Answer: B: ANI F0H (no official key was published)

F0H is binary 11110000. AND with its four high ones preserves the corresponding accumulator bits; AND with its four low zeros clears those bits. Thus ANI F0H performs the required masking. XOR would toggle selected bits instead of necessarily clearing them. ANI 0FH does the opposite mask, preserving the low nibble and clearing the high nibble. The operation is independent of the accumulator’s initial value.

Original paper, page 1

2 marks · MCQ
Report issue

Doubling a register pair

Instructions & Addressing Modes

Question 2.1, GATE 1995: Which two 8085 instructions double DE and leave the result in HL: XCHG/DAD B, XTHL/DAD H, PCHL/DAD D, or XCHG/DAD H?
Tap to enlarge
Your answer
Answer & solution

Answer: D: XCHG; DAD H (no official key was published)

XCHG exchanges the DE and HL register pairs, so HL receives the original DE. DAD H then adds HL to itself and stores the 16-bit result in HL. Thus the pair produces twice the original DE, modulo 216, with carry recording overflow. DAD B would add BC rather than double HL; XTHL exchanges with stack memory; PCHL changes control flow. These different effects rule out the other sequences.

Original paper, page 3

Descriptive
Report issue

Explain an 8085 memory search

Instructions & Addressing Modes

Question 16(a), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What does this program do?
Question 16(a), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What does this program do?
Tap to enlarge
Answer & solution

Answer: Searches up to ten bytes at 1C40H–1C49H for the first 05H. (no official key was published)

B starts at decimal 10, A contains the search value 05H, and HL points to 1C40H. In 8085 notation M refers to the memory byte addressed by HL. CMP M computes flags as if subtracting that byte from A, without modifying A. If the byte equals 05H, the zero flag is set and RZ returns immediately to the caller.

On a mismatch, INX H advances the address, DCR B reduces the remaining count, and JNZ repeats while the count remains nonzero. Importantly, that JNZ tests the flags from DCR B, not the earlier comparison. After ten mismatches, B becomes zero and RET returns normally. HLT then stops the main program.

Thus the routine performs a bounded linear search, examining addresses 1C40H through 1C49H and stopping on the first match. On success HL addresses that match and B is the number of positions remaining including the matched position. On failure HL points one byte beyond the searched interval and B=0. A stays 05H throughout.

Original paper, page 7

Descriptive
Report issue

Read the initialized 8085 registers

Instructions & Addressing Modes

Question 16(b), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What are the initial contents of A and B for the search?
Question 16(b), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What are the initial contents of A and B for the search?
Tap to enlarge
Answer & solution

Answer: A=05H and B=0AH (decimal 5 and 10). (no official key was published)

MVI means “move immediate”: it loads the byte written in the instruction directly into the named register. MVI B,0AH sets B to hexadecimal 0A, which is decimal 10. MVI A,05H then sets the accumulator to hexadecimal 05, which is decimal 5. These are the initialized values just before CALL SUB, not claims about unspecified power-on register contents.

LXI H,1C40H loads the separate HL pair and does not change either A or B. CALL changes control flow and the stack, not these initialized register values. During the routine A remains the search key 05H because CMP only changes flags. B is the loop counter and can subsequently decrease. The source asks for the initial values, so a final B value derived from an assumed memory image would answer a different question.

Original paper, page 7

Descriptive
Report issue

Determine the conditional final search address

Instructions & Addressing Modes

Question 16(c), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. Find HL after execution; no memory contents are supplied.
Question 16(c), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. Find HL after execution; no memory contents are supplied.
Tap to enlarge
Answer & solution

Answer: HL=1C40H+k for first match offset k∈{0,…,9}; if absent, HL=1C4AH. (no official key was published)

Let k be the offset of the first byte equal to 05H among the ten searched locations. For every preceding mismatch the program increments HL exactly once. It therefore reaches the matching address 1C40H+k after k increments. CMP sets zero and RZ returns before INX H, leaving HL pointing directly at the match. In particular, an immediate match leaves HL=1C40H; a match in the last tested byte leaves HL=1C49H.

If all ten comparisons fail, every iteration executes INX H, including the last one. Starting at 1C40H, ten increments give 1C4AH. DCR B then makes B=0 and the routine returns without testing that next address.

No single unconditional final address can be inferred because the source gives no values for memory 1C40H–1C49H. The no-match value 1C4AH is a conditional answer, not an established fact. This distinction also avoids the common off-by-one error of returning 1C49H after ten failures.

Original paper, page 7

Report issue

Expanding opcodes and RISC

Instructions & Addressing Modes

Question 3.2, GATE 1994: True or false: expanding-opcode instruction formats are commonly employed in RISC machines.
Tap to enlarge
Answer & solution

Answer: False in the conventional RISC/CISC distinction (no official key was published)

An expanding opcode reuses bits otherwise needed for operands to distinguish more operations in formats with fewer operands. This increases encoding flexibility but complicates decoding and produces less uniform formats. Conventional RISC emphasizes regular, often fixed-length instructions and straightforward decoding, so expanding opcodes are associated more with complex instruction-format designs. The statement is a textbook architectural tendency, not a prohibition: real instruction sets may mix features, and “RISC” is not a formal theorem excluding every variable-format encoding.

Original paper, page 4

5 marks · Descriptive
Report issue

8085 packed BCD addition

Instructions & Addressing Modes

Question 10, GATE 1994: Write 8085 assembly to add two unsigned 16-bit packed 8-4-2-1 BCD operands in register pairs BC and DE. Place the result in BC; the higher register contains the higher-order decimal digits.
Tap to enlarge
Answer & solution

Answer: Use ADD/DAA for the low byte and ADC/DAA for the high byte; final CY is decimal overflow. (no official key was published)

1. Each packed byte holds two decimal digits. First add C and E in A; DAA adjusts the binary sum into valid packed BCD and supplies the carry into the next two digits.

2. MOV C,A saves the low result without changing flags. MOV A,B also preserves the carry, allowing ADC D to add high bytes plus the low-byte decimal carry.

3. A second DAA adjusts the upper digits. MOV B,A preserves the final carry flag. BC now contains the lowest four decimal digits.

4. A sum above 9999 cannot fit in BC. The fifth digit is final CY (0 or 1); the question supplies no separate overflow destination. This limitation must not be concealed.

Code

MOV A,C
ADD E
DAA
MOV C,A
MOV A,B
ADC D
DAA
MOV B,A

Original paper, page 5

Descriptive
Report issue

XOR register exchange

Instructions & Addressing Modes

Question 12(a), GATE 1994: A CPU has only R1,R2 and instruction XOR Ri,Rj, meaning Ri←Ri XOR Rj for i,j∈{1,2}. Give a sequence that exchanges R1 and R2.
Tap to enlarge
Answer & solution

Answer: XOR R1,R2; XOR R2,R1; XOR R1,R2. (no official key was published)

1. Execute XOR R1,R2; XOR R2,R1; XOR R1,R2, in that order.

2. Let the original contents be a,b. After the first instruction the pair is (a XOR b,b).

3. After the second it is (a XOR b,b XOR (a XOR b))=(a XOR b,a).

4. After the third it is ((a XOR b) XOR a,a)=(b,a), using associativity and x XOR x=0. No temporary register is needed.

Original paper, page 5

Descriptive
Report issue

Operand address with PC autoincrement

Instructions & Addressing Modes

Question 10(a), GATE 1993: The CPU instruction occupies one memory word with fields OP CODE, MODE, RegR. Mode 2 uses the address in RegR to fetch the operand, then increments RegR by one. The instruction is at word address 2000 and RegR selects PC. Find the operand address.
Question 10(a), GATE 1993: The CPU instruction occupies one memory word with fields OP CODE, MODE, RegR. Mode 2 uses the address in RegR to fetch the operand, then increments RegR by one. The instruction is at word address 2000 and RegR selects PC. Find the operand address.
Tap to enlarge
Answer & solution

Answer: 2001, under conventional instruction-fetch PC advancement. (no official key was published)

Use the conventional fetch sequence for a word-addressed CPU. Before instruction fetch PC=2000. Fetching the one-word instruction into the instruction register advances PC to 2001. Decoding then selects PC as the mode-2 address register. The effective operand address is the value of PC at that point, namely 2001, so the operand is the contents of memory word M[2001]. The operand fetch subsequently increments PC again, but this later value is not the operand address.

In register-transfer notation: IR ← M[PC]; PC ← PC+1; EA ← PC; operand ← M[EA]; PC ← PC+1. The addresses 2000 and 2001 respectively hold the instruction and its following operand word. This is the usual immediate-operand idiom implemented by PC autoincrement. It assumes ordinary instruction-fetch advancement of the PC, implicit in the question's CPU convention; it does not treat PC as still 2000 during operand addressing.

Original paper, page 10

Descriptive
Report issue

PC after operand fetch

Instructions & Addressing Modes

Question 10(b), GATE 1993: The CPU instruction occupies one memory word with fields OP CODE, MODE, RegR. Mode 2 uses the address in RegR to fetch the operand, then increments RegR by one. The instruction is at word address 2000 and RegR selects PC. For a non-jump instruction, find PC after execution.
Question 10(b), GATE 1993: The CPU instruction occupies one memory word with fields OP CODE, MODE, RegR. Mode 2 uses the address in RegR to fetch the operand, then increments RegR by one. The instruction is at word address 2000 and RegR selects PC. For a non-jump instruction, find PC after execution.
Tap to enlarge
Answer & solution

Answer: 2002. (no official key was published)

There are two distinct increments. First the instruction fetch consumes the memory word at 2000 and advances PC to 2001. Next mode 2 uses the current PC as the address of the operand, reads M[2001], and increments that selected register by one. Because the selected register is PC, it becomes 2002.

The instruction is specified to be non-jumping, so no later branch-target assignment replaces this sequential address. PC=2002 therefore identifies the next instruction, after both the instruction word and its inline operand word. Do not increment a third time for execution: the next fetch has not yet happened. Conversely 2001 accounts only for instruction fetch and overlooks the addressing mode's explicit post-increment. This result uses the conventional word-addressed fetch semantics implicit in part (a).

Original paper, page 10

Descriptive
Report issue

Five-byte input transfer

Instructions & Addressing Modes

Question 20(a), GATE 1993: Identify the function of this 8085 segment: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Question 20(a), GATE 1993: Identify the function of this 8085 segment: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Question 20(a), GATE 1993: Identify the function of this 8085 segment: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Tap to enlarge
Answer & solution

Answer: Read five bytes from input port 20 into consecutive memory cells starting at the address stored at 5000/5001. (no official key was published)

LHLD is a direct memory load of a register pair, not an immediate-address load: it loads L from memory[5000] and H from memory[5001]. Let the resulting 16-bit pointer be h. MVI initializes counter B to five. Each iteration reads one byte from the designated input port into accumulator A, and MOV M,A writes it to the memory location addressed by HL.

INX H advances the pointer by one. DCR B decreases the loop count and sets the zero flag. JNZ returns to GET while that count is nonzero. Thus the five iteration-start counts are 5,4,3,2,1, and exactly five input operations occur. The writes target h,h+1,…,h+4; afterward B=0 and HL=h+5, modulo the 16-bit address space.

The numeric radix of bare literals is not explicitly supplied; using customary hexadecimal assembly notation makes the pointer cells 5000H/5001H and port 20H. The transfer structure is unchanged under another assembler's radix convention. No input-ready polling or handshaking is implemented; the program assumes each IN yields a usable byte.

Original paper, page 13

Descriptive
Report issue

Register and address roles

Instructions & Addressing Modes

Question 20(b), GATE 1993: List the registers and addressed locations used by: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Question 20(b), GATE 1993: List the registers and addressed locations used by: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Question 20(b), GATE 1993: List the registers and addressed locations used by: LHLD 5000; MVI B,5; GET: IN 20; MOV M,A; INX H; DCR B; JNZ GET.
Tap to enlarge
Answer & solution

Answer: HL destination pointer; B count; A input byte; cells 5000/5001 hold pointer; 20 is input-port address; GET is a code label. (no official key was published)

L and H jointly form a 16-bit destination pointer, with L the low byte. LHLD fetches its initial low and high bytes from consecutive memory cells 5000 and 5001; it does not set HL to the literal 5000. The symbol M in MOV M,A denotes memory addressed indirectly by HL and is not another physical register.

A is the accumulator carrying the latest byte returned by IN. B is an 8-bit down-counter initialized to five; DCR B updates the zero condition used by JNZ. INX H changes the register-pair pointer, so successive MOV operations reach consecutive destination addresses. The zero flag is tested after decrement, ensuring five iterations.

The operand 20 designates an I/O port in the separate 8085 port-address space, whereas 5000 and 5001 are memory addresses. GET labels the IN instruction in code and is the branch destination. At completion the original pointer storage cells need not change, B is zero, A contains the last input value, and HL points one location beyond the five-byte output block, subject to address wraparound.

Original paper, page 13

Report issue

An inconsistent expanding-opcode premise

Instructions & Addressing Modes

Question 1(vi), GATE 1992: An 11-bit instruction with 4-bit address fields allegedly supports five two-address instructions and 32 two-address instructions. How many zero-address instructions remain?
Question 1(vi), GATE 1992: An 11-bit instruction with 4-bit address fields allegedly supports five two-address instructions and 32 two-address instructions. How many zero-address instructions remain?
Tap to enlarge
Answer & solution

Answer: Literal premise impossible; 256 if the second group was intended to be one-address (no official key was published)

A two-address instruction uses eight operand bits, leaving only three opcode bits, hence at most eight distinct two-address operations. The literal total of 37 is impossible. If the second phrase is repaired to 32 one-address instructions, five primary opcodes are consumed, leaving three. Expanding each by four bits gives 48 one-address opcode patterns. After using 32, the remaining 16 patterns can each expand by another four bits into 16 zero-address patterns, yielding 256. Both copies repeat “two-address, ” so 256 is explicitly a conditional reconstruction, not a solution to the literal inconsistent specification.

Original paper, page 1

Report issue

A computed jump using PCHL

Instructions & Addressing Modes

Question 2(iv), GATE 1992: 8085 PCHL copies HL to PC. Which construct is it especially useful for: if/then/else, while, case, call?
Question 2(iv), GATE 1992: 8085 PCHL copies HL to PC. Which construct is it especially useful for: if/then/else, while, case, call?
Tap to enlarge
Select all that apply
Answer & solution

Answer: C: case dispatch through a jump table (no official key was published)

A case statement can compute an index, retrieve the selected branch address from a table into HL, then use PCHL to jump directly there. This is an indirect/computed branch rather than a fixed immediate target. Ordinary if and while control are usually implemented with conditional direct branches. PCHL also does not save a return address, so it is not a complete CALL instruction. With auxiliary code an indirect jump can participate in many constructs; C identifies the characteristic direct application, not an impossibility theorem for every other use.

Original paper, page 2

Descriptive
Report issue

8085 immediate OR timing

Instructions & Addressing Modes

Question 8(a.i), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for printed “ORI A,22”.
Question 8(a.i), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for printed “ORI A,22”.
Question 8(a.i), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for printed “ORI A,22”.
Tap to enlarge
Answer & solution

Answer: 9 T-states = 3 μs, interpreting the printed mnemonic as 8085 ORI immediate. (no official key was published)

The 8085 divides the external crystal frequency by two, giving a 3 MHz processor clock. Therefore one T-state lasts 1/3 μs, not 1/6 μs.

8085 ORI immediate is a two-byte instruction: an opcode-fetch cycle of 4 T-states and an immediate-data memory-read cycle of 3 T-states. With PC=0200H, both bytes, at 0200H and 0201H, lie in ROM. Each access adds one wait state. Total time is (4+1)+(3+1)=9 T-states, or 9/(3 MHz)=3 μs.

The accumulator’s original value affects the logical result but not this timing. The other general-purpose registers and the stack pointer are unused. The printed “ORI A,22” is not the conventional 8085 syntax, which writes only the immediate operand, e.g. ORI 22H. The implicit destination is always A. Whether the literal 22 is decimal or hexadecimal does not alter the cycle count. Treating it as register ORA A would incorrectly discard the immediate-byte read.

Original paper, page 6

Report issue

8085 memory decrement timing

Instructions & Addressing Modes

Question 8(a.ii), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for DCR M.
Question 8(a.ii), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for DCR M.
Question 8(a.ii), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for DCR M.
Tap to enlarge
Answer & solution

Answer: 11 T-states = 11/3 μs ≈3.667 μs. (no official key was published)

The processor clock is 6 MHz/2=3 MHz, so a T-state is 1/3 μs. DCR M decrements the memory byte addressed by HL. It performs a 4-T opcode fetch, a 3-T memory read, and a 3-T memory write, for a nominal 10 T-states.

The opcode address PC=0200H is in ROM, adding one wait state. The operand address is HL=10FFH, obtained by concatenating H=10H and L=FFH. This lies in RAM’s 1000H–17FFH range, so neither the operand read nor the write adds a wait. Thus the total is (4+1)+3+3=11 T-states, or 11/3 μs≈3.667 μs.

“M” does not mean an immediate byte following the opcode; it is the indirect-memory operand at HL. The byte’s value was not specified, but every value uses the same timing. Nor is the ROM wait charged to every machine cycle merely because the program executes from ROM: each cycle’s addressed memory device determines its own wait requirement. The instruction changes arithmetic flags except carry, which is immaterial to the timing calculation.

Original paper, page 6