Question: Hi so I've been working on this program and I need help debugging and fixing it . Its 2 files, one is C and the

Hi so I've been working on this program and I need help debugging and fixing it. Its 2 files, one is C and the other is NASM x86 Assembly.
The C File:
#include
#include
extern int addstr_asm(int a, int b);
extern int is_palindrome_asm(char *s);
extern int fact_asm(int n);
extern void option_4();
int addstr(char *a, char *b){
int num1= atoi(a); // Convert strings to integers
int num2= atoi(b);
return addstr_asm(num1, num2);
}
int is_palindrome(char *s){
return is_palindrome_asm(s);
}
int fact(char *s){
int num1= atoi(s);
return fact_asm(num1);
}
int is_palindrome_c(char *buf, int len){
int i, j;
for (i =0, j = len -1; i len /2; i++, j--){
if (buf[i]!= buf[j]){
return 0; // Not a palindrome
}
}
return 1; // Palindrome
}
int main(){
int choice;
char string1[100];
char string2[100];
do{
printf("
Menu:
");
printf("1. Add two numbers together.
");
printf("2. Test if a String is a palindrome (C -> ASM).
");
printf("3. Print the factorial of a number.
");
printf("4. Test if a string is a palindrome (ASM -> C).
");
printf("5. Exit Program.
");
printf("Enter a choice: ");
scanf("%d", &choice);
if(choice 1|| choice >5){
printf("Invalid selection! Please try again.");
}
else if(choice ==1){
printf("Please enter a Number: ");
scanf("%s", string1);
printf("Please enter another Number: ");
scanf("%s", string2);
int result = addstr(string1, string2);
printf("The result of adding the two strings is: %d
", result);
}
else if (choice ==2){
printf("Please enter a String: ");
scanf("%99s", string1); // Prevent buffer overflow
// Debug: Print the input string
//printf("Debug: Input string is '%s'
", string1);
// Call the assembly palindrome function
int result = is_palindrome(string1);
if (result ==1){
printf("The string '%s' is a palindrome.
", string1);
} else if (result ==0){
printf("The string '%s' is not a palindrome.
", string1);
}
}
else if(choice ==3){
printf("Please enter a Number: ");
scanf("%s", string1);
int fact_result = fact(string1);
printf("The factorial of '%s' is: %d
", string1, fact_result);
}
else if(choice ==4){
option_4();
}
}while(choice !=5);
}
Unfortunately The assembly code wont fit on here due to the character limit so it will have to be in an image.
exit_option 4 only has ret for a command.

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!