You are on page 1of 7

Experiment 3 Lab Manual

American International University- Bangladesh


Department of Electrical and Electronic Engineering
EEE 4219: Computer System Architecture Laboratory

Title: Computer System Simulation using MARIE Simulation Software.

Introduction:

The Idea of this experiment is to obtain the knowledge required to enter, assemble, and
execute a program in MARIE Simulator.

MarieSim is a rich graphical machine simulation environment. Its features are best
appreciated after you have experimented with a simple program or two. The following are the
steps required to enter, assemble, and execute a program.

Theory and Methodology:

Software Running Procedure:

Using the Executable JAR File:

It is not necessary to unpack (unJAR) the MARIE machine simulator and its accompanying
datapath simulator in order to run them. All that you need to do is double click on the
MarieSim.jar icon to invoke the MARIE simulator, or the MarieDP1.jar file to invoke the
datapath simulator. You may wish to copy, or drag and drop, the jar files to a convenient
location on your system (such as the desktop). If you double click and the software will not
run, check the information in the complete MarieGuide documentation on path and classpath.

Quick Start Steps

1) Start the simulator.

To invoke MarieSim using the executable JAR file, simply double click on the MarieSim
JAR icon. If you've uncompressed the simulator files and prefer to run the simulator from
a command prompt, log into the directory where you have installed MarieSim, and type:
java MarieSim1

2) Invoke the Code Editor:

From the [File] menu on the menu bar, select [Edit] as shown in the illustration.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 1


3) Enter the program source code:

Using the editor pop up window, type your MARIE assembly instructions. The MARIE
editor supports basic editing functions such as cut and paste.

4) Save the program source code:

Select [Save] from the menu bar of the editor. The simulator automatically saves the file
with a .mas extension.

5) Assemble the program source code:

Select [Assemble] from the menu bar. If your program contains no errors, a message
displays at the bottom of the editor telling you that the assembly was successful. If your
file contains errors, the assembly listing will pop up on the screen, and the message at the
bottom of the editor will be highlighted.

6) Close the editor:

Close the editor window by selecting [File] [Exit] or by clicking on the close icon at the
upper right-hand corner of the editor panel.
© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 2
7) Load the program:

From the main simulator pane select [Load] from the [File] menu bar option. The file
dialog pops up, showing you all of the MARIE executable files (.mex) files in the current
directory. You can navigate through your directory structure if needed.

8) Run the program:

Select any of the run mode options from the [Run] menu. This menu allows you to turn
step mode off and on, and set a delay between each instruction.

9) Observe data path instruction execution:

Type:
java MarieDP1

10) Load an executable Marie file:

Select [Load] from the [File] menu on the menu bar. A file dialog will appear that shows
all of the MARIE executable files in the currently logged directory. (You can navigate the
directory structure as needed.) Note: The data path simulator will load only executable
(.mex) files that have been assembled in the Marie simulator.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 3


11) Run the program:

To begin execution, you can select [Run] or [Step]. If you select [Step], a single fetch-
decode-execute cycle is processed in the simulator. [Run] executes the program without
pausing. (You can stop the program during its execution.) If you find that observing the
instruction fetch part of the simulation becomes boring, you can turn "fast fetch mode"
on. This feature reduces the delay between machine cycles during instruction fetch only.
The machine cycle delay is restored for the rest of the instruction execution.

A Few Words Regarding the MARIE Assembler:

Your book discusses each of MARIE's instructions in detail, so we will not restate them here.
There are, however, a few things particular to the assembler that you'll need to know before
you begin writing your first program.

Assembler Directives:

There are four directives that the MARIE assembler recognizes. The first of these is the
origination directive, ORG. The ORG directive controls the starting address of your
program. If you do not include an ORG directive in your code, the first address of your
program is automatically 000h. (Note: On a real machine, you could not count on this,
which is why origination directives are used.) If you want the first address of your program
to be 010h, you would place the directive, ORG 010 at the beginning of your program. The
ORG directive must be the first statement of your program, otherwise, the assembler will give
you an error.

The other three directives enable you to put constants in your program as decimal (DEC),
octal (OCT), and hexadecimal (HEX) numbers. These constants must be valid for the radix
stated in the directive. For example, the statement, OCT 0900, will give you an error.

