I got an assignment from my college to create this
Now I know there might be some way, that I can copy the disassembly of my C code I created from a debugger, I guess...
If there is a way please let me know... Or atleast...
Help me with the disassembly of this code I created...
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//Logic loop
int to_base3(int decimal_number)
{
//To return the function at the end of recursion
if (decimal_number == 0)
return 0;
//The Recursion
else
return (decimal_number % 3 + 10 * to_base3(decimal_number / 3));
}
//Main function
int main()
{
int decimal_number;
char check[20];
//Inputting the values and checking for characters
do{
int flag=1;
printf("Enter the number: ");
fgets(check, 19, stdin);
//Loop to check for number or character
for(int i=0; i<sizeof(check);i++){
if(isdigit(check[i])){
flag =0;
break;
}
else{
continue;
}
}
//The place where to_base3() gets called
if(flag==0)
{
decimal_number = atoi(check);
printf("Base 3 number: %d\n", to_base3(decimal_number));
}
//If flag == 1 i.e. if it's a char, then exit the loop
else
break;
}while(1);
//The final statement
printf("Thank you for using my program. Bye!");
return 0;
}
Also, if you think that you can come up a shorter assembly code for this problem... Let me know...