27.01.2015 Views

titus-larsen-titus-1981-apple-interfacing

titus-larsen-titus-1981-apple-interfacing

titus-larsen-titus-1981-apple-interfacing

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

grams are probably easier to write and debug. Assembly language<br />

programming is generally not recommended for the novice.<br />

We will be mentioning assembly language programming very little,<br />

concentrating on the use of BASIC language programming instead.<br />

For further information on 6502 assembly language programming,<br />

we recommend 6502 Software Design and Programming and<br />

Interfacing the 6502, With Experiments (Howard W. Sams & Co.,<br />

Inc., Indianapolis, IN 46268).<br />

Binary and Decimal Numbering<br />

The Apple computer system acquires, processes, and prints decimal<br />

(base-10) numbers. This makes it compatible with the numbering<br />

used by most people today. It would be difficult for us to readily<br />

understand and convert data values that were printed in a nondecimal<br />

format. The data and address lines are directly connected to the<br />

6502 microprocessor chip, so they are binary, having only two statesa<br />

logic one or a logic zero. Thus, when we specify an I/ 0 port address<br />

in a PEEK or POKE command, we must realize that the address<br />

( 0-65535 ) will appear in its binary form on the address bus<br />

(0000000 0000-1111111111111111). You should be able to make<br />

the conversion between decimal and binary, in either direction.<br />

Likewise, the data values transferred to and from the computer<br />

by the PEEK and POKE commands are also specified or acquired as<br />

8-bit binary values, since the data bus is only eight bits "wide." The<br />

8-bit data bus is a function of the data processing capability within<br />

the 6502 chip. It is not a function of the Apple. Thus, we are limited<br />

to 8-bit data transfers. Is this a great limitation Generally not. In<br />

spite of it, the Apple can process a great deal of information, and, as<br />

you will see later, it is easy to interface to 1/0 devices.<br />

One final note on addresses is necessary before leaving this chapter.<br />

The BASIC interpreter in the Apple computer has been set up<br />

to handle both negative and positive addresses. This does,n,ot mean<br />

that there are actually negative addresses in the computer. Can you<br />

imagine negative street numbers The negative numbers are simple<br />

due to the way in which the binary equivalents of the addresses are<br />

stored in the Apple. Thus, the address for the speaker, 49200, is<br />

equivalent to -16336. To avoid confusion, we strongly recommend<br />

the use of the positive addresses. You can easily convert between<br />

negative and positive addresses simply by (a) adding 65536 to a<br />

negative address to yield the positive equivalent, or (b) by subtractir1g<br />

65536 from the positive address to yield the negative equivalent.<br />

Both addresses, 49200 and -16336, generate the same 16-bit address,<br />

but we think that you will agree that negative addresses can seem a<br />

hit abstract and confusing.<br />

25

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

Saved successfully!

Ooh no, something went wrong!