Can anyone help me on following question PLEASE ANSWER IN MA
Can anyone help me on following question. PLEASE ANSWER IN MARIE SIMULATOR FORM.
(1) Write a MARIE subroutine that will multiply two numbers by using repeated addition. For example, to multiply 2 x 8, the program would add 8 to itself twice (if the larger of the two numbers is chosen to be added to itself, the subroutine will run more quickly). Then, write a MARIE program to evaluate the expression A x B + C x D using your function. Your program should get the values from A, B, C, and D from input.
(2)
Suppose we add the following instruction to MARIE\'s ISA:
JumpOffset X
This instruction will jump to the address calculated by adding the given address, X, to the contents of the accumulator. Show how this instruction would be executed using RTN.
Solution
1)
here is my code with explanation
hope it is usefull
org 100
 input
 store A
 input
 store B
 JnS prod
 Load sum
 store C
 input
 store A
 input
 store B
 jns prod
 load sum
 store D
 load C
 add D
 output
 halt
 
 sum, dec 0
 one, dec 1
 ctr, dec 0
 A, dec 0
 B, dec 0
 C, dec 0
 D, dec 0
 
 
 prod, hex 0
 load B
 store ctr
 clear
 store sum
 Loop, Load sum
 Add A
 Store sum
 Load ctr
 Subt one
 Store ctr
 Skipcond 400
 Jump Loop
for multiplication purpose subroutine prod is called by the first two values which are stored in temp variable
same procedure repeats for C an D with other temp
 finally we are adding the two temps
 
 
 2)


