Question: How do I change the code below to fit the instructions given here? Write an ARM program that asks the user to enter an upper

How do I change the code below to fit the instructions given here?

Write an ARM program that asks the user to enter an upper and lower limit numbers (as positive integers). The program will:

1. Verify that both numbers are positive.

2. Verify that the upper limit is greater than the lower limit.

3. Verify that the difference between the upper and lower limit is no greater than 50.

4. As required print out an error message which is specific to the nature of the input error checks in 1-3. After printing the error message terminate the program.

5. Print from the lower limit to the upper limit incrementing by 1.

6. Print the sum of the numbers from the lower limit to upper limit (inclusive). After printing the final sum terminate the program.

As with all programs your outputs should be clearly labeled and your code generous documented.

@-----------------------------------------------------------

@ Start instruction section

.text

.global main

main:

@ Use printf to print input prompt

LDR r0, =input_promptL @ string to print needs to be in r0

BL printf @ call printf

@ use scanf to read an integer from the user

@ r0 must contain address of the input format string

@ r1 must contain address of the variable where input will be stored

LDR r0, =input_format

LDR r1, =intval

BL scanf @ call scanf

@ Move the value to print into r1

LDR r2, =intval

LDR r1, [r2]

@ Add one to the int to show it is a numeric value

ADD r1, r1, #1

r0 = output_formatL

@ Load the output format string

@ Value to print is already in r1

@ Print the values between the upper limits in increments of 1

LDR r0, =output_format

BL printf @ call printf

ADR r0, r1

LDR r0, [r2] @r0 := N

MOV r1, #1

CMP r1, r0

@BGE after something

ADD r1, r1, #1

@B r1, r0

@ exit the program

MOV r7, #1

SVC 0

@--------------------------------------------------

@ Start data section

.data

input_promptL: .asciz "Enter a Lower Limit: "

input_promptU: .asciz "Enter an Upper Limit: "

output_formatL: .asciz "Lower Limit: %d: "

output_formatU: .asciz "Upper Limit: %d: "

input_format: .asciz "%d"

.align 4

@ Set aside space for an integer

intval: .word 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!