Iam new in Marie simulator. I know how to add in the simulator, but unfortunately I don't know how to multiply. for example how can I put a code for this: S=x*Y+z Thanks in advance
Asked
Active
Viewed 1,271 times
1 Answers
0
You can implement Multiplication using repeated addition.
Here is a basic algorithm.
For positive integers use the algorithm:
Result = Result - Multiplier
Multiplicand = Multiplicand - 1
For negative integers use the algorithm:
Result = Result + Multiplier
Multiplicand = Multiplicand + 1
In pseudocode:
while Multiplicand != 0
if Multiplicand > 0
Result = Result - Multiplier
Multiplicand = Multiplicand - 1
else
Result = Result + Multiplier
Multiplicand = Multiplicand + 1
This requires two variables to hold the Multiplier and Multiplicand.
Additionally you can convert this into a general purpose routine with the JNS
(Jump-and-Store instruction) and JUMPI
(Jump Indirect).
JNS Multiply
/ Somewhere else
/ Define Multiply as a variable
/ JNS will store the current HEX address
/ in Multiply and start executing the next
/ line
Multiply, DEC 0
/ *** Multiply Body *** /
/ Lastly use JUMPI to Jump Indirectly
/ back to where Multiply was
/ executed from
JUMPI Multiply

Dustin Kingen
- 20,677
- 7
- 52
- 92