0% found this document useful (0 votes)
204 views67 pages

Using The MARIE Simulator

The document provides instructions for using the MARIE simulator to write, assemble, and run simple assembly language programs. It discusses downloading the Java runtime, opening the MARIE simulator jar file, writing code in the editor, assembling the code, loading and running the executable in the simulator interface, and interpreting the output. The interface includes areas to monitor memory, registers, programs, and output.

Uploaded by

Dann Laurte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
204 views67 pages

Using The MARIE Simulator

The document provides instructions for using the MARIE simulator to write, assemble, and run simple assembly language programs. It discusses downloading the Java runtime, opening the MARIE simulator jar file, writing code in the editor, assembling the code, loading and running the executable in the simulator interface, and interpreting the output. The interface includes areas to monitor memory, registers, programs, and output.

Uploaded by

Dann Laurte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

USING THE

MARIE SIMULATOR

SCHOOL OF COMPUTING MITCH M. ANDAYA


INTRODUCTION
• MarieSim is a rich graphical machine simulation environment.

• Its features are best appreciated after you have experimented


with a simple program or two.

• This guide presents the basic steps required to enter, assemble,


and execute a program.

• Be sure that the latest version of the Java SE Runtime


Environment is installed on your machine. You may download it
from here:

https://www.oracle.com/java/technologies/javase-jre8-downloads.html

Select Windows x64 (jre-8u261-windows-x64.exe).

Using the MARIE Simulator


RUNNING THE MARIE SIMULATOR
• The first step is to
unzip the file
MarieSim-v3.00.

• Inside the directory


is a file called
MarieSim.jar which
is the executable
JAR file for the
simulator.

It is not necessary
to unpack (unJAR)
the MARIE
machine simulator
in order to run it.

Using the MARIE Simulator


RUNNING THE MARIE SIMULATOR
• To invoke MarieSim using the executable JAR file, double click on
the MarieSim JAR icon.

• This is the
graphical
environment
of the MARIE
machine
simulator.

This is where
assembly
language
programs are
executed or
simulated.

Using the MARIE Simulator


RUNNING THE MARIE SIMULATOR
• To invoke MarieSim using the executable JAR file, double click on
the MarieSim JAR icon.

• However, this
is not where
the programs
are typed.

• Programs are
typed and
assembled
using the
MARIE
Assembler
Code Editor.

Using the MARIE Simulator


WRITING A PROGRAM
• To invoke the code editor, select [Edit] from the [File] menu. This
will open the MARIE Assembler Code Editor in a new window.

Using the MARIE Simulator


WRITING A PROGRAM

• Using the
MARIE
Assembler
Code Editor
pop up
window, type
your MARIE
assembly
instructions.

• The code editor


supports basic
editing
functions such
as cut and
paste.

Using the MARIE Simulator


WRITING A PROGRAM

• Type the very


first assembly
program that
was discussed.

• The Org directive


simply tells the
assembler to
store the
program starting
(originating) at
memory address
10016.

• Remember, MARIE uses 12-bit memory addresses (3


hexadecimal numbers). Data and instructions use 16
bits (4 hexadecimal numbers).

Using the MARIE Simulator


WRITING A PROGRAM

• After typing
the code,
save the
program
source code.

• Select [Save
As] from the
[File] menu.

Using the MARIE Simulator


WRITING A PROGRAM

• Type in the
name of your
program.

Source codes
should have
an extension
of .mas
(MARIE
source code).

Make sure
that .mas is
explicitly
typed.

Using the MARIE Simulator


ASSEMBLING A PROGRAM

• After saving
the source
code, the next
step is to
assemble it
(convert it to
machine or
executable
code).

• Select
[Assemble
current file]
from the
[Assemble]
menu.

Using the MARIE Simulator


ASSEMBLING A PROGRAM

• 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. • The assembly process will create an executable file for
the program. This can be run later in the simulator.

Using the MARIE Simulator


ASSEMBLING A PROGRAM

• If you decide
to edit the
file, make
sure you
assemble
the program
again (and
save it of
course).

Using the MARIE Simulator


USING THE MARIE SIMULATOR

• To run the
program, go back
to the MARIE
Simulator
window.

• The first step in


running the
program is to
load the
executable file in
the simulator.

• Select [Load]
from the [File]
menu.

Using the MARIE Simulator


USING THE MARIE SIMULATOR

• The file dialog


pops up,
showing you
all of the
MARIE
executable
files (.mex) in
the current
directory.

• You can
navigate
through your
directory
structure if
needed.

