Question: need a study question help x86 assembly language write a...
Need a study question help. x86 assembly language
Write a program that calculates the sum of N integers in a sequence.
An integer sequence has N integers, with a starting value a, and a constant difference d between 2 integers.
For example: the sequence 3, 9, 15, 21 has N = 4, a = 3, d = 6
and the sequence 1, 2, 3, 4, 5, 6, 7 has N = 7, a = 1, d = 1
The sum S of all N integers is calculated as: S = N(2a + (N-1)d) / 2
1. Prompt the user for the N, a, and d values, in that order.
- You can expect that the user will give you N, a, and d values that are between 1 and 100, so there's no error checking needed.
- Given that 100 is the max value of all input, use the appropriate data type and the register size that can store the maximum output value, but do not use the largest possible data size.
- Use 32bit registers except esp
2. Calculate the sum, using the given formula.
- Be efficient with your code for the calculation (Refer to the class notes for suggestions).
3. Print the values of N,
a, d, and sum on one line of output. See sample
4. Do not declare and use any memory variable, except for text strings.
- The text strings for the prompts and the output text can be defined in the .data section, but all user input and calculation results should be in registers.
Sample program output:
Enter the number of integers: 90
Enter the start integer: 3
Enter the difference between integers: 1
N = 90, a = 3, d = 1, sum = 4275