(16C) Mask and Sign Extend
|
04-09-2019, 07:25 PM
Post: #3
|
|||
|
|||
RE: (16C) Mask and Sign Extend
Thanks for the hint, wynen! Here then is a shorter, simpler version of the original program. This is slightly different than the original in that you specify which bit is the sign bit rather than how many bits are in the offset. In both cases though, the offset is assumed to be in the lower bits of the instruction word.
Usage: Enter the instruction followed by the bit number of the offset sign. Press GSB A. The signed offset will be in X. You can now use the signed offset and incremented program counter value to calculate the target address of the branch instruction. Before: Y - Instruction X - bit # of the offset sign bit After X - Masked and sign extended offset Example (PDP-11) Set word size to 16, mode to Hex. The offset is the lower 8 bits of the instruction, so the sign bit would be bit 7. BNE $+4 ; offset would be 3 Enter 0203h, 7h Result is 3h BEQ $-4 ; offset would be -5 Enter 03FBh, 7h Result is FFFBh (-5) Code:
Remember kids, "In a democracy, you get the government you deserve." |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(16C) Mask and Sign Extend - mfleming - 03-26-2019, 11:48 PM
RE: (16C) Mask and Sign Extend - wynen - 04-09-2019, 09:38 AM
RE: (16C) Mask and Sign Extend - mfleming - 04-09-2019 07:25 PM
RE: (16C) Mask and Sign Extend - hth - 04-12-2019, 08:33 PM
RE: (16C) Mask and Sign Extend - mfleming - 04-13-2019, 02:32 AM
RE: (16C) Mask and Sign Extend - hth - 04-16-2019, 01:56 AM
|
User(s) browsing this thread: 1 Guest(s)