Using the MARIE Simulator


USING THE MARIE SIMULATOR

• Select
the file to
be
executed.

Using the MARIE Simulator


USING THE MARIE SIMULATOR

• The program
is now loaded
in the MARIE
simulator.

• Take note that


programs
cannot be
edited in the
simulator
itself.

Using the MARIE Simulator


PARTS OF THE MARIE SIMULATOR

Program Monitor
Area

Using the MARIE Simulator


PARTS OF THE MARIE SIMULATOR

Register Monitor
Area

Using the MARIE Simulator


PARTS OF THE MARIE SIMULATOR

Output Monitor
Area

Using the MARIE Simulator


PARTS OF THE MARIE SIMULATOR

Memory Monitor
Area

Using the MARIE Simulator


MEMORY MONITOR AREA

Each
horizontal
row of the
memory
monitor
area
contains 16
memory
addresses.

Using the MARIE Simulator


MEMORY MONITOR AREA

Example:

090 + 1 = 091
hexadecimal

• So the
contents of
memory
location 09116
is 000016.

Using the MARIE Simulator


MEMORY MONITOR AREA

Example:

100 + 1 = 091
101
hexadecimal

• So the
contents of
memory
location 10116
is 310516.

Using the MARIE Simulator


PROGRAM MONITOR AREA

• Because of the
Org 100
directive, the
program was
loaded starting
at memory
address 100.

• Take note that


the Org 100 will
not appear in the
program listing
because it is just
a directive. It is
not part of the
program.

Using the MARIE Simulator


PROGRAM MONITOR AREA

• So the Load X
instruction is
stored in
memory
location
10016.

The Add Y
instruction is
stored in
memory
location
10116.

And so on and
so forth.

Using the MARIE Simulator


PROGRAM MONITOR AREA

• Take note also


the contents of
variable (or
label) X is stored
at memory
location 10416.

The contents of
variable (or
label) Y is stored
at memory
location 10516.

The contents of
variable (or
label) Z is stored
at memory
location 10616.

Using the MARIE Simulator


PROGRAM MONITOR AREA

The actual contents of


memory location 100
is 1104 which is the
hexadecimal
equivalent of Load X.

1104
opcode for Load

memory address
of variable X

Using the MARIE Simulator


PROGRAM MONITOR AREA

The actual contents


of memory location
001 is 3105 which is
the hexadecimal
equivalent of Add Y.

3105
opcode for Add

memory address
of variable Y

Using the MARIE Simulator


PROGRAM MONITOR AREA

The actual contents


of memory location
104 should be the
value of X.

0023 is the
hexadecimal
equivalent of 3510.

Using the MARIE Simulator


PROGRAM MONITOR AREA

The actual contents


of memory location
105 should be the
value of Y.

FFE9 is the
hexadecimal
equivalent of –2310.

Using the MARIE Simulator


PROGRAM MONITOR AREA

• Take note that


the contents
of memory
locations
10016 to 10616
are the
hexadecimal
codes of the
program itself.

Using the MARIE Simulator


SYMBOL TABLE

• If you want to
see the
symbol table,
select
[Symbol Map]
from the main
menu.

The symbol
table will then
appear in a
separate
window.

Using the MARIE Simulator


RUNNING A PROGRAM

• Load X

Load the contents


of memory
location X to AC.

AC 0023

Using the MARIE Simulator


RUNNING A PROGRAM

• Add Y

Add the contents of


AC to the contents of
memory location Y
and store the results
to AC.

0023 + FFE9 = 000C

AC 000C

Using the MARIE Simulator


RUNNING A PROGRAM

• Store Z

Store the contents


of AC to memory
location Z.

106 000C

this will become 000C once the program is executed

Using the MARIE Simulator


RUNNING A PROGRAM

• To run the
program,
select [Run]
from the
[Run] menu.

Using the MARIE Simulator


RUNNING A PROGRAM

• After running
the program,
check if the
results are
correct.

• In this
program, the
contents of
memory
location 10616
is now 000C16.

Using the MARIE Simulator


EDITING A PROGRAM

• Programs
can be
edited using
the MARIE
Assembler
Code Editor.

• Select
[Open] from
the [File]
menu to
open your
program
again.

Using the MARIE Simulator


EDITING A PROGRAM

• Select the
program to be
edited.

• Remember,
MARIE source
codes use the
extension
.mas.

Using the MARIE Simulator


EDITING A PROGRAM

• Suppose
you want
to change
the values
of X and Y.

Using the MARIE Simulator


EDITING A PROGRAM

• After
making the
desired
changes,
save the file.

Using the MARIE Simulator


EDITING A PROGRAM

• Select [Save]
from the [File]
menu to save
your program.

• If you want to
save it in a
different file,
select [Save
As].

Using the MARIE Simulator


EDITING A PROGRAM

• After saving
the file, re-
assemble the
program to
update the
executable
file.

• Select
[Assemble
current file]
from the
[Assemble]
menu.

Using the MARIE Simulator


EDITING A PROGRAM

• Go back to
the Marie
simulator to
run the
revised
program.

• However, the
executable
file that is
loaded is still
the previous
one.

Using the MARIE Simulator


EDITING A PROGRAM

• To load the
new version
of the
executable
file, select
[Reload]
from the
[File] menu.

Using the MARIE Simulator


EDITING A PROGRAM

• Take note
of the
changes
that were
made.

Using the MARIE Simulator


EDITING A PROGRAM

• To run the
program,
select [Run]
from the
[Run] menu.

Using the MARIE Simulator


EDITING A PROGRAM

• After running
the program,
check if the
results are
correct.

• In the edited
program, the
contents of
memory
location 10616
is now 001916
or 2510.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• You can also use the


step mode feature
of the simulator to
run programs.

• Step mode allows


you to execute your
program one
statement at a time.

• This gives you the


opportunity to
check the contents
of registers and
memory locations
after the execution
of each instruction
(for debugging
purposes).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• Before you
can use step
mode, you
have to check
first if the
feature is
enabled.

• If the [Step]
button in the
menu bar is
greyed out,
then step
mode is
disabled.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• You can turn


on step mode
by selecting
[Set Stepping
mode] in the
[Run] menu.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• The step
mode is
now
enabled
(the [Step]
button is
no longer
grayed
out).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• You can use the


Register Monitor
Area to check the
contents of the
registers as each
instruction is
executed.

• Take note that PC


is currently equal
to 10016.

• This is because
10016 is the
address of the
next instruction
to be executed
(the 1st
instruction).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• By pressing
the [Step]
button, the
simulator will
now execute
the first
instruction
(the one
pointed to by
PC).

• This is the
instruction
Load X.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• After execution,
take note of the
changes in the
contents of the
registers.

• AC is now 002316
which is the
value stored at X.

• IR contains the
hexadecimal
equivalent of
Load X which is
110416.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• MAR contains
10416 which is
the address of
most recent
memory fetch
(the address of
X).

• MBR contains
002316 which is
the data that was
recently fetched
from memory
(the contents of
X).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• PC has been
updated to 10116
in preparation
for the execution
of the next
instruction.

• Pressing the
[Step] button at
this point will
cause the
execution of the
second
instruction (the
one now pointed
to by PC).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• After execution,
take note that
Add Y has been
highlighted.

• Looking at the
registers, take
note that AC is
now 000C16
which is the
result of the
addition process.

• IR contains the
hexadecimal
equivalent of
Add Y which is
310516.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• MAR contains
10516 which is
the address of
most recent
memory fetch
(the address of
Y).

• MBR contains
FFE916 which is
the data that was
recently fetched
from memory
(the contents of
Y).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• PC has been
updated to 10216
in preparation
for the execution
of the next
instruction.

• Pressing the
[Step] button at
this point will
cause the
execution of the
third instruction
(the one now
pointed to by
PC).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• After execution, take


note that Store Z has
been highlighted.

• Looking at the
registers, take note
that AC did not
change (it is still
000C16) as the Store
instruction simply
copies AC to the
designated memory
location

• IR contains the
hexadecimal
equivalent of Store Z
which is 210616.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• MAR contains
10616 which is
the address of
most recent
memory access
(the address of
Z).

• MBR contains
000C16 which is
the data that was
recently written
to memory (the
contents of AC).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• Take note that


the contents
of memory
location 10616
has changed
to 000C16 as a
result of the
execution of
the Store Z
instruction.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• PC has been
updated to 10316
in preparation
for the execution
of the next
instruction.

• Pressing the
[Step] button at
this point will
cause the
execution of the
third instruction
(the one now
pointed to by
PC).

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• After execution,
take note that
Halt has been
highlighted.

• IR contains the
hexadecimal
equivalent of
Halt which is
700016.

• None of the
other registers
changed because
of the Halt
instruction.

Using the MARIE Simulator


RUNNING A PROGRAM IN STEP MODE

• Although PC
has been
updated to
10416 to
point to the
next
instruction,
that is
already
irrelevant.

Using the MARIE Simulator

You might also like