Andre Fathallah Yousiff
430185500
MARIE Assembly Language Programming
Lab report
References
http://www.cse.yorku.ca/~jeff/notes/compiler/Marie/DocumentationFromW
eb/2.2.pdf
http://mrajababu.com/?
q=system/files/08.Introduction2DataPathImplementation.pdf
http://mirkwood.cs.edinboro.edu/~bennett/wombat/manual/node7.html
http://samples.jbpub.com/9781449600068/00068_CH04_Null3e.pdf
Background Information
MARIE has a simple and powerful instruction set. Each instruction for
MARIE has 16 bits. The bits 12-15 are the most significant because they
make up the opcode that determines the instruction to be executed. The
other 12 bits (0-11) make an address. The table below showcases MARIEs
instruction set.
RTN (Register Transfer Notation) is a means of describing machine
structure and function. It can be used to describe what a machine does
without describing how the machine does it. Register names such as IR,
PC, MAR, MBR and AC are used to represent the registers.
Summary Chapter 1
The first exercise of the lab involved writing a MARIE assembly program to
implement unsigned integer multiplication. Below is the program which is
explained in the comments.
/Program Start
Start,
Load
Subt
Skipcond
Jump
Num2
Count
800
Inver2
Andre Fathallah Yousiff
Store
Jump
430185500
Iter
S1P
/Remove negative sign function
Inver2,
Load
Invert
Subt
Num2
Add
One
Store
Iter
Jump
S1P
/Loop Function
S1P,
Load
Iter
Subt
Count
Skipcond
400
Jump
LoopS1
Jump
RCheck
/and + if ++ or --)
/Multiplication Function
LoopS1,
Load
Result
/number of times
Add
Num1
Store
Result
Load
Count
Add
One
Store
Count
Jump
S1P
/Finds correct result (- if / +- or -+,
/Loads num1 and adds nunm1: num2
/Saves num1
/Adds 1
/Loops again
/Checks if result needs to be inverted function
RCheck,
Load
Num1
/Check if Num1 is possitive
Subt
Count
Skipcond
000
Jump
Check2
/Check if Num2 is positive if
/Num1 > 0
Load
Num2
/If Num1 < 0, Check Num2 is positive
Subt
Count
Skipcond
000
Halt
/Num1 < 0, Num2 > 0, no need to
invert /result as we get negative value we want because -num1 + -num1 =
negative /(true because -n * +n = -n^2)
Jump
InvRes
/Num1 and Num2 < 0, so need to
/invert result as -n * -n = +n^2
/Checks if result needs
Check2,
Load
Subt
Skipcond
Halt
invert /result
Jump
to /invert result as +n
/negative number
/Invert Result function
InvRes,
Load
Subt
Add
Store
Halt
/Variables
to be inverted function (cont)
Num2
/Loads num2 for negative check
Count
000
/Num1 and Num2 > 0, no need to
InvRes
/Num1 > 0, Num2 < 0, so need
+ +n = + however Num2 is negative, so we want a
Invert
Result
One
Result
Andre Fathallah Yousiff
430185500
Num1,
Num2,
Result,
Count,
Dec
Dec
Dec
Dec
65000
4
0
0
/Number 1 to multiply
/Number 2 to multiply
/Result to store
/Keeps track of ammount of iterate times
One,
Dec
/Holds number 1
Invert,
Dec
65535 /To invert number
Iter,
Dec
/Itererator
Temp,
Dec
/Holds a temporary value
Summary Chapter 2
Exercise two of the lab involved transforming the Program below to RTN.
MAR Num2
MBR M[MAR]
AC MBR
/Load Num2
MAR Count
MBR M[MAR]
AC AC MBR
/Subt Count
/Skipcond 400
If IR[11-10] = 01 then
If AC = 0 then PC PC + 1
PC LoopS1
/Jump LoopS1
/Halt
MAR Result
MBR M[MAR]
AC MBR
/Load Result
Andre Fathallah Yousiff
MAR Num1
MBR M[MAR]
AC AC + MBR
430185500
/Add Num1
/Store Result
MAR Result, MBR AC
M[MAR] MBR
MAR Count
MBR M[MAR]
AC MBR
/Load Count
MAR One
MBR M[MAR]
AC AC + MBR
/Add One
/Store Count
MAR Count, MBR AC
M[MAR] MBR
PC S1P
/Jump S1P