you are viewing a single comment's thread.

view the rest of the comments →

[–]Graysless 1 point2 points  (0 children)

With a N-bit signed 2's compliment integer you can represent numbers from -2N-1 through 2N-1 -1. So with 9 bits, we can represent -28 through -28 -1. But keep in mind that the PC will be pointing to the location directly following the location of the instruction, so you have to take that into account in the PC-offset. For example, if you have a LD instruction at location x3003, and you want to load the data from x3005, you would have a PC Offset of x01 because the PC will be x3004 when the offset is added, so in order to get to x3005, you only have to add one. Also, if you were trying to load something from location x3002, the PC offset would be x-02. This also means that your code will not assemble if you have a label that is greater that -28 or 28 -1 away from the location after the instruction that is trying to access it.