williams-et-al-1983-apple-ii-computer-graphics
williams-et-al-1983-apple-ii-computer-graphics
williams-et-al-1983-apple-ii-computer-graphics
- No tags were found...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
APPENDIX 1-DECIMAL, HEX, AND BINARY 173column which f<strong>al</strong>ls into the bit buck<strong>et</strong> that is ignored anyway. This is whythe two's complement can be used as if it were a negative number, whenit re<strong>al</strong>ly is not.If you add any number to its corresponding negative v<strong>al</strong>ue (five plusnegative five) you will <strong>al</strong>ways g<strong>et</strong> zero. The same thing happens when youadd any binary number to its two's complement ... <strong>al</strong>most. Try adding! (3(31(3 (31(31and its complement:! 11(31 1(311You will g<strong>et</strong> <strong>al</strong>l zeros, except for the fi n<strong>al</strong> carry which f<strong>al</strong>ls into the buck<strong>et</strong>.So we <strong>al</strong>ways expect that carry, and ignore it when it occurs.Figure A 1-8 shows another sample of subtraction using two's complement.1 !101 1 001 1 8 !1011 001 1!01 10 1100 - !1001 001 1 - + !1001 0100!0100 01 11Figure A1-8.Notice that it is <strong>al</strong>ways the number being subtracted which is changed toits two's complement form. !©1 1© 11©© is changed to !1©©1 ©©1 1, and thena 1 is added to g<strong>et</strong> !1©©1 ©1©©. This number is then added to !1©1 1 ©©1 1to g<strong>et</strong> !©1 ©© ©1 11, and as usu<strong>al</strong> we ignore the bit in the buck<strong>et</strong>.Negative AddressesThe two's complement essenti<strong>al</strong>ly changes a number to its negative equ iv<strong>al</strong>ent,so instead of subtracting a number you end up adding its negative.In a decim<strong>al</strong> s<strong>et</strong>ting you can think of it as changing the subtraction 9-3into the addition 9 + (-3) and the result is six in either case.The same idea l<strong>et</strong>s some addresses be written in negative form for convenience.When you wish to enter Monitor from BASIC you CALL theaddress -151. The true address for the Monitor entry point is 65385, and-151 is the two's complement of that address. If you convert 151 to its twobytebinary form (!©©©© ©©©© 1©©1 ©1 11) and take the two's complement(to account for the negative) you g<strong>et</strong> !1111 11_1 1 ©1 1© 1©©1 . The not-soquickconversion to decim<strong>al</strong> results in the expected v<strong>al</strong>ue of 65385. Youmust admit that -1 51 is much easier to remember that 65385.Another reason for using the two's complement, or negative, fo rm for