Question: In this assignment, you will create a program in C to simulate the instruction life cycle of a simplified computer architecture. You will implement a

In this assignment, you will create a program in C to simulate the instruction life cycle of a simplified
computer architecture. You will implement a fetch-decode-execute cycle and demonstrate how different
op codes affect the execution of instructions. (10 Marks)
Scenario Description:
Imagine you are a computer architect tasked with building a simulator for a basic computer architecture.
Your goal is to create a program that can execute a series of instructions, each with its own op code, and
show how the fetch-decode-execute cycle works.
Requirements:
1. Write a C program named instruction_simulator.c.
2. Define a simplified instruction set with at least five different op codes. Each op code should
correspond to a specific operation (e.g., ADD, SUB, LOAD, STORE, etc.). Create an enum or
constants to represent these op codes.
3. Implement a fetch-decode-execute cycle within a loop that processes a sequence of instructions.
The cycle should include the following steps:
a. Fetch: Fetch the next instruction from memory.
b. Decode: Determine the operation to be performed based on the op code.
c. Execute: Perform the operation and update the program state accordingly.
4. Create a data structure (e.g., an array) to represent the memory of the computer. Initialize this
memory with a sequence of instructions using the op codes defined in step 2.
5. Print the state of the computer (e.g., memory contents, registers) before and after each
instruction is executed.
6. Implement at least two sample programs using your defined op codes and memory layout.
7. These programs should consist of sequences of instructions that demonstrate various operations
and interactions between instructions.
8. Use comments to explain the purpose of each part of your code and how the fetch-decodeexecute cycle works.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!