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 x 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:
Enter integers
Element :
Element :
Element :
Element :
Element :
Rotate LRE L
Rotate LRE l
Rotate LRE z
Try again. Rotate LRE R
Rotate LRE r
Rotate LRE E
Goodbye.
You will implement four procedures:
void getArrayint n int a will read n elements from the console and put them into the
specified array.
void printArrayint n int a will print the n elements of the array on a single line sepa
rated by commas.
void rotateLeftint n int a will rotate the array to the left one slot. An element in slot
i will be copied to slot i The element in slot will find itself in slot n
void rotateRightint n int a will rotate the array to the right one slot. An element in
slot i will be copied to slot i The element in slot n will find itself in slot
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
points Implement a cryptographic encoderdecoder that will input a line of text and output an
encoding of the text. The method will be similar to Caesars cipher and ROT 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:
if it is between the space and the tilde use the formula c
c key mod
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 key mod
mod 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
nopQRS
$ echo "abcDEF" crypto encode
@AB
$ echo "Hello, world!" crypto encode
HOORnbZRUOGc
$ echo cdecrypto decode
abc
$ echo Hello world!crypto encode crypto decode
Hello, world!
In order to access the command line arguments, remember that stdlib is calling main with this signature:
int mainint argc, char argv
To read the string, use fgets and not scanfs 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
