PDP11/45 machine code question.

From: Paul Koning <pkoning_at_equallogic.com>
Date: Mon Feb 21 08:57:05 2005

>>>>> "Jim" == Jim Beacon <jim_at_g1jbg.co.uk> writes:

 Jim> Hi, this is simple if you know....

 Jim> I was looking at a listing for a light chaser for the PDP 11,
 Jim> and the last instruction is branch back 4, (BR -4). The hex for
 Jim> this is given as 000775

 Jim> I understand that this is a bit type instruction, where the op
 Jim> code is the base code plus 2*offset. If the base code is 000400,
 Jim> how do I calculate the offset to make it go back ? Is bit 7 a
 Jim> sign bit?

Not quite. The low byte of the branch instruction is an 8 bit two's
complement value.

Two's complement means: to take the negative of a number, complement
all bits, then add one. So for example (in 8 bits):

    +2 = 00 000 010
    -2 = 11 111 110

The branch displacements are 8 bit two's complement values, in units
of words (not bytes), counting from the instruction following the
branch. So, for example, "br ." (an infinite loop) is 000777 because
it needs a displacement of -1.

Note that SOB is different, it always branches backwards and has a
positive 6-bit displacement.

         paul
Received on Mon Feb 21 2005 - 08:57:05 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:37:39 BST