Search code examples
assemblydisassemblypowerpc

Multiple PowerPC instructions have same opcode


I'm trying to make sense of PowerPC instructions and ultimately disassemble them. I've found http://pic.dhe.ibm.com/infocenter/aix/v7r1/index.jsp?topic=/com.ibm.aix.aixassem/doc/alangref/ppc_instr.htm and already I'm confused - how do addic and si have the same opcode?


Solution

  • Apparently it's some kind of syntactic sugar on the assembler's part. They both perform addition, but si does it with a negative number:

    The si instruction subtracts the 16-bit signed integer specified by the
    SINT parameter from the contents of general-purpose register (GPR) RA and
    stores the result in the target GPR RT. This instruction has the same
    effect as the ai instruction used with a negative SINT value. The
    assembler negates SINT and places this value (SI) in the machine
    instruction:
    
        ai RT,RA,-SINT
    

    Source: si (Subtract Immediate) Instruction