Recall that MARIE's word size is 16 bits, and all constants are assumed to be signed
numbers. Therefore, the valid range of decimal constants is decimal –32,768 to 32,767
(8000h to 7FFFh).

Operands:

As you learned in Chapter 4, all MARIE operands are addresses. If you use address literals
in your program, the valid values are 000h through FFFh, since MARIE has 4096 memory
locations. These addresses must be given in hexadecimal, preceded by a zero. So, if you
wish to add the value at address F00 to the accumulator, you would use the instruction, ADD
0F00. If you instead use the instruction, ADD F00, the assembler will expect to find the
label F00 somewhere in your program. Unless you have such an address in your program,
the assembler will give you an error.
© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 4
You may prefer to use symbolic labels instead of address literals. MARIE's labels are case
sensitive and can be of virtually any length (up to the limits placed on string variables by the
Java language). Be advised, however, that only the first 24 characters of the symbol will
print on the assembly listing and only the first 7 characters will be visible in MARIESim's
program monitor panel.

Code Construction:

Assembly language source code files can be of any size, but you can have only as many
program statements as will fit in the MARIE memory. The program statement count does not
include comments or blank lines. We encourage you to use comments and blank lines to
make your code understandable to humans as well as the machine.

The only other restriction on your code is that it can begin with only the following types of
statements:
1) A comment followed by an origination directive and at least one imperative
statement.
2) An origination directive and at least one imperative statement, or
3) At least one imperative statement.

In other words, your program cannot begin with a DEC, OCT or HEX directive. If it does,
neither the assembler nor the simulator will care, but the literal values defined by those
directives will be interpreted as instructions by the machine, giving you results that you may
not have expected.

A similar problem will arise if you fail to include a HALT statement in your program, or your
HALT statement does not execute, and the program counter ends up pointing to data. (How
will the machine react if it tries to execute the statement HEX 0000? What about HEX
0700?)

Creating a Program in MARIE Assembly Language:

Approach:

Given a problem to solve, here's how to create a program to solve that problem, in MARIE
assembly language.
You need to know two things:

1) An understanding of the MARIE instruction set, and how to build a program from that
instruction set. In other words, how to combine those instructions in a way that builds
to a working program.
2) An understanding of the problem, and any related algorithms needed to solve it.

The MARIE Instruction Set:

Here's a convenient table of all the MARIE instructions and their operands (if any). In the
table, each instruction has a brief description of what it does, but you'll need to familiarize
yourself with the details of each instruction's workings. Fortunately, this is pretty easy for
most instructions.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 5


Remember that any program written with MARIE instructions normally flows linearly from
one address to the next. The Skipcond, Jump, and Jumpl instructions change this behavior,
and are used when you want to do different things based on the values of your data, etc.

Understanding your Problem, and Coming Up with Algorithms:

1) To come up with a program to solve your problem, you need to look at the problem
and understand it. If the problem is too large to really understand, then you should try
to break it down into smaller sub-problems which when combined, will solve your
entire problem. If a sub-problem is too large to understand completely, then you need
to break it down into its sub-problems and so on.
2) You repeat this until you have a set of sub-problems which are small enough for you
to understand completely. This process is called stepwise refinement, and uses a
common strategy for any kind of problem-solving: a divide and conquer strategy.
3) Once you have identified all the sub-problems that are simple enough to understand
without needing to break them down any further, then you can start to come up with
algorithms to implement them.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 6


An algorithm is a step-by-step procedure for solving a problem or accomplishing some end.

Once you have constructed all the necessary algorithms, you can then recombine all the sub-
problems in the appropriate sequence to solve your original problem. This recombination also
constitutes an algorithm.

Apparatus:

1) Computer System For Simulation


2) Marie Sim Simulator

Experimental Procedure:

NOTE: Be sure that the Java virtual machine version 1.4 (JRE) or later is installed on
your machine. Visit Sun's Java site, java.sun.com, to get a copy.

1) Enter, assemble, load and run (step by step) the example problem in the MARIE
simulator.
2) In each step observe the change in MARIE register contents and main memory
contents.
3) Write a program to add three numbers and output the result. One of the numbers must
be entered from the keyboard.

References:

[1] Null and Lobur, Jones & Bartlett, Essentials of Computer Organization and Architecture,
1st edition

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 7

You might also like