12.07.2015 Views

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

172 APPLE II COMPUTER GRAPHICSand is ignored. For any of you interested in machine-level programming,when a bit is carried off the end of an addition, the processor s<strong>et</strong>s a sign<strong>al</strong>bit, c<strong>al</strong>led the carry flag, within the status register. That sign<strong>al</strong>s (to anybodywho knows where to look) that the latest operation had to dump a carryinto the buck<strong>et</strong>.SubtractionFigure A 1 -6 shows an example of binary subtraction.!001 1 01 11!0010 0101!0001 0010Figure A1-6.Again you work from right to left, and you should have no problemarriving at the result. This sample was carefully constructed so that youcould subtract without having to fiddle around with borrowing, not becauseof coward ice, but because you never re<strong>al</strong>ly have to worry aboutborrowing in binary. The fact is, your <strong>computer</strong> never subtracts, so whyshould you? Instead of subtracting a number, the arithm<strong>et</strong>ic unit of yourmachine <strong>al</strong>ways ADDS a thing c<strong>al</strong>led the "two's complement."Two1s ComplementForming the two's complement of a binary number takes two steps: firstchange <strong>al</strong>l the ones to zeros, and <strong>al</strong>l the zeros to ones, and second, addone to the result. To form the two's complement of !({)(1')10 (/)101, you fi rstturn it into !11(/)1 1(/)1(/) and then add 1 to g<strong>et</strong> !11(/)1 1011. Now we canrepeat the example from Figure A 1 -6 using addition, but instead of subtracting!(/')(/')1(/') (/)1 (/)1 , you will add its two's complement, !11(/)1 1(/)11.1 8 !001 1+ !1101!00010111101 10010Figure A1-7.The addition is shown in Figure A 1 -7, and is fairly straightforward. Theanswer comes out the same as before, except for the carry from the last

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!