Question

Please help me write this in Marie Simulator code: Problem: Sum= 1+2+3+.....+N Input: N Output: S...

Please help me write this in Marie Simulator code:

Problem: Sum= 1+2+3+.....+N

Input: N

Output: Summation of 1 to N

Sum=0;

A=1;

While (A<=N){

Sum=sum+A;

A=A+1;

}

Print Sum;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is your marie code :)

         INPUT        // taking input from user
         STORE   count    // storing input to count

Loop,   Load   total    // loading total to AC
         Add    count    // adding count to AC
             STORE        total    // storing AC to total
         Load    count    // loading count to AC
         SUBT    one      // subtracting one to AC
         STORE   count    // storing AC to count
             SKIPCOND     000      // if AC < 0 skip next instruction
         JUMP    Loop     // jumping to Loop

End,   LOAD    total    // loding total to AC
        OUTPUT       // Printing output
            HALT                   // end
count,      DEC       0        // declaring count
total,      DEC       0        // declaring total
one,   DEC       1        // declaring one

M MARIE Assembler Code Editor File Edit Assemble Help INPUT STORE // taking input from user I/ storing input to count count L

Sample Output:

Here input was 5 and output is 15, and don't forget to select DEC as input and output in simulator.

M MARIE Simulator File Run Stop Step Breakpoints Symbol Map Help label opcode operand hex OUTPUT AC 000F (Hex) R 7000 (Hex) M

Add a comment
Know the answer?
Add Answer to:
Please help me write this in Marie Simulator code: Problem: Sum= 1+2+3+.....+N Input: N Output: S...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help me write this in Marie Simulator code: Problem: Sum=x*y+z

    Please help me! I need to find the sum of the product of two numbers and the third number. Like this: x*y+z.

  • For some reason nobody out there answers this question, Please please help me with this, Let...

    For some reason nobody out there answers this question, Please please help me with this, Let me know if any further info will be needed. Create a MARIE assembly program which inputs two integers, X and Y, computes 3X + 4Y, and outputs the result. Requirements 1. The program must be written in MARIE Assembly Language. 2. It must use a subroutine to perform the multiplications. 3. You do not need to prompt for the input, just use the Input...

  • Can someone do this in assembly code for me please Given the following input and output, write ...

    can someone do this in assembly code for me please Given the following input and output, write the assembly code necessary to make it look exactly the same as below. Pay careful attention to spacing and blank lines: Input Enter a number: 1 Enter a larger number: 3 Enter an even larger number: 5 Output 1 < 3 < 5 5 > 3 > 1 aseembly programing language

  • Please help me! For Problem 1, 2 and 3: You are required to submit three .c...

    Please help me! For Problem 1, 2 and 3: You are required to submit three .c files that contain the instructions that you have written to solve the following problems. Place the C source code to solve the first problem in a file called lab5a.c. Place the C source code to solve the second problem in a file called lab5b.c. And place the C source code to solve the third problem in a file called lab5c.c. Remember to include your...

  • 2. What is the output of the following code fragment? n = 1; while (n <=...

    2. What is the output of the following code fragment? n = 1; while (n <= 5) { n++; cout << n << ' '; a.1 2 3 4 5 b. 1 2 3 4 c. 1 1 1 forever d. 2 3 4 5 e. 2 3 4 5 6 3. What is the termination condition for the following While loop? while (beta > 0 && beta < 10) { cout << beta << endl; cin >> beta; }...

  • 1. Write a MARIE program that can implement a sum of two products, i.e. using MARIE...

    1. Write a MARIE program that can implement a sum of two products, i.e. using MARIE program to calculate 13*35 + 27*18 (* means multiply) and store the result to a variable Sum. Hint: e.g. following code can be used to initialize the variables A, B, C and D, in which A is 13, B is 35, C is 27 and D is 18 A,       DEC   13    /one of the four input numbers: 13 B,       DEC   35...

  • 1. Please write the following code in Python 3. Also please show all output(s) and share...

    1. Please write the following code in Python 3. Also please show all output(s) and share your code. Below is a for loop that works. Underneath the for loop, rewrite the problem so that it does the same thing, but using a while loop instead of a for loop. Assign the accumulated total in the while loop code to the variable sum2. Once complete, sum2 should equal sum1. sum1 = 0 lst = [65, 78, 21, 33] for x in...

  • Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The...

    Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The parity checker should repeatedly execute a loop that performs the following tasks: 1. Ask the user for an input X, which can be any printable ASCII character; 2. Output the decimal code of X; 3. Output the total number of 1’s that appears in the binary code of X; 4. Output the parity bit which, when added to the binary code of X, will...

  • NEED HELP THE PROBLEM-SOLVING PROCESS WITH THE UML DIAGRAM + ACTIVITY DIAGRAMS TO RUN THE CODE...

    NEED HELP THE PROBLEM-SOLVING PROCESS WITH THE UML DIAGRAM + ACTIVITY DIAGRAMS TO RUN THE CODE PROGRAM PLEASE!! Problem1. (20 points) Recursive Coding Problem. Using the Problem Solving Process. Write a Java application that implements these two functions using recursive methods (recursion must be used). First Recursive Function. When one passes an integer as input (n for example), the return should return (output) the sum as follows: 1 + 1/2 + 1/3 + 1/4 + ... 1/(n-1) + 1/n Example:...

  • help with problem number 2 would be greatly appreciated Problem 1: Input data has lines organized...

    help with problem number 2 would be greatly appreciated Problem 1: Input data has lines organized as follows: column 1: character code (one of A, B, c, D) columns 2-3: integer (named m) columns 4-8: real value (named r) Write a FORTRAN 90 program which reads this data from the keyboard (use the Unix redirect "with the data file) A sum is found for each code: For code A sum m +r-m For code B sum (m2 + r2)0.5 For...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT