Marie Accumulator Help

Thread Starter

Shawnj317

Joined Oct 14, 2023
1
I need help......Using the sample output numbers in this code, I don't get the 120 when the input 12 and 10 are multiplied. I get 0 for the output. Here are the instruction for the program with the sample output and my code.

Write a single Marie Subroutine
that will multiply two positive variables: MP1 and MP2 and place the
positive result in PROD1. Note: Use these variable names in program.
NOTE! One or both Input variables may be negative!

Write a Marie program to input the two variables, determine their sign,
force them to be positive and keep track of how many variables are
negative. If only one variable is negative, the result is negative!
Then place the variables in the subroutines ‘input’ variables. ‘Call’ the
subroutine, get the result, and Output the result. MP2 may be 0!
Halt the program only when MP1 is zero, and do not ask for MP2!
Upload your program named: PROG5.max to the Assignment dropbox.
Sample Output: (‘Decimal’ Marie setting for Input and Output!)
12
10
120

121
-56
-6776

Start, Input
Store MP1
Output
Skipcond 800
Halt
Input
Store MP2
Output
Load MP1
Skipcond 400
Jump CheckMP2
Load Zero
Sub MP1
Store MP1
Load ONE
Add Counter
Store Counter
CheckMP2, Load MP2
Skipcond 400
JumpI Call
Load Zero
Sub MP2
Store MP2
Load ONE
Add Counter
Store Counter
Call, Load After
Store Return
JumpI Multiply
After, Load Counter
Skipcond 000
Jump Result
Load Zero
Sub PROD1
Store PROD1
Result, Load PROD1
Output
Jump Start
Multiply, Load Zero
Store PROD1
Load MP1
Skipcond 800
JumpI Return
Loop, Load MP2
Skipcond 800
JumpI Return
Load PROD1
Add MP1
Store PROD1
Load MP2
Sub ONE
Store MP2
Jump Loop
MP1, DEC 0
MP2, DEC 0
PROD1, DEC 0
Counter, DEC 0
ONE, DEC 1
Zero, DEC 0
Return, DEC 0
End Start
 

WBahn

Joined Mar 31, 2012
32,712
Few people, if anyone, is going to walk through a long code listing looking for your error, especially when there is not hint given as to the logic you are attempting to implement.

I would recommend comment the heck out of your code -- show how it relates to the high-level logic you are using.

Then you might show a walk through of the program showing how you think each of the memory locations changes as the program executes.

In doing this, you will very likely find your problem on your own.
 
Top