Reputation: 22255
I'm trying to read the documentation for the ADRP arm64 instruction and I'm not sure about one aspect. The best way is to show it in code:
ULONG64 uiAddr = 0xfffff80198964c08; //Address of the following opcode
ULONG32 opcode = 0x900016d0; //Opcode for the ADRP instruction to resolve
//Check if opcode is correct
if((opcode & 0x9F000000) != 0x90000000)
{
//Bad opcode
wprintf(L"Bad opcode for ADRP instruction: 0x%X\n", opcode);
return -1;
}
ULONG64 imm;
imm = (opcode & 0x60000000) >> 29;
imm |= (opcode & 0x00FFFFE0) >> 3;
//Do I need to do this?
//uiAddr += sizeof(opcode); //Advance PC by the size of the opcode
uiAddr += imm << 12;
uiAddr &= ~((0x1LL << 12) - 1);
ULONG uiReg = opcode & 0x1F;
wprintf(L"ADRP address resolution: x%u=0x%I64X\n", uiReg, uiAddr);
Is that how it works - do I need to advance PC by the size of the opcode?
Upvotes: 2
Views: 51