Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CIS 21JA Assignment 4 There are 2 parts to this lab assignment: - Part 1: Start with the file lab4.asm. In the place labeled Part

CIS 21JA Assignment 4

There are 2 parts to this lab assignment:

- Part 1: Start with the file lab4.asm. In the place labeled Part 1, write the program as described below.

- Part 2: At the end of lab4.asm is a comment block labeled Part 2. There is no coding needed for part 2, simply type in your answers next to the questions about status flags.

Overview of part 1 Write a program that calculates the sum of N integers in a sequence.

Background 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

Requirements

1. Prompt the user for the N, a, and d values, in that order.

  • The prompt should explain clearly what you expect from the user. See sample output below.

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

  • 2pts of the lab is for using the correct data type / size.

2. Calculate the sum, using the given formula.

- Be efficient with your code for the calculation (Refer to the class notes for suggestions).

- 1pt of the lab is for coding efficiency.

3. Print the values of N, a, d, and sum on one line of output. See sample output. The output line should be a separate line, so don't forget the newline character at the end of the line. 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.

- 2 pts of the lab is for not using memory variables to store numeric data.

5. Documentation

  • To get credit for the lab, don't forget your name at the top.

  • Use comments to explain logical blocks of code, and It is also visually helpful to add a blank line between logical blocks.

Test Run multiple test cases: at least one with a small N and large a and d values, and another one with a large N and small a and d values.

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions