Using The MARIE Simulator
Using The MARIE Simulator
MARIE SIMULATOR
https://www.oracle.com/java/technologies/javase-jre8-downloads.html
It is not necessary
to unpack (unJAR)
the MARIE
machine simulator
in order to run it.
• This is the
graphical
environment
of the MARIE
machine
simulator.
This is where
assembly
language
programs are
executed or
simulated.
• However, this
is not where
the programs
are typed.
• Programs are
typed and
assembled
using the
MARIE
Assembler
Code Editor.
• Using the
MARIE
Assembler
Code Editor
pop up
window, type
your MARIE
assembly
instructions.
• After typing
the code,
save the
program
source code.
• Select [Save
As] from the
[File] menu.
• 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.
• 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.
• 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.
• If you decide
to edit the
file, make
sure you
assemble
the program
again (and
save it of
course).
• To run the
program, go back
to the MARIE
Simulator
window.
• Select [Load]
from the [File]
menu.
• You can
navigate
through your
directory
structure if
needed.
• Select
the file to
be
executed.
• The program
is now loaded
in the MARIE
simulator.
Program Monitor
Area
Register Monitor
Area
Output Monitor
Area
Memory Monitor
Area
Each
horizontal
row of the
memory
monitor
area
contains 16
memory
addresses.
Example:
090 + 1 = 091
hexadecimal
• So the
contents of
memory
location 09116
is 000016.
Example:
100 + 1 = 091
101
hexadecimal
• So the
contents of
memory
location 10116
is 310516.
• Because of the
Org 100
directive, the
program was
loaded starting
at memory
address 100.
• 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.
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.
1104
opcode for Load
memory address
of variable X
3105
opcode for Add
memory address
of variable Y
0023 is the
hexadecimal
equivalent of 3510.
FFE9 is the
hexadecimal
equivalent of –2310.
• 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.
• Load X
AC 0023
• Add Y
AC 000C
• Store Z
106 000C
• To run the
program,
select [Run]
from the
[Run] menu.
• After running
the program,
check if the
results are
correct.
• In this
program, the
contents of
memory
location 10616
is now 000C16.
• Programs
can be
edited using
the MARIE
Assembler
Code Editor.
• Select
[Open] from
the [File]
menu to
open your
program
again.
• Select the
program to be
edited.
• Remember,
MARIE source
codes use the
extension
.mas.
• Suppose
you want
to change
the values
of X and Y.
• After
making the
desired
changes,
save the file.
• Select [Save]
from the [File]
menu to save
your program.
• If you want to
save it in a
different file,
select [Save
As].
• After saving
the file, re-
assemble the
program to
update the
executable
file.
• Select
[Assemble
current file]
from the
[Assemble]
menu.
• Go back to
the Marie
simulator to
run the
revised
program.
• However, the
executable
file that is
loaded is still
the previous
one.
• To load the
new version
of the
executable
file, select
[Reload]
from the
[File] menu.
• Take note
of the
changes
that were
made.
• To run the
program,
select [Run]
from the
[Run] menu.
• 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.
• 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.
• The step
mode is
now
enabled
(the [Step]
button is
no longer
grayed
out).
• This is because
10016 is the
address of the
next instruction
to be executed
(the 1st
instruction).
• 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.
• 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.
• 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).
• 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).
• 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.
• 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).
• 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).
• 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.
• 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).
• 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).
• 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.
• Although PC
has been
updated to
10416 to
point to the
next
instruction,
that is
already
irrelevant.