How to translate C++ pseudocode to MIPS assembly language instruction

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elijah godfrey
    New Member
    • Oct 2010
    • 1

    How to translate C++ pseudocode to MIPS assembly language instruction

    (Can you translate this C++ pseuodoce to MIPS language
    instruction?)

    CountBits


    # int count bits(int a0)
    {
    vo=0;
    while (a0){
    v0+= a0&1 > add $v0
    a0 >> =1, > srav $a0,$a0,$at
    }
    return 0;

    }
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    The easiest way is to compile that program on a MIPS cross-compiler and capture the assembly output. On some compilers (for example, gcc) this is accomplished with the -S command line argument [I think].

    Comment

    Working...