I am a TA for Dr. Sohoni in CST 250 at ASU. I have been working with Damon Cost on making PLPTool more accessible for a blind student in our class. Today a student found a issue where using a negative offset in a load word instruction caused an error stating that the address not in any module's address space.
I was able to duplicate the error on my own computer and after doing the address offset sign extension and addition I noticed that the address PLPTool was attempting to access had 9 hex digits meaning the address was greater than 32 bits. If the number had been truncated to 32 bits the address would be correct, but the resulting address appeared to be stored in a 64 bit variable so the sign extension did not match the size of the variable.
I found the where the memory address was being calculated in SimCore.java (around line 606) and masked the resulting address with 0xFFFFFFFFL. I copied and commented out the original lines as follows:
Load Word Changes:
//Long data = (Long) bus.read(s + s_imm);
Long data = (Long) bus.read((s + s_imm) & 0xFFFFFFFFL);
Store Word Changes://ret = bus.write(s + s_imm, regfile.read(rt), false);
ret = bus.write((s + s_imm) & 0xFFFFFFFFL, regfile.read(rt), false);
After building PLPTool with these changes, negative offsets work as expected. For anyone who has in-depth knowledge of the simulator implementation, is there any reason why addresses are longs (64 bits in Java) rather than ints (32 bits in Java) since PLP is a 32 bit architecture?
Thanks,
Chris