Register Transfer Language, Microoperations and Programming the Basic Computer
Arithmetic, Logic and Shift Microoperations
- Arithmetic microoperations: addition, subtraction (via 2's complement — add the complement, no separate subtractor circuit needed), increment, decrement. A single adder-subtractor unit implements both add and subtract by complementing one operand and setting the carry-in, controlled by one mode line.
- Logic microoperations: bitwise AND, OR, XOR, NOT/complement applied independently to each bit pair — used for masking (AND with a mask clears unwanted bits), setting bits (OR), and selective complementing (XOR with a mask).
- Shift microoperations: logical shift (fills with 0), arithmetic shift (preserves the sign bit on a right shift, treating the value as signed), and circular/rotate shift (the bit shifted out re-enters at the other end) — each usable for multiplication/division by powers of two (arithmetic shift) or for serial data movement (logical/circular).
Basic Computer Organisation, Instruction Cycle and Interrupt
The classic basic-computer model has one accumulator (AC), a memory-address register (MAR), a memory-buffer/data register (MBR/DR), a program counter (PC), an instruction register (IR), and memory-reference, register-reference and input-output instruction formats distinguished by an opcode field and an addressing-mode (direct/indirect) bit. Every instruction executes an instruction cycle: fetch (MAR ← PC, IR ← M[MAR], PC ← PC + 1), decode the opcode, compute the effective address (an extra memory read if the addressing mode is indirect), then execute. After execution, the control unit checks the interrupt flip-flop; if set, it stores the return address, disables further interrupts, and branches to the interrupt-service routine — this check is why an interrupt is never noticed mid-instruction, only at instruction boundaries.
Machine and Assembly Language, Program Loops and Subroutines
- Assembler: translates symbolic assembly-language mnemonics (LDA, ADD, STA, BUN, BSA...) into the machine's binary opcodes in two passes — the first pass builds a symbol table of labels and their addresses, the second generates the actual binary using that table, which is why a forward reference (a jump to a label defined later in the program) is resolvable at all.
- Program loops: a counter is initialised, decremented (or incremented) each pass, and tested — the standard pattern is initialise, body, decrement-and-branch-if-not-zero, which is exactly a hardware-level for-loop.
- Subroutines: a Branch-and-Save-return-address instruction (BSA) stores the return address (PC's current value) at the subroutine's first memory location and sets PC to the next location, so the subroutine's own last instruction is an indirect branch through that saved location — this is the pre-stack mechanism a hardware call/return implements, and it fails for recursion because there is only one saved slot per subroutine, not a stack of them.
- I/O programming: programmed I/O polls a device's status flag in a tight loop before transferring one word at a time — simple but wastes CPU cycles busy-waiting, which is exactly the motivation for interrupt-driven I/O and DMA covered under Input-Output Organisation.
Key takeaways
- RTL notation like P: R2 ← R1 describes a hardware-gated copy, not a software conditional — when P = 0 nothing happens, R2 simply keeps its old value.
- Arithmetic microoperations use 2's-complement addition for subtraction with one adder-subtractor; logic microoperations are independent bitwise operations; shifts are logical, arithmetic (sign-preserving) or circular.
- The instruction cycle is fetch, decode, compute effective address (extra access if indirect), execute, then check the interrupt flip-flop — interrupts are only ever noticed at instruction boundaries.
- A two-pass assembler resolves forward references via a symbol table built in its first pass.
- BSA-style subroutine linkage stores one return address per subroutine and cannot support recursion, unlike a stack-based call mechanism.
Practice questions (9)
Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.
In the register transfer statement P: R2 ← R1, if the control condition P is 0 during a given clock cycle:
Show answer
Answer: A — R2 retains its previous value; the transfer simply does not happen that cycle
P physically gates the load-enable pulse to R2's flip-flops; when it is 0 the load simply does not occur that cycle and R2 is unaffected.A single adder-subtractor circuit can perform both addition and subtraction because:
Show answer
Answer: A — Subtraction is implemented as addition of the 2's complement of one operand
Complementing one operand and setting carry-in to 1 turns the adder into a subtractor with no separate circuitry, controlled by a single mode line.In the basic-computer instruction cycle, indirect addressing compared to direct addressing requires:
Show answer
Answer: A — One extra memory access to fetch the actual operand address
The address field points to a memory word holding the operand's real address, so one extra read is needed to dereference that pointer before the operand itself can be fetched.An interrupt requested during instruction execution is typically serviced:
Show answer
Answer: A — Only after the current instruction completes, at an instruction boundary
The control unit checks the interrupt flip-flop only after the execute phase of the current instruction, so an interrupt is always noticed at an instruction boundary and never mid-instruction.A two-pass assembler needs two passes chiefly because:
Show answer
Answer: A — A forward reference to a label defined later needs the symbol table built in pass one before code can be generated in pass two
Without a completed symbol table, a branch to a label appearing later in the source cannot yet be resolved to an address — pass one builds that table, pass two uses it.The BSA (branch-and-save-return-address) subroutine linkage mechanism fails to support recursion because:
Show answer
Answer: A — It stores only one return address per subroutine, overwriting the previous one on re-entry
A recursive call re-enters the same subroutine before the outer call has returned, and BSA has only one slot to hold a return address — the second call's address overwrites the first, so the original return path is lost.Programmed I/O, compared to interrupt-driven I/O, is characterised by:
Show answer
Answer: A — The CPU busy-waiting in a polling loop, wasting cycles
Programmed I/O repeatedly polls a status flag before every word transfer, which is simple to implement but ties up the CPU the entire time — the opposite of interrupt-driven I/O, which lets the CPU do other work until signalled.Which of the following are logic (not arithmetic) microoperations? (More than one option may be correct.)
Show answer
Answer: A — Bitwise AND with a mask; B — Bitwise XOR for selective complementing
AND and XOR operate bit-independently with no carry propagation between bits, which is what makes them logic rather than arithmetic microoperations; subtraction and increment both involve carry propagation across bit positions, which is the arithmetic signature.An arithmetic right shift of the 8-bit signed (2's complement) value 11110000 (which represents −16) by one position gives the bit pattern _____ (write as 8 bits).
Numerical answer — type the value.
Show answer
Answer: 11111000
Arithmetic right shift preserves the sign bit by replicating it into the vacated most-significant position: shifting 11110000 right by one, keeping the leading 1, gives 11111000, which is −8 — correctly halving −16 towards negative infinity.