To all:
I am playing with Armulator to try to understand the ARM instruction as I do not yet have any ARM hardware to play with. However I run into a poss ible Armulator bug. This is surprising as Armulator should be sophisticated enough to have such trivial and obvious bug.
Here is the code that Armulator try to emulate:
00008104 : 8104: e3b00016 movs r0, #22 8108: e28f1f47 add r1, pc, #284 ; 0x11cQuestion, after the second instruction, what value is stored into regis ter r1?
You would think that by the time the instruction is fetched from locati on 0x8108, the program counter PC would have been increased 4 to 0x810C. Th us the result would be 0x810C + 0x11C = 0x8228, which is stored into r1.
However Armulator gives a result 0x822C instead. It first increment PC right after the instruction is fetched, then, within function data_proc() i t increment the PC register once again:
void ARM::data_proc(A_INSTR instruction) { //bla bla bla... int Rn = (instruction>>16) & MASK_4BIT; //Bla bla bla...
if (Rn == 15) r[Rn] += 4;
Looks to me this is a bug, as R15 (PC) is un-necessarily incremented tw ice before used. Am I right in concluding that this is a bug in Armulator?
I obtained the source using GIT and I forgot where I got it, as I am no t familiar how to look up log in GIT. But the author seems to be Zi Yan
Any one has an answer to my question? Is this a bug in the Armulator?