You are on page 1of 1

INTRODUCTION TO 8085 INSTRUCTIONS 211

needs to draw up a plan of logical thoughts. A given task should be broken down into
small units that can be built independently. This is called the modular design approach.

6.5.1 Getting Started


Writing a program is equivalent to giving specific commands to the microprocessor in a
sequence to perform a task. The italicized words provide clues to writing a program. Let
us examine these terms.

Perform a Task. What is the task you are asking it to do?


❑Sequence. What is the sequence you want it to follow?
111 Commands. What are the commands (instruction set) it can understand?

These terms can be translated into steps as follows:


Step 1: Read the problem carefully.
Step 2: Break it down into small steps.
Step 3: Represent these small steps in a possible sequence with a flowchart—a plan of
attack.
Step 4: Translate each block of the flowchart into appropriate mnemonic instructions.
Step 5: Translate mnemonics into the machine code.
Step 6: Enter the machine code in memory and execute. Only on rare occasions is a
program successfully executed on the first attempt.
Step 7: Start troubleshooting (see Section 6.6, "Debugging a Program").
These steps are illustrated in the next section.

6.5.2 Illustrative Program: Microprocessor-Controlled


Manufacturing Process
PROBLEM STATEMENT
A microcomputer is designed to monitor various processes (conveyer belts) on the floor
of a manufacturing plant, presented schematically in Figure 6.12. The microcomputer
has two input ports with the addresses F1H and F2H and an output port with the address
F3H. Input port F1H has six switches, five of which (corresponding to data lines D 4–D0)
control the conveyer belts through the output port F3H. Switch S7, corresponding to the
data line D7, is reserved to indicate an emergency on the floor. As a precautionary mea-
sure, input port F2H is controlled by the foreman, and its switch, S 7 ', is also used to in-
dicate an emergency. Output line D6 of port F3H is connected to the emergency alarm.
Write a program to

1. turn on the five conveyer belts according to the ON/OFF positions of switches S 4 –S o
at port F1H.
2. turn off the conveyer belts and turn on the emergency alarm only when both
switches—S 7 from port Fl H and S7/ from port F2H—are triggered.
3. monitor the switches continuously.

You might also like