Question: In x 8 6 - 6 4 at&t assembly : Write a program that will collect some integers into an array and then rotate those

In x86-64 at&t assembly : Write a program that will collect some integers into an array and then rotate those elements
in the array according to the direction of the user. Heres a sample session:
Size of array: 5
Enter 5 integers
Element 0: 11
Element 1: 22
Element 2: 33
Element 3: 44
Element 4: 55
11,22,33,44,55
Rotate (L/R/E)? L
22,33,44,55,11
Rotate (L/R/E)? l
33,44,55,11,22
Rotate (L/R/E)? z
Try again. Rotate (L/R/E)? R
22,33,44,55,11
Rotate (L/R/E)? r
11,22,33,44,55
Rotate (L/R/E)? E
Goodbye.
You will implement four procedures:
void getArray(int n, int *a) will read n elements from the console and put them into the
specified array.
void printArray(int n, int *a) will print the n elements of the array on a single line sepa-
rated by commas.
void rotateLeft(int n, int *a) will rotate the array to the left one slot. An element in slot
i will be copied to slot i 1. The element in slot 0 will find itself in slot n 1.
void rotateRight(int n, int *a) will rotate the array to the right one slot. An element in
slot i will be copied to slot i +1. The element in slot n 1 will find itself in slot 0.
After filling the array, print the contents out and prompt for a rotation (L or R) or exit (E). Allow for
case insensitivity. L and l should both trigger a left rotation. Repeat this process until the user selects
exit.
Dont try writing this program all at once. First, implement printArray with a fixed array. Next,
implement leftRotate and test it on that array, printing the array before and after the rotate. Do
the same with rightRotate. At this point, implement getArray. Once your functions are ready, go
ahead and get the prompt loop working. Adding case insensitivity of the prompt response will be the
final step.
Save your program as rotate.s.
2.(40 points) Implement a cryptographic encoder/decoder that will input a line of text and output an
encoding of the text. The method will be similar to Caesars cipher and ROT13 system. The user will
provide a verb (encode or decode) and an integer key as a command line argument. This key will be
a decimal number. For each of the characters in the line of text to be encoded:
1
if it is between the space and the tilde (), use the formula c
=(((c 32)+ key) mod 95)+32
to compute the encoded character
if it is less than the space, use the character as is.
if it is after the tilde, use the character as is.
To decode, follow this method:
if it is between space and the tilde (), use the formula c
=((((c 32) key) mod 95)+95)
mod 95+32 to compute the encoded character
if it is less than space, use the character as is.
if it is after the tilde, use the character as is.
Here are some sample runs you should be able to produce.
$ echo "abcDEF" |./crypto encode 13
nopQRS
$ echo "abcDEF" |./crypto encode 91
]^_@AB
$ echo "Hello, world!" |./crypto encode 3771
+HOORnbZRUOGc
$ echo cde|./crypto decode 2
abc
$ echo Hello, world!|./crypto encode 2173|./crypto decode 2173
Hello, world!
In order to access the command line arguments, remember that stdlib is calling main with this signature:
int main(int argc, char * argv[])
To read the string, use fgets and not scanf("%s",..) since the latter will stop at the first white
space.
Save your program as crytpo.s.

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 Programming Questions!