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"
Add two numbers together
Test if a string is a palindrome C ASM
Print the factorial of a number
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
int addstrchar 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.
int ispalindromechar s
The C driver will prompt and read a string from the user.
Then the C driver will call the ispalindrome function and
print its results. You may use the ispalindrome function
that you wrote in the previous assignment.
int factint n
int factstrchar 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
int ispalindromechar s
void palindromecheck
The C driver will immediately call the assembler function palindromecheck.
This assembler function will then prompt and read a string from the user.
Next, palindromecheck will call the ispalindrome 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 elfF 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 mo 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
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
