Chapter 1

Instructions, operands and addresses

An instruction describes an operation and where its operands come from. First separate architectural rules from the hardware that implements them; then count fields and trace addresses in the units the machine actually uses.

1.1 Instruction set and machine state

Past papers · CS 2014–2026 (23 papers): 4 questions, 4 marks

The instruction set architecture (ISA) specifies programmer-visible registers, instruction encodings and semantics, supported operand types, addressing modes and architectural memory behaviour. Cache capacity, pipeline depth and clock frequency are implementation choices. Two implementations of the same ISA can execute the same binary at different speeds.

Instruction classState changeQuestion-solving cue
Load/store or moveTransfer data between specified locationsDistinguish the address from its contents
Arithmetic/logicCompute a register or memory resultCheck destination position and flag updates
Shift/rotateReposition bitsIdentify signedness and shifted-in bits
Conditional branchChange PC only if a condition holdsUse the flags from the instruction that last changes them
Call/returnTransfer control and preserve/recover a return addressDo not assume a particular stack convention
Input/outputAccess a peripheral interfaceI/O address space may be separate from memory

PC is the program counter; IR holds the fetched instruction; a status register or PSW holds condition flags and other architectural status. Register names and flag behaviour are ISA-dependent.

A load-store ISA performs ordinary arithmetic on registers; explicit loads and stores transfer memory operands. Classic RISC designs favour regular formats, register operands and hardwired control. Classic CISC designs often provide more addressing modes and variable instruction lengths. These are design tendencies, not definitions that determine every modern implementation.

Explicit operand addressesTypical arithmetic semanticsImplicit information
ThreeADD D, A, B: D←A+BD\leftarrow A+BNext PC normally sequential
TwoADD D, S: D←D+SD\leftarrow D+SDestination is also a source
OneADD A: accumulator ←\leftarrow accumulator +M[A]+M[A]Accumulator
ZeroADD: pop two operands, push their sumStack top operands

Here M[A]M[A] denotes memory contents at address AA. An operand-address field can select a register or a memory operand if the ISA permits it. An implied accumulator requires no explicit address field.

1.2 Fixed instruction fields

Past papers · CS 2014–2026 (23 papers): 6 questions, 10 marks · EC 2020–2026 (7 papers): 1 question, 1 mark

Count encoded choices, not the largest register number written in the question. A register used both as source and destination needs only one field when the instruction format specifies that shared field.

If a type bit partitions the instruction set, budget that bit and the operation bits within the largest type separately. Unused register encodings do not automatically become opcode bits. A fixed bopb_{\mathrm{op}}-bit opcode supports at most 2bop2^{b_{\mathrm{op}}} operations when all patterns are available.

1.3 Expanding opcodes

Past papers · CS 2014–2026 (23 papers): 3 questions, 6 marks

Short opcode prefixes can leave more operand bits; longer prefixes reuse only unallocated regions. The decoder must distinguish formats without mistaking part of an operand for an opcode.

1.4 Effective addresses

Past papers · CS 2014–2026 (23 papers): 5 questions, 8 marks

An effective address, EA, identifies the operand's memory location. An immediate is already the operand, and register-direct addressing has no memory EA. In the table, dd is an instruction field, Rb,RiR_b,R_i are register contents and sis_i is an index scale in addressable units per element.

For a read operand, direct and register-indirect addressing need one data-memory access; memory-indirect needs an extra pointer read. This count excludes fetching instruction bytes, translation and cache effects. Stores and read-modify-write instructions require their own access count.

1.5 Data layout and byte order

Past papers · CS 2014–2026 (23 papers): 2 questions, 4 marks

Byte addressing means each byte has an address; a 32-bit word then spans four addresses. Word addressing gives one address per word. Endianness orders bytes within a multi-byte value, not bits inside a byte.

Natural alignment of a uu-byte object means its address is divisible by uu. A compiler may insert padding between record fields; use the stated layout rather than summing sizes blindly.

1.6 Stack and subroutine discipline

Past papers · CS 2014–2026 (23 papers): 1 question, 2 marks · EC 2020–2026 (7 papers): 1 question, 2 marks

A stack is last-in, first-out. PUSH/POP ordering and stack growth are independent of byte order. CALL preserves the return PC, sometimes in a link register; an interrupt may also preserve status. Only save additional words if the stated mechanism requires them.

Last-minute recall

  • ISA describes visible behaviour; cache size and clock rate describe an implementation.
  • Round each independent field width upward before subtracting it from the instruction length.
  • Expanding opcodes consume complete encoding regions, not equal-sized opcode slots.
  • A memory-indirect operand needs a pointer read before its data read.
  • Resolve PC reference and displacement scale before calculating a branch target.
  • Endianness changes byte significance; address progression still increases by one byte.
  • Track stack direction, item width and what SP points to separately.

Revise offline: the whole Computer Organization and Architecture handbook as one PDF

36 pages · 2.5 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections