Question

Write a MARIE program that sums the numbers from 1 to N (N(N + 1) /...

Write a MARIE program that sums the numbers from 1 to N (N(N + 1) / 2) using a loop and user input.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

    INPUT           /Read a number n. where n stores inot AC
   JNS FindSum          /Call FindSum by passing n
   OUTPUT               /Print the return value(sum)
   HALT           /Exit the program
FindSum, HEX 000             /Store the return address
   STORE n              /Save the passed value into n
LOOP,   SKIPCOND 800             /if n is 0, go to Return
   JUMP Return      
   /Do sum=sum+n
   LOAD sum             /AC=sum
   ADD n                /AC=sum+n
   STORE sum            /sum=AC
   /DO n=n-1
   LOAD n               /AC=n
   SUBT ONE             /AC=n-1
   STORE n              /n=AC
   JUMP LOOP            /Go to LOOP
Return, LOAD sum             /Send sum as return value
   JUMPI FindSum       /Return from FindSum
/Declare necessary variables
n,    DEC 0
sum, DEC 0
ONE, DEC 1

Below is the process to run it

Open MARIE Simulator

Open File editor

Write the program

Save the program as sumoneton.mas

Assemble the program

Now load the program(sumoneton.max)

Note: Set INPUT ,AC and OUTPUT display format as Dec (Decimal number)

Run the program

Input: enter n=5

Ouptut: sum=1+2+3+4+5= 15

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Write a MARIE program that sums the numbers from 1 to N (N(N + 1) /...
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
  • Write a Marie or MASM program which sums the numbers from 1 to N, where you...

    Write a Marie or MASM program which sums the numbers from 1 to N, where you choose N. For extra credit nmake it a subroutine and call it several times.

  • 2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum...

    2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum of both of the integers and all the numbers in between Write a Marie program that determines the largest of a series of positive integers provided by a user. The user will enter a -1 when she is finished. Up to 10 numbers will be provided by the user. Write a Marie program that accepts two positive integers, multiples them by repeated addition, and...

  • Write a MARIE program to calculate some basic statistics on a list of positive numbers. The...

    Write a MARIE program to calculate some basic statistics on a list of positive numbers. The program will ask users to input the numbers one by one. Assume that all numbers will be in the range 1 to 1000. To terminate the data entry, user will input any negative number. Once the data entry is complete, the program will show four statistics about the list of numbers: (1) Count (2) Minimum value (3) Sum of numbers (4) "Mean/Average" calculation. As...

  • 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...

  • In java, write a program that gets 10 integer numbers from the user using user input,...

    In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read.   Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1:  use a while loop. version2:  use a do-while loop. version 3:  use a for loop. For each version, use a loop to input 10 int numbers from the user...

  • In java, write a program that gets 10 integer numbers from the user using user input,...

    In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read.   Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. The program must be in one file. version1:  use a while loop. version2:  use a do-while loop. version 3:  use a for loop. For each version, use a loop to...

  • Write a MARIE program to implement one round of rock paper scissors game. Your program should...

    Write a MARIE program to implement one round of rock paper scissors game. Your program should represent the three moves ‘rock’, ‘paper’ and ‘scissors’ with numbers 1, 2 and 3 respectively. When the program is run, there should be two input prompts, one after the other, to ask for player 1’s and player 2’s moves (a number 1, 2 or 3). Then the program would compare both numbers and apply the following rules to work out the winner. Paper beats...

  • Write a MARIE assembly program to read two different positive numbers from the keyboard and output...

    Write a MARIE assembly program to read two different positive numbers from the keyboard and output the smaller number to the screen.

  • Write a Java program to prompt for inputting an integer N, then enter N integers (a...

    Write a Java program to prompt for inputting an integer N, then enter N integers (a loop is needed), print the numbers user entered, and the amount of even and odd numbers (zero is even number). (1) Prompt for the user to input an integer and output the integer. (1 pts) Enter an integer: You entered: 5 (2) Prompt for the user to input N integers, output the numbers entered and the amount of even and odd numbers (9 pts)...

  • Program 6: Sums and Averages. Assigned Wednesday, 10/05/16 Program Due Wednesday, 10/12/16 , at start of...

    Program 6: Sums and Averages. Assigned Wednesday, 10/05/16 Program Due Wednesday, 10/12/16 , at start of class. Write a program in c++ that asks the user to input a list of numbers, one at a time, until the user is finished. The program should keep track of how many numbers, how many positive numbers, and how many negative numbers were entered. It should also calculate the sums for each of these (positives, negatives, and total). After exiting the loop, the...

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