Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

5. Discuss the key components of behavior modeling training.

Answered: 1 week ago

Question

4. Develop a self-directed learning module.

Answered: 1 week ago