All Exams Test series for 1 year @ ₹349 only
Question

The following program is stored in the memory unit of the basic computer. Give the content of accumulator register in hexadecimal after the execution of the program.

Location

Instruction

010

CLA

011

ADD 016

012

BUN 014

013

HLT

014

AND 017

015

BUN 013

016

C1A5

017

93C6

The correct answer is

8184

Understanding Basic Computer Program Execution

This question asks us to trace the execution of a small program stored in the memory of a basic computer and determine the final content of the accumulator (AC) register in hexadecimal format. The program uses fundamental instructions like CLA (Clear Accumulator), ADD (Add to Accumulator), BUN (Branch Unconditionally), HLT (Halt), and AND (Bitwise AND).

Initial State and Program Loading

The program is loaded into memory starting from location 010. The memory locations 016 and 017 contain data values that the program will use. The accumulator (AC) is a central register that holds data for processing.

Location (Hex) Instruction / Data (Hex) Instruction Mnemonic
010 CLA (Encoded) CLA
011 ADD 016 (Encoded) ADD 016
012 BUN 014 (Encoded) BUN 014
013 HLT (Encoded) HLT
014 AND 017 (Encoded) AND 017
015 BUN 013 (Encoded) BUN 013
016 C1A5 Data
017 93C6 Data

Tracing Program Execution

Let's trace the program step-by-step, keeping track of the Program Counter (PC) and the Accumulator (AC).

  • Location 010: CLA
    • The instruction at location 010 is CLA (Clear Accumulator).
    • The content of the Accumulator (AC) is set to 0.
    • AC = \(0_{hex}\)
    • PC is incremented to 011.
  • Location 011: ADD 016
    • The instruction at location 011 is ADD 016.
    • This instruction adds the content of memory location 016 to the Accumulator.
    • The content of memory location 016 is C1A5 (hexadecimal).
    • AC = AC + Memory[016] = \(0_{hex} + C1A5_{hex} = C1A5_{hex}\).
    • PC is incremented to 012.
  • Location 012: BUN 014
    • The instruction at location 012 is BUN 014 (Branch Unconditionally to location 014).
    • The Program Counter (PC) is updated to 014.
    • PC is now 014. The instruction at 013 (HLT) is skipped.
  • Location 014: AND 017
    • The instruction at location 014 is AND 017.
    • This instruction performs a bitwise AND operation between the content of the Accumulator (AC) and the content of memory location 017. The result is stored back in the Accumulator.
    • AC contains C1A5 (hex).
    • Memory[017] contains 93C6 (hex).
    • We need to perform C1A5 AND 93C6. Let's convert these hexadecimal values to binary:
    • \(C1A5_{hex} = 1100\ 0001\ 1010\ 0101_{binary}\)
    • \(93C6_{hex} = 1001\ 0011\ 1100\ 0110_{binary}\)
    • Now perform the bitwise AND operation:
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
AC (\(C1A5_{hex}\)) 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 1
Memory[017] (\(93C6_{hex}\)) 1 0 0 1 0 0 1 1 1 1 0 0 0 1 1 0
Result (AC AND Mem[017]) 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0

    • Convert the resulting binary back to hexadecimal:
    • \(1000\ 0001\ 1000\ 0100_{binary} = 8\ 1\ 8\ 4_{hex} = 8184_{hex}\)
    • So, AC = \(8184_{hex}\).
    • PC is incremented to 015.
  • Location 015: BUN 013
    • The instruction at location 015 is BUN 013 (Branch Unconditionally to location 013).
    • The Program Counter (PC) is updated to 013.
    • PC is now 013.
  • Location 013: HLT
    • The instruction at location 013 is HLT (Halt).
    • The program execution stops here.

Final Accumulator Content

After the execution of the program halts at location 013, the final content of the Accumulator (AC) register is \(8184_{hex}\).

Revision Table: Basic Computer Instructions

Mnemonic Description Operation on AC
CLA Clear Accumulator AC ← 0
ADD M Add content of memory location M AC ← AC + M[Address]
AND M Bitwise AND with content of memory location M AC ← AC AND M[Address]
BUN M Branch Unconditionally to location M PC ← Address
HLT Halt Computer Stops program execution

Additional Information: Basic Computer Architecture Concepts

The program demonstrates key aspects of a basic computer's architecture and instruction cycle:

  • Program Counter (PC): This register holds the address of the next instruction to be fetched. It is typically incremented after fetching an instruction, except when a branch instruction (like BUN) is executed, which loads a new address into the PC.
  • Accumulator (AC): This is a general-purpose register used to store data and results of arithmetic and logic operations. Instructions like ADD and AND operate on the content of the AC.
  • Instruction Cycle: The basic computer executes instructions in a cycle that typically involves Fetching the instruction from memory (address specified by PC), Decoding the instruction to determine the operation, and Executing the operation (which might involve fetching operands from memory, performing calculations, and storing results). Branch instructions like BUN alter the normal sequence by changing the PC during the execute phase.
  • Memory Unit: Stores both instructions and data. Each location has a unique address.
  • Hexadecimal Representation: Used to represent memory addresses and data values concisely. Understanding how to convert between hexadecimal and binary is crucial for performing bitwise operations like AND.
Was this answer helpful?

Important Questions from Instruction Format - Teaching

  1. A micro instruction format has micro operation field which is divided into 2 subfields F1 and F2, each having 15 distinct microoperations, condition field CD for four status bits, branch field BR having four options used in conjunction with address field AD. The address space is of 128 memory words. The size of micro instruction is:

  2. A computer uses a memory unit of 512 K words of 32 bits each. A binary instruction code is stored in one word of the memory. The instruction has four parts: an addressing mode field to specify one of the two-addressing mode (direct and indirect), an operation code, a register code part to specify one of the 256 registers and an address part. How many bits are there in addressing mode part, opcode part, register code part and the address part?

  3. Which of the following is not an example of pseudo‐instruction?

  4. A Computer uses a memory unit with 256K word of 32 bits each. A binary instruction code is stored in one word of memory. The instruction has four parts: an indirect bit, an operation code and a register code part to specify one of 64 registers and an address part. How many bits are there in operation code, the register code part and the address part?

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App