CS计算机代考程序代写 algorithm assembly 1. Assume that an array has been initialized with integers, where the array location is in

1. Assume that an array has been initialized with integers, where the array location is in
register $1 and the array length is in register $2. Write an assembly program that
reverses the contents of the array.
For example, if the array started with values [7, 0, 15, -3, 6], when the program is done
the array will contain the values [6, -3, 15, 0, 7].
The contents of registers $1 and $2 must be the same at the end of your program as they
were at the beginning; however their values may change within the body of the program.

2. Credit card numbers include a check digit that can be used to detect errors when
someone enters the card number for online purchases. One common method for
generating a check digit is the Luhn formula. A description of the algorithm can be
found here:
https://en.wikipedia.org/wiki/Luhn_algorithm
Assume that an array has been initialized with non-negative integers, where the array
location is in register $1 and the array length is in register $2. The contents of the array
represent all the digits of a credit card except the check digit. In other words, each
element of the array will be a single digit in the range 0 to 9 inclusive.
Write an assembly program that computes the check digit based on Luhn’s algorithm
and places the check digit in register $3. The leftmost digit of the credit card will appear
at index position 0 in the array. The rightmost digit of the credit card will appear in the
last index position in the array.
Examples:
  The array with values [1, 2, 3, 4] has check digit of 4, since
1 + 2   2 + 3 + 4   2 = 16, and
16   9 = 144, and
the remainder when you divide 144   10 is 4.
  The array with values [5, 4, 3, 2, 1] has a check digit of 5, since
5   2 = 10 and the sum of the digits of 10 is 1 + 0 = 1, and
1 + 4 + 2   3 + 2 + 1   2 = 15, and
15   9 = 135, and
the remainder when you divide 135   10 is 5.
  The array with values [7, 9, 9, 2, 7, 3, 9, 8, 7, 1] has check digit of 3
(Wikipedia example).

3. Write an assembly program that reads a string input from the keyboard, and outputs a
substring. The program should read a single line of input { in other words, read all
characters typed until you enter a new line character. Assume the characters of the
string are indexed starting at position 0. The newline character is not considered part of
the input string. The output will be the characters of the input string from the index
position found in register $1 up to, but not including, the character at index position
found in register $2. Use the twoints frontend to initialize the index values of the
substring you are required to output. Your program should print a newline character
following the substring. The ASCII code value of a newline character is the hex number
0xA.
For example, if the user entered the values 4 and 10 in the twoints front end, and then
used the keyboard to enter the string computer science, the output would be: uter s
Additionally:
  If the value of $1 is less than or equal to the value of $2 and they are valid index
positions in the string that is entered, and the value in $3 should be 0.
Assuming that length of the string is L, valid index positions are 0   $1   $2   L.
If the index values are the same number and valid (including L), then your program
should print out a newline character only.
  If the value of $1 is greater than the value of $2 but they are both valid index
positions in the string that is entered, nothing should be printed and the value in
$3 should be set to 1.
  If either the value of $1 or the value of $2 is an invalid index position in the string
that is entered (i.e. too small or too large), nothing should be printed and the value
in $3 should be set to 2.
  If either the value of $1 or the value of $2 is an invalid index position in the string
that is entered (i.e. too small or too large), and the value of $1 is greater than the
value of $2 then nothing should be printed and the value in $3 should be set to 3.