-3

So I don't understand assembly but i have some simple c functions i need to convert to assembly. Does anyone know how to convert these c functions into assembly?

void printChar( char ch )
{
    printf("%c",ch);
}

int checkRange( long value, long minRange, long maxRange )
{
    if(value >= minRange && value <= maxRange)
        return true;
    else
        return false;
}

int isOdd( long value )
{
    if(value % 2 == 0)
    {
        return false;
    }
    else
    {
         return true;
    }
}
Alex Yang
  • 63
  • 2
  • 8
  • well it will help me understand assembly language better for the homework if i understand how to convert these basic c functions into assembly – Alex Yang Oct 16 '12 at 20:46
  • yes, but which cpu? There's SPARC, x86, etc. Which one are you dealing with? – Nabou Oct 16 '12 at 20:47
  • I found a duplicate of this question: http://stackoverflow.com/questions/2709327/easy-way-to-convert-c-code-to-assembly – Anderson Green Apr 23 '13 at 00:58

1 Answers1

11

Put your functions in a tst.c file and use this command:

gcc -c tst.c -S -o -
ouah
  • 142,963
  • 15
  • 272
  • 331
  • Can you just code it from scratch. usually when you convert it like that it leads to excessive coding. – Alex Yang Oct 16 '12 at 20:45
  • 1
    @AlexYang Usually when it comes to programming, you need to do excessive coding. –  Oct 16 '12 at 20:46
  • @AlexYang you need at least the basics, it's clear that you don't even know how to handle source code written in assembly, the assembly it's also strictly tied to the platform and the registries that you choose. Even if someone would like to write that for you, you are not saying for what architecture/platform you want it and what registry are you using. – Ken Oct 16 '12 at 20:48
  • @H2CO3 "Excessive coding" is something that I usually try to avoid. I usually prefer concise and efficient code over verbose and inefficient code. – Anderson Green Apr 23 '13 at 01:00