[Simh] Writeup of PDP-11 bootstrap loader analysis

Paul Koning paulkoning at comcast.net
Wed Dec 23 20:29:05 EST 2015


> On Dec 23, 2015, at 8:02 PM, Will Senn <will.senn at gmail.com> wrote:
> 
> 
> 
> 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,
> 
> Given Line 7 037760  100376               BPL WAIT
> 
> 100376 is a BPL instruction and the offset (376) is to be multiplied by two and added to the updated PC. That is, 376 * 2 is going to be added to 037762. 376 represents a negative offset in two's complement notation - it has a one in it's most significant bit, the left hand bit in 11 111 110. As a human, I kind of need the number in some form that makes sense to me, so I convert it to a positive quantity by first taking the one's complement and adding one. This gives me the positive magnitude of the negative number -1. Multiplying this by two is easy, it's -2, which when added to 037762 yields 037760 , which is the correct location. This is how I did the math. If I understand you correctly, the machine doesn't do it this way. I tried multiplying 376, 11 111 110 by shifting left one, 11 111 100, and adding that to 037762's binary representation, but that doesn't seem to make sense. Would you please elaborate?

Branch argument is -2, so branch displacement is twice that, or -4.  That is updated to the updated PC (the PC after the branch), or 037762 in this case.  037762-4 = 037756 which is the TSTB.  That's a classic "wait for device ready" loop.

Your two's complement description is correct but you didn't do it right.  11 111 110 complemented is 00 000 001, add one and you get 00 000 010 which is 2.  So the original number was -2.

	paul




More information about the Simh mailing list