-
Notifications
You must be signed in to change notification settings - Fork 44
A Simple Adder
In this tutorial we are going to write a some code which assembles a simple addition calculator
Concepts
Variables in
MARIE
are in string, for example both the variablesX
andvalue
work in MARIE. Variables are typically declared at the bottom of the code.
The instruction INPUT takes a user input and loads it into the
Accumulator
orAC
The main idea is to get the user to input two values and store it into two variables: X and Y. A simple way to do this is:
INPUT
Store X
INPUT
Store Y
This will store the user input into two variables: X and Y. For the purposes we recommend you set the input and output value types to DEC (Decimal) mode.'
The next part requires us to Load X into the AC, then Add Y, output it then Halt the program.
Load X
Add Y
Output
Halt
Now, declare these variables into 'temporary' values, note that declaration is usually at the end of the code.
X, DEC 0
Y, DEC 0
There we have it. The code should something like
INPUT
Store X
INPUT
Store Y
Load X
Add Y
Output
Halt
X, DEC 0
Y, DEC 0
Copyright © 2018 Jason Nguyen, Saurabh Joshi, Eric Jiang, Felix Salim, Guido Tack, Monash University
Documentation
MARIE Instructions Set with Opcode
Register Transfer Language (RTL)
More Reading
The Essentials of Computer Organization and Architecture-Chapter 4.2
Tutorials
MARIE.js Documentation