Your simulator must run from the command line with a single input file as a parameter to main. This file will contain a sequence of instructions for your simulator to store in "Instruction Memory" and then run via the fetch/execute cycle. In the input file each instruction is represented with two integers: the first one represents the opcode and the second one a memory address or a device number depending on the instruction.
Your simulator must run from the command line with a single input file as a parameter to main. This file will contain a sequence of instructions for your simulator to store in "Instruction Memory" and then run via the fetch/execute cycle. In the input file each instruction is represented with two integers: the first one represents the opcode and the second one a memory address or a device number depending on the instruction.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![### Input Specifications
Your simulator must run from the command line with a single input file as a parameter to main. This file will contain a sequence of instructions for your simulator to store in "Instruction Memory" and then run via the fetch/execute cycle. In the input file, each instruction is represented with two integers: the first one represents the opcode and the second one a memory address or a device number depending on the instruction.
#### Example:
**Input File**
```
5 5 // IN 5
6 7 // OUT 7
3 0 // STORE 0
5 5 // IN 5
6 7 // OUT 7
3 1 // STORE 1
1 0 // LOAD 0
4 1 // SUB 1
3 0 // STORE 0
6 7 // OUT 7
1 1 // LOAD 1
6 7 // OUT 7
7 0 // END
```
### Output Specifications
Your simulator should provide output according to the input file. Along with this output, your program should provide status messages identifying details on the workings of your simulator. Output text does not have to reflect the example word-for-word, but please provide detail on the program as it runs in a readable format that does not conflict with the actual output of your simulator. After each instruction, print the current state of the Program Counter, Accumulator, and Data Memory. The INPUT instruction is the only one that should prompt an interaction from the user.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F862d67f6-41ff-41a6-a751-26ec3266bc03%2F1cbfbcb3-b8c6-47ff-ac00-4d0a986f53e7%2Flsoo1vk_processed.png&w=3840&q=75)
Transcribed Image Text:### Input Specifications
Your simulator must run from the command line with a single input file as a parameter to main. This file will contain a sequence of instructions for your simulator to store in "Instruction Memory" and then run via the fetch/execute cycle. In the input file, each instruction is represented with two integers: the first one represents the opcode and the second one a memory address or a device number depending on the instruction.
#### Example:
**Input File**
```
5 5 // IN 5
6 7 // OUT 7
3 0 // STORE 0
5 5 // IN 5
6 7 // OUT 7
3 1 // STORE 1
1 0 // LOAD 0
4 1 // SUB 1
3 0 // STORE 0
6 7 // OUT 7
1 1 // LOAD 1
6 7 // OUT 7
7 0 // END
```
### Output Specifications
Your simulator should provide output according to the input file. Along with this output, your program should provide status messages identifying details on the workings of your simulator. Output text does not have to reflect the example word-for-word, but please provide detail on the program as it runs in a readable format that does not conflict with the actual output of your simulator. After each instruction, print the current state of the Program Counter, Accumulator, and Data Memory. The INPUT instruction is the only one that should prompt an interaction from the user.
![**The Problem**
Using the C programming language, write a program that simulates a variant of the Tiny Machine Architecture. In this implementation, memory (RAM) is split into Instruction Memory (IM) and Data Memory (DM). Your code must implement the basic instruction set architecture (ISA) of the Tiny Machine Architecture:
1. 1 → LOAD
2. 2 → ADD
3. 3 → STORE
4. 4 → SUB
5. 5 → IN
6. 6 → OUT
7. 7 → END
8. 8 → JMP
9. 9 → SKIPZ
Each piece of the architecture must be accurately represented in your code (Instruction Register, Program Counter, Memory Address Registers, Instruction Memory, Data Memory, Memory Data Registers, and Accumulator). Data Memory will be represented by an integer array. Your Program Counter will begin pointing to the first instruction of the program.
**For the sake of simplicity, Instruction Memory (IM) and Data Memory (DM) may be implemented as separate arrays.**
**Hint:** Implementing a struct for your Instructions and an array of these structs as your Instruction Memory greatly simplifies this program.
**Example:**
```c
typedef struct {
int opCode, deviceOrAddress;
} Instruction;
Instruction IM[MAXPROGRAMSIZE];
```
**Note:** IM, MDR1, and IR are of type Instruction. All other CPU registers and Data Memory (DM) are of type int.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F862d67f6-41ff-41a6-a751-26ec3266bc03%2F1cbfbcb3-b8c6-47ff-ac00-4d0a986f53e7%2Fijlqhc8_processed.png&w=3840&q=75)
Transcribed Image Text:**The Problem**
Using the C programming language, write a program that simulates a variant of the Tiny Machine Architecture. In this implementation, memory (RAM) is split into Instruction Memory (IM) and Data Memory (DM). Your code must implement the basic instruction set architecture (ISA) of the Tiny Machine Architecture:
1. 1 → LOAD
2. 2 → ADD
3. 3 → STORE
4. 4 → SUB
5. 5 → IN
6. 6 → OUT
7. 7 → END
8. 8 → JMP
9. 9 → SKIPZ
Each piece of the architecture must be accurately represented in your code (Instruction Register, Program Counter, Memory Address Registers, Instruction Memory, Data Memory, Memory Data Registers, and Accumulator). Data Memory will be represented by an integer array. Your Program Counter will begin pointing to the first instruction of the program.
**For the sake of simplicity, Instruction Memory (IM) and Data Memory (DM) may be implemented as separate arrays.**
**Hint:** Implementing a struct for your Instructions and an array of these structs as your Instruction Memory greatly simplifies this program.
**Example:**
```c
typedef struct {
int opCode, deviceOrAddress;
} Instruction;
Instruction IM[MAXPROGRAMSIZE];
```
**Note:** IM, MDR1, and IR are of type Instruction. All other CPU registers and Data Memory (DM) are of type int.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY