On 12/23/15 5:09 PM, Johnny Billquist wrote:
As for your analysis:
Your explanation of branches seems somewhat over complicated. The
instruction is indeed in just 8 bits, while 8 bits are the offset.
However, there is no need to mess things up with one-complement, or
tricks like that. The offset is an 8-bit value. Sign extend to 16
bits. Multiply by 2, and add to the updated PC. Simple as that.
(Note that I said "updated PC". The PC will contain the address of the
instruction after the branch before you start doing the calculation
for the branch destination.)
Johnny,
OK. I think I figured out how to think about the BPL. Given the machine
code:
037756 100376
It is a BPL instruction to the updated PC + (2 * offset). The offset is
given as 376, in binary, sign extended 1 111 111 111 111 110, shifting
it left to multiply by 2 (there's a carry out that we can ignore)
results in 1 111 111 111 111 100. Adding the result to the updated PC,
037762, results in binary 0 011 111 111 110 010 (there's another carry
out we can ignore). The math looks like this:
1 111 111 111 111 100 (2 * offset 376 sign extended)
+ 0 011 111 111 110 010 (PC = 037762)
-----------------------
0 011 111 111 101 110 (037756)
I can see that this is a better, simpler explanation and more in line
with how the machine processes the instruction.
Thanks,
Will
_______________________________________________
Simh mailing list
Simh@trailing-edge.com
http://mailman.trailing-edge.com/mailman/listinfo/simh