Helpful Information
 
 
Category: Other Programming Languages
MARIE Help: Multiplication SubRoutine

G'day all, newbie programmer here whose touching on a variety of differnet languages at the moment. I've come across the MARIE Machine Simulator and encountered some problems.

First off, some info on Marie:

"*MarieSim is an environment within which you can write your own programs and watch how they would run on a real "von Neumann architecture" computer system...MarieSim was written in the Java language so that the system would be portable to any platform for which a Java Virtual Machine (JVM) is available."

*Taken from: A Guide to the MARIE Machine Simulator Environment Accompanying The Essentials of Computer Organization and Architecture by Linda Null and Julia Lobur.

Basically i can't fix some Logical Bugs in this Multiplication Sub Routine (And MARIE isn't working for me so i'm down to trying to fix it without the program itself) and am asking for some feedback and guidence on what can be done without changing the code structure. I've personally fixed most of the problems involved but still cannot get the thing to work 100% correctly. Code as follows:



/Multiplication SubRoutine Program

/Global Variables

ORG 0200 /GLOBAL data areas
X, DEC 0000 /Multiplicand
Y, DEC 0000 /Multiplier (Used as counter, terminate if 0)
M, DEC 0000 /Product (Used as Sum and receives outputs)
One, DEC 1 /Constant “1”

/Multiply Subroutine

MPY, HEX 0000 /Entry Point and Return Address (guessing problem is here)
Load X /Initialise Multiplicand
Store M

MPY1, Load Y /Decrement Multiplier
Subt One
Skipcond 01 /Skip if zer0
JumpI MPY /Multiply Complete: RETURN
Load M /Add value X to sum in M
Add X
Store M
Jump MPY1 /loop for next Iteration
END


Example Input for x and y as 5 and 3 (Set above to 0 and 0 for ease sake) so that the program does the following calculation:

(x)5 * (y)3 = (m)15 or rather 5 + 5 (loop 1) + 5 (loop 2)

Using the good old pen and paper and follwing the algorithm, this is what the above code should do:

....................X..........Y..........M..........ONE
Initialised:......5...........3..........5............1
LOOP1:..........5...........2..........10..........1
LOOP2:..........5...........1..........15..........1
LOOP3:..........5...........0..........Loop Terminates.

Once the Loop Terminates, it jumps to MPY which doesn't make sense at the moment. If i move the MPY line to just above the End line, this should make the program work right?

For those who are familiar with MARIE, the error i'm recieving is that once i've downloaded it and placed it in a folder named MARIE i am meant to type in command prompt:

"jar xvf MarieSim.jar" to uncompress the program
and
"jar xvf MarieSource.jar" to uncompress the Source

However, it comes up with an error that it does not recognise the jar command even though i have installed Java SDK 1.4.0 which is what it requires.

Many thanks to those who read this and even more so to those that help out and i hope this post is coherent and through enough to convey the problem.

Cheers

Balor










privacy (GDPR)