Question: You will write a program that, when compiled, will be named backandforth. The main driver for the program will be written in C . It

You will write a program that, when compiled, will be named backandforth. The main driver for the program will be written in C. It will print a menu. When the user enters the number for a particular menu item, the program will take the appropriate actions. Those actions will include prompting the user for input, calling an assembly function, and then printing out the results.
The C main driver will print the following menu"
1) Add two numbers together
2) Test if a string is a palindrome (C -> ASM)
3) Print the factorial of a number
4) Test if a string is a palindrome (ASM -> C)
The actions that each menu item will take is described in the table below:
Menu Item
C Functions to write
Assembly functions to write
Description
1
int addstr(char *a, char *b)
The C driver will prompt and read two strings from the user.
Then the C driver will call the addstr() assembly function.
Finally, the C driver will print the results from the assembly function.
Note, the assemby function must call the atoi() C Library function to
Convert the strings to integers.
2
int is_palindrome(char *s)
The C driver will prompt and read a string from the user.
Then the C driver will call the is_palindrome function and
print its results. You may use the is_palindrome() function
that you wrote in the previous assignment.
3
int fact(int n)
int factstr(char *s)
The C driver will prompt and read a string from the user.
The the C driver will call the factstr() function. The factstr()
function which will convert the string argument to integer by calling the atoi() C library function. factstr() will then call the C function fact() to
obtain the factorial of the integer, and then pass the answer back to the C driver, which will then print it.
4
int is_palindrome(char *s)
void palindrome_check()
The C driver will immediately call the assembler function palindrome_check.
This assembler function will then prompt and read a string from the user.
Next, palindrome_check() will call the is_palindrome() function written in C
to determine if the string is a palindrome, and then print the results.
Do not use any macros, and only use the C library for this assignment.
The program is to be written and tested on the virtual machine given in class, must compile using the nasm assembler, and must link using the ld linker. To assemble the file that contains your assembly functions for your program, you will enter the following command:
nasm -g -f elf32-F dwarf -o functions.o functions.asm
The following command will compile the C part of your program example program and link it to the assembly code:
gcc -g -Wall -static -m32-o backandforth backandforth.c functions.o
(Note: if you have gcc produce assembler from the C code and submit the gcc generated assembler, then the professor will know and give you a grade of 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 Programming Questions!