PDP-8 Code Optimization (was Re: HP-35/45 Simulator for PDP-8)

Pete Turnbull pete at dunnington.plus.com
Wed Sep 14 09:42:54 CDT 2016


On 14/09/2016 13:17, Vincent Slyngstad wrote:
> From: Kyle Owen: Tuesday, September 13, 2016 7:12 PM
>> TAD OVFA /A XOR B
>> AND OVFB
>> CMA IAC
>> TAD OVFA
>> TAD OVFB
>
> Sigh.
>
> There seems to be an issue with my implementation of XOR.
> Before the CMA IAC there needs to be CLL RAL, to reposition the carries
> before subtracting them.  Both XORs are affected.

Yes, the usual way is just what you describe: A + B - (2 * A AND B), 
which works by calculating the bitwise carries and subtracting them from 
the addition, to make it carryless.  The AND tells you where they result 
from but you have to shift them to the correct positions before taking 
the difference.  You were missing the multiply x 2 (which needs the CLL 
first).  Easily missed.

But unless I've missed something, you don't need a complete XOR, you 
just need to check the sign bits.

-- 
Pete
Pete Turnbull


More information about the cctech mailing list