|
|
Product:
80C52 Based Products
|
|
Controlling
80C52 Port 1 Bits with Assembly Language Calls |
Date: 5/26/98
|
Introduction:
Although
the Port 1 bits can be controlled directly through BASIC using the PORT1
command, sometimes its easier to use assembly language calls. This method
allows the individual bits to be changed instead of the whole port. |
|
Background:
The
following table indicates the addresses for the Port 1 bits: P1.0
= 90h P1.4 = 94h P1.1 = 91h P1.5 = 95h If
only a few of the bits are being controlled then the easiest way to
implement this is by storing the machine code using data statements. The
code to set, clear, or toggle a bit takes three bytes of memory (command,
address, return). The
machine code commands are used as follows: NOTE: Assignments must begin with an integer, otherwise the
processor will interpret them as a variable. 0D2h
= set bit |
|
Program
Listing: The sample program below shows how the commands are stored
and then called: 10 DATA 0D2h, 94h, 22h : REM code to set bit 4 of
port 1 |