Question: A Program Simulating Modified MARIEs Computer Language : C++ Input : A text file containing decimal (not Hex) machine code (not assembly code) for MARIEs

A Program Simulating Modified MARIEs Computer

Language: C++

Input: A text file containing decimal (not Hex) machine code (not assembly code) for MARIEs computer following instruction set described in chapter 4. Instructions are in different lines (no need for semicolon at the end of each instruction)

Output:

Any output specified in the input file by 6000 will be displayed on screen

Computer specification:

Generally the same as in chapter 4:

? 1000 memory address: 000999

? Four digits decimal instruction or data in each memory slot.

? One PC, one AC, one IR, one MBR, one MAR

? The program in the input file needs to be loaded into memory first and stored in consecutive slots starting from address 000

? Instruction 5000 will ask users input from keyboard, 6000 displays content in calculator

? Instruction 8000 will skip next instruction if AC<0. Instruction 8100 will skip next instruction if AC=0. Instruction 8200 will skip next instruction if AC>0

Other requirements:

Your program should accept any length of input program that can be fit in MARIEs 1000 memory slots and generate correct result and/or output on screen.

Submit the source code together with readme file with instruction to compile, build and use your program

1. Load X

Recall that this instruction loads the contents of memory location X into the AC. However, the address X

must first be placed into the MAR. Then the data at location M[MAR] (or address X) is moved into the

MBR. Finally, this data is placed in the AC.

MAR ? X

MBR ? M[MAR]

AC ? MBR

Because the IR must use the bus to copy the value of X into the MAR, before the data at location X can

be placed into the MBR, this operation requires two bus cycles. Therefore, these two operations are on

separate lines to indicate that they cannot occur during the same cycle. However, because we have a

special connection between the MBR and the AC, the transfer of the data from the MBR to the AC can

occur immediately after the data is put into the MBR, without waiting for the bus.

2. Store X

This instruction stores the contents of the AC in memory location X:

MAR ? X, MBR ? AC

M[MAR] ? MBR

3. Add X

The data value stored at address X is added to the AC. This can be accomplished as follows:

MAR ? X

MBR ? M[MAR]

AC ? AC + MBR

4. Subt X

Similar to Add, this instruction subtracts the value stored at address X from the accumulator and places

the result back in the AC:

MAR ? X

MBR ? M[MAR]

AC ? AC MBR

5. Input

Any input from the input device is first routed into the InREG. Then the data is transferred into the AC.

AC ? InREG

6. Output

This instruction causes the contents of the AC to be placed into the OutREG, where it is eventually sent to

the output device.

OutREG ? AC

7. Halt

No operations are performed on registers; the machine simply ceases execution of the program.

8. Skipcond

Recall that this instruction uses the bits in positions 10 and 11 in the address field to determine what

comparison to perform on the AC. Depending on this bit combination, the AC is checked to see whether it

is negative, equal to 0, or greater than 0. If the given condition is true, then the next instruction is skipped.

This is performed by incrementing the PC register by 1.

9. Jump X

This instruction causes an unconditional branch to the given address, X. Therefore, to execute this

instruction, X must be loaded into the PC.

PC ? X

In reality, the lower or least significant 12 bits of the instruction register (or IR[110]) reflect the

value of X. So this transfer is more accurately depicted as:

PC ? IR[11-0]

However, we feel that the notation PC ? X is easier to understand and relate to the actual instructions, so

we use this instead.

Register transfer notation is a symbolic means of expressing what is happening in the system when a

given instruction is executing. RTN is sensitive to the datapath, in that if multiple microoperations must

share the bus, they must be executed in a sequential fashion, one following the other.

Example:

Input file contains following code (return positive difference):

5000

2011

5000

2012

4011

8000

9009

1011

4012

6000

7000

Running of the program with this input will ask user to input 2 numbers, let's say 5 and 10, the program will output the positive difference on the screen, which is 5.

Address

Content

Comment

000

5000

Input the first number

001

2011

Save the first number to address 011

002

5000

Input the second number

003

2012

Save the second number to address 012

004

4011

Second number First number, result in AC

005

8000

If AC<0 jump to address 007

006

9009

Jump to address 009

007

1011

Load the first number to AC

008

4012

First number second number, result in AC

009

6000

Print ACs value

010

7000

Halt

011

Storage for first number

012

Storage for second number

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!