Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need this in C languge and please explain me in a side comment in every part how that code is working . and please

i need this in C languge and please explain me in a side comment in every part how that code is working . and please also share the screen shot of running code. its should be run from the comand line.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Using 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 LOAD 2 ADD 3 STORE 4 SUB 5 IN 6 OUT 7 END 8 JMP 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: typedef struct \{ int opCode, device Or Address; Instruction; Instruction IM[MAXPROGRAMSIZE]; Note: IM, MDR1, and IR are of type Instruction. All other CPU 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: utput Specifications our simulator should provide output according to the input file. long with this output your program should provide status messages entifying details on the workings of your simulator. Output text es not have to reflect my example word-for-word, but please ovide detail on the program as it runs in a readable format that es not conflict with the actual output of your simulator. After each struction print the current state of the Program Counter, ccumulator, and Data Memory. The INPUT instruction is the only ie that should prompt an interaction from the user. Example: Assembling Program... Program Assembled. Run. PC=10A=NULLDM=[0,0,0,0,0,0,0,0,0,0]/inputvalue*/XPC=11A=XDM=[0,0,0,0,0,0,0,0,0,0]/outputtingaccumulatortoscreen/XPC=12A=XDM=[0,0,0,0,0,0,0,0,0,0] /* storing accumulator to memory location 0 / PC=13A=XDM=[X,0,0,0,0,0,0,0,0,0] etc Program complete. For instance, to implement FETCH and instruction LOAD you must implement each step: FETCH MAR B PC PCBPC+1 MDR B IM [MAR] // IM stands for Instruction Memory (program memory) IR B MDR Case IR.OP =1 Load is executed. LOAD (Execute cyele) MAR2 B IR.ADDR MDR2 B DM [MAR2] I/DM stands for Data Memory A B MDR2 Note: Lecture 1 describes the instruction set architecture of the Tiny Machine. Submission Your program must be submitted as a C file. For example: NameMyProgram.c Please check and double check your submission. Note: you can use one or two MARs, MAR for IM and MAR2 for DM. Depending on IR.OP one of the following instructions will be executed: (Execute cycle) LOAD MAR2 B IR.ADDR MDR2 B DM[MAR2] A B MDR2 ADD Depending on IR.OP one of the following instructions will be executed: (Execute cycle) LOAD MAR2 B IR.ADDR MDR2 B DM[MAR2] A B MDR2 ADD MAR2 B IR.ADDR MDR2 B DM[MAR2] A B A + MDR2 STORE MAR2 B IR.ADDR MDR2 B A DM[MAR2] B MDR2 SUB MAR2 B IR.ADDR MDR2 B DM[MAR2] ABAMDR2 IN A B Input value from keyboard OUT Screen B A END Run B 0 // In your program Run must be initialized to 1 to control the instruction cycle. JMP PC B IR.ADDR SKIP IF (A=0)PCBPC+1

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

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

What is Ramayana, who is its creator, why was Ramayana written?

Answered: 1 week ago

Question

To solve by the graphical methods 2x +3y = 9 9x - 8y = 10

Answered: 1 week ago

Question

Does it have at least one-inch margins?

Answered: 1 week ago

Question

Does it highlight your accomplishments rather than your duties?

Answered: 1 week ago