
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![PLEASE DON'T USE STRUCTS
Using C programming language write a program that simulates a variant of the Tiny Harvard 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 TinyMachine 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, Instruction
Memory (IM), MAR1, MDR-1(MAR-1 and MDR-1 are connected to the IM). Data Memory, MAR-2, MDR2 (MAR-2 and MDR-2 are
connected to the DM), and Accumulator. Instruction Memory will be represented by an integer array and each instruction will
use 2 elements of the array(one for OP and the other one for address) Data Memory will be represented by an integer array and each
data value uses an element of the DM array. Your Program Counter will begin pointing to the first instruction of the program (PC =0).
For the sake of simplicity Instruction Memory (IM) and Data Memory (DM) may be implemented as separate integer arrays.
IM size 250
DM size 10
Hint: All CPU registers and Data Memory (DM) are of type int.
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.
The text file should be named elf.txt. YOU MUST MAKE SURE THAT THE PROGRAM BEING RAN MULTIPLIES TWO NUMBERS.
YOU CAN USE THE OBJECT FILE BELOW TO HELP WITH THIS. The numbers will not be validated. you can use two integers as
inputs 3 and 4.
The program must accept the input values in this order
input1-0 (to accumulate the result here)
input2-1 (top decrement variable that control the loop).
input3: first number to be multiplied (for example, 5)
input4: second number to be multiplied (for example, 3).
Example of reading the object file and printing the Assembly language:
Read
Object File
55
67
30
55
67
31
55
67
32
55
67
33
10
22
30
13
41
33
90
812
10
67
70
Print it.
IN 5
OUT 7
STORE 0
IN 5
IN 5
OUT 7
STORE 1
IN 5
OUT 7
STORE 2
OUT 7
STORE 3
LOAD 0
ADD 2
STORE 0
LOAD 3
SUB 1
STORE 3
SKIP 0
JUMP 12
LOAD 0
OUT 7
END
Output Specifications
The virtual machine(VM) you are implementing 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 my 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 VM. 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.
PC 141A-XIDM = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
storing accumulator to memory location 0"/
PC 161A XIDM (x, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Program complete.
Your program should compile and run from the command line with one input file parameter.
For instance, to implement FETCH and instruction LOAD you must implement each step:
FETCH
MAR1<-PC
PC PC 2
MDR1 IM [MAR1] // IM stands Instruction Memory (program memory)
IR <-MDR1
Case IROP 1 Load is executed.
//LOAD (Execute cycle)
MAR2<-IR ADDR
MDR2DM [MAR2] //DM stands for Data Memory
A <-MDR2
Note: you can use MAR or MAR1 for IM and MAR2 for DM.
Tiny Machine ISA:
FETCH
MAR1 PC
PC <PC+2
MOR1 IM (MAR) // IM stands for Instruction Memory (program memory)
IR-MDR1
Depending on IROP one of the following instructions will be executed:
(Execute cycle)
LOAD
MAR2<IR.ADDR
MDR2 DMMAR2)
AMDR2
ADD
MAR2<IR.ADDR
MDR2DMIMAR2]
A <-A+MDR2
STORE
MAR2<IR.ADDR
MDR2 A
DM[MAR2] <MDR2
Example:
Reading Program...
Program Loaded.
Run.
PC 101A NULLI DM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
input value "/
x
PC-121A XIDM [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
outputting accumulator to screen "/
X
SUB
MAR2<IR ADDR
MDR2DMIMAR2]
AA-MDR2
IN
A Input value from keyboard (emit a message to the user: "Input data:")
OUT
Screen <-A (emit message to the user: "The result is:"
END
Run 0 // In your program Run must be initialized to 1 to control the instruction cycle.
JMP
PCIR.ADDR
SKIP
IF (A0) PC PC +1](https://content.bartleby.com/qna-images/question/44870f31-83c6-452e-ba54-77702704a3ca/daa75681-41d9-4019-9d3d-25a1c810ba6c/2mhwt1s_thumbnail.png)
Transcribed Image Text:PLEASE DON'T USE STRUCTS
Using C programming language write a program that simulates a variant of the Tiny Harvard 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 TinyMachine 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, Instruction
Memory (IM), MAR1, MDR-1(MAR-1 and MDR-1 are connected to the IM). Data Memory, MAR-2, MDR2 (MAR-2 and MDR-2 are
connected to the DM), and Accumulator. Instruction Memory will be represented by an integer array and each instruction will
use 2 elements of the array(one for OP and the other one for address) Data Memory will be represented by an integer array and each
data value uses an element of the DM array. Your Program Counter will begin pointing to the first instruction of the program (PC =0).
For the sake of simplicity Instruction Memory (IM) and Data Memory (DM) may be implemented as separate integer arrays.
IM size 250
DM size 10
Hint: All CPU registers and Data Memory (DM) are of type int.
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.
The text file should be named elf.txt. YOU MUST MAKE SURE THAT THE PROGRAM BEING RAN MULTIPLIES TWO NUMBERS.
YOU CAN USE THE OBJECT FILE BELOW TO HELP WITH THIS. The numbers will not be validated. you can use two integers as
inputs 3 and 4.
The program must accept the input values in this order
input1-0 (to accumulate the result here)
input2-1 (top decrement variable that control the loop).
input3: first number to be multiplied (for example, 5)
input4: second number to be multiplied (for example, 3).
Example of reading the object file and printing the Assembly language:
Read
Object File
55
67
30
55
67
31
55
67
32
55
67
33
10
22
30
13
41
33
90
812
10
67
70
Print it.
IN 5
OUT 7
STORE 0
IN 5
IN 5
OUT 7
STORE 1
IN 5
OUT 7
STORE 2
OUT 7
STORE 3
LOAD 0
ADD 2
STORE 0
LOAD 3
SUB 1
STORE 3
SKIP 0
JUMP 12
LOAD 0
OUT 7
END
Output Specifications
The virtual machine(VM) you are implementing 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 my 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 VM. 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.
PC 141A-XIDM = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
storing accumulator to memory location 0"/
PC 161A XIDM (x, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Program complete.
Your program should compile and run from the command line with one input file parameter.
For instance, to implement FETCH and instruction LOAD you must implement each step:
FETCH
MAR1<-PC
PC PC 2
MDR1 IM [MAR1] // IM stands Instruction Memory (program memory)
IR <-MDR1
Case IROP 1 Load is executed.
//LOAD (Execute cycle)
MAR2<-IR ADDR
MDR2DM [MAR2] //DM stands for Data Memory
A <-MDR2
Note: you can use MAR or MAR1 for IM and MAR2 for DM.
Tiny Machine ISA:
FETCH
MAR1 PC
PC <PC+2
MOR1 IM (MAR) // IM stands for Instruction Memory (program memory)
IR-MDR1
Depending on IROP one of the following instructions will be executed:
(Execute cycle)
LOAD
MAR2<IR.ADDR
MDR2 DMMAR2)
AMDR2
ADD
MAR2<IR.ADDR
MDR2DMIMAR2]
A <-A+MDR2
STORE
MAR2<IR.ADDR
MDR2 A
DM[MAR2] <MDR2
Example:
Reading Program...
Program Loaded.
Run.
PC 101A NULLI DM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
input value "/
x
PC-121A XIDM [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
outputting accumulator to screen "/
X
SUB
MAR2<IR ADDR
MDR2DMIMAR2]
AA-MDR2
IN
A Input value from keyboard (emit a message to the user: "Input data:")
OUT
Screen <-A (emit message to the user: "The result is:"
END
Run 0 // In your program Run must be initialized to 1 to control the instruction cycle.
JMP
PCIR.ADDR
SKIP
IF (A0) PC PC +1
Expert Solution

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 nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- Write an assembly program for the processor family x86-32 that reads three real numbers from the keyboard and shows on the console the average value of them. In your implementation include the function averageOfThree and define for that function the interface below. ; ******************************************************************************************************************* averageOfThree: ; Input: Three memory addresses on the stack of three 64-bit floating point numbers in main memory. ; Output: The average value of the three input numbers on the stack as a 64-bit floating point number.arrow_forwardAnalyze the code solution below and discuss any gain in performance. To gather measurement values, use any CUDA or OpenMP library API that is used to measure performance (time, speedup, etc..) or by using what is offered by the compiler (C, C++). #include <stdlib.h> //malloc and free #include <stdio.h> //printf #include <omp.h> //OpenMP // Very small values for this simple illustrative example #define ARRAY_SIZE 8 //Size of arrays whose elements will be added together. #define NUM_THREADS 4 //Number of threads to use for vector addition. /* int main (int argc, char *argv[]) { // elements of arrays a and b will be added // and placed in array c int * a; int * b; int * c; intn = ARRAY_SIZE; // number of array elements intn_per_thread; // elements per thread inttotal_threads = NUM_THREADS; // number of threads to use inti; // loop index // allocate space for the arrays a = (int *) malloc(sizeof(int)*n); b = (int *) malloc(sizeof(int)*n); c = (int *)…arrow_forwardx86 Assembly Programming-MASM - Use Irvine32.inc Write a program with a loop and indexed addressing that calculates sum of the values of elements of a DWORD array that are located at multiple of 5 location. For example for the array 2,3,4,5,6,7,8,9,10,11,12,13,14,15 Program calculates: 5+10+15arrow_forward
- NAND2TETRIS HARDWARE SIMULATOR HiLoMux - This has one 8-bit input bus, in, and one 4-bit output bus, out. Alsopresent is a sel input, which is used to select what appears on out. Ifsel is false, then out should contain the lower 4-bits of in (i.e. in[0],in[1], in[2], in[3]). If sel is true, then out should contain theupper 4-bits of in (i.e. in[4] mapped to out[0], in[5], mapped toout[1], etc.). In other words, the HiLoMux can be used to select anibble from a byte please use the skeleton program below CHIP HiLoMux{ IN in[8], sel; OUT out[4]; PARTS: }arrow_forwardassembly language please with comment and screen shot of the out putarrow_forwardPLEASE HELParrow_forward
- Example: The Problem Input File 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: //IN 5 //OUT 7 //STORE O //IN 5 //OUT 7 //STORE 1 //LOAD O //SUB 1 55 67 30 55 67 1 LOAD 2- ADD 3> STORE 4> SUB 5> IN 6> OUT 7> END 8> JMP 9> SKIPZ 31 10 41 30 //STORE O 67 //OUT 7 11 /LOAD 1 //OUT 7 //END 67 70 Output Specifications 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. Your simulator should provide output according to the input file. Along with…arrow_forwardIn assembly 68k write the: Initialize the supervisor stack pointer to $8000 Initialize the program counter to $1000 Reserve locations at $2000 to hold your first name only (Joshua) as text and call it NAM Reserve locations at $3000 to store 9 longwords, call it MEM, and write your family name (Kimmich) as a comment Reserve locations at $12400 to store 32-bit unsigned integer variable called RES (to be computed)arrow_forwardAnswser must be in MIPSzy assembly language. Max of 3 - Brancharrow_forward
- Indirect Addressing Mode Instruction 002A J@ RETADR 3E20030030 RETADR RESW 1 1.Instruction Starts with 002A2.Opcode of J is 3C3.Object code is 3E2003Please show the detailsarrow_forwardE In the following code block(Reference:Q11), you will a set of assembly instructions with corresponding line numbers (line numbers are for informational purpose only and they are not part of the source code). 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 mov edx, 5 dec ecx jmp LABEL1 mov eax, 1 LABEL1: mul edx jmp ecx mov edx, 0678h sub edx, eax jmp DWORD PTR [edx] neg ebx add ecx, ebx mov eax, 0 For each of the conditions/scenario listed below, indicate the corresponding line number (that cause or is associated with the condition/scenario). Enter 0 (Zero) if the condition is not caused by the block of code. 1) Memory indirect jump: type your answer... type your answer... type your answer... type your answer... 2) Register indirect jump: 3) Relative short jump: type your answer... 5) Two's complement type your answer... 4) Relative near jump: 6) Unreachable codearrow_forwardlist: .word 3, 0, 1, 2, 6, -2, 4, 7, 3, 7 size: .word 10 Develop a mips code with a Mars simulator that reads this sequence and counts those <0 (negative) and >=0 (zero or positive) and prints what it finds to the screen.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education