Exploiting the Overflow Feature of a Conventional CPU

The issue persists of whether modern machines should continue the traditional overflow (or carry) bit. I recall here a fairly short loop that utilized that feature three different ways in the span of about 12 instructions in some of my Motorola 68000 machine language code.

The task is to produce 3 million one bit pixels—black if a certain 3rd order polynomial in x and y was positive and white otherwise. Using differences to compute the polynomial, as Babbage planned for his difference engine, is the way to go, but multi precision is then required. The multi precision adds used the hardware carry logic just as it was conceived. Having the polynomial value in the accumulator in fixed format also means that the sign of the polynomial is already in the carry bit. An add to self with carry shifts the pixel accumulator one bit left and inserts the new pixel in the vacated low order bit. The pixel accumulator is initialized not with zero, but with 1. This means that after the add to self, 32 pixels have been accumulated just if the overflow is on. A conditional test of the carry bit is usually provided and this test closed the loop.

I know of no language other than assembler to achieve this hackery.


The ‘app’ would invite the user to choose nine points on a large window and the program would determine the unique cubic polynomial passing thru those points, and make the screen black everywhere that polynomial was negative. It was surprisingly dramatic as well as instructive.