The jump address calculation

62 Views Asked by At

Suppose that I want to jump from 0x20000000 to 0x1FFFFFFC. For this, I should write the jump instruction on this address.

I got jump instruction machine code: 0000 1011 1111 1111 1111 1111 1111 1111 with leftmost 6bit opcode and 26bit relative address. So, to check if I really jumped to the desired address, I do everything backward: take off the first 6 bits of opcode and get 11 1111 1111 1111 1111 1111 1111, shift left << 2, 1111 1111 1111 1111 1111 1111 1100, and now I concatenate upper 4 bits of current PC which is 0010 and I finally get 0010 1111 1111 1111 1111 1111 1111 1100 which is 0x2FFFFFFC, not 0x1FFFFFFC. Is this scenario possible in practice? If yes, then how to calculate the jump address correctly?

0

There are 0 best solutions below