Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
transfers will require more than eight bits of information, so multiple<br />
bytes are transferred, one byte at a time.<br />
There are also cases in which the actual value of the data transferred<br />
is meaningless. The bits may be used to represent individual<br />
two-state conditions that are unrelated to the positional values of<br />
the bits. For example, a number of sensors could be connected to the<br />
Apple indicating conditions such as tank empty-or-full, heater on-oroff,<br />
value open-or-closed, and so on. A PEEK command could be<br />
used to input the status of these indicator bits, through an 8-bit input<br />
port. Thus, the value read from this input port might be 100, but the<br />
port is sensing eight individual on or off (logic one or logic zero)<br />
states, so the value of 10010 is meaningless. The individual binary<br />
bits each represent the state of an individual sensor. In this case:<br />
10010 = 011001002<br />
This indicates that three of the sensors are in the logic one state and<br />
five are in the logic zero state.<br />
The POKE and PEEK commands can also be used in a similar<br />
manner to turn a device on or to turn a device off, based upon the<br />
state of the individual bits that have been sensed elsewhere in a control<br />
program. In fact, many of the I/0 addresses used by the Apple<br />
are assigned to simple on/ off devices such as the speaker. Thus, a<br />
simple command:<br />
A =<br />
PEEK(49200)<br />
will generate a 'blip" on the speaker in the Apple. You should understand<br />
that the variable, A, is a "dummy," and its final value is not important,<br />
since the net effect of the simple BASIC statement is to<br />
pulse the speaker once. The speaker control command may be used<br />
in a loop to generate a low buzz from the speaker. This is shown<br />
'<br />
in<br />
kU<br />
l 0 A = PEEK(49200)<br />
20 GOTO 10<br />
Example 1-4. A Simple Speaker Control Program<br />
The important point to remember here is that the PEEK and<br />
POKE instructions are not limited simply to controlling the transfer<br />
of information on the data bus. They may also be used for specific<br />
control functions, such as pulsing a counter, turning on a pump, or<br />
tilting a solar collector.<br />
Assembly Language and BASIC<br />
The BASIC-language programs that you write on your Apple computer<br />
bear very little relationship to the actual instructions that the<br />
6502 microprocessor chip can actually execute. Each of your BASIC<br />
23