Search code examples
assemblypowerpcinstructions

What is actually happening in lwz?


I am looking at the following instruction and I can't seem to understand it. I've tried to read a couple of online PowerPC instruction references but they are not very understandable to me.

lwz       r4, dword_91C0DB28@l(r28)

Here how the dword shows in IDA

dword_91C0DB28: .long 0    

What exactly is going on when lwz is called and why is it useful?


Solution

  • No, the answer above is not correct.

    IDA instruction:

    lwz       r4, dword_91C0DB28@l(r28)
    

    Instruction above access to memory dword_91C0DB28 itself.
    This memory address is calculated by IDA's analyse heuristics.

    Original instruction:

    lwz        r4, -12345(r28)
    

    In this moment the real instruction would be like above.
    The address0x91C0DB28 you've seen at IDA would be made by $r28 - 12345 during runtime.
    (Offset -12345 is just an example).

    FYI: You can see original instruction by using dumb disassemblers such as objdump.