Sunteți pe pagina 1din 11

Lecture 11

Program Design
Lecture 11(a)

Programming Design
Program Development Steps
Understand the problem: form of data involved,
necessary interface circuits, existing ways of solving
situation at hand.

Develop algorithm: step by step statements or a


flowchart.

Write program: covert algorithm into a program using


a suitable programming language.

Assemble/compile the program, load into memory


and run to test to debug the program.

Testing and debugging may run for a number of


iterations before a perfect solution is realized.
Practical Programs
Practical programs have one or more of these
constructs

They may make use of subroutines (to be covered


later)
Labels at points Start RS232 Transmission
Label where two

Practical Programs
where there is a
junction Set counter (reg B) to 8)
 
alternate pathways
exist; label one of the
two paths
write_bit
Shift LSB of register A into carry flag

Y write_1
Is carry flag set?

Write a ‘1’ to data line


N
Write a ‘0’ to data line
If-else
write_nxt
construct
Decrement counter
Subroutine
N
Is counter zero?

Y
End Do while construct
Start

Practical ProgramsSequential
HL = 9000h; C = 8h; clear E
Label_1
B =8h

Preserve (HL) in D
Label_2
EX-OR D with E, keep D & E unchanged

Shift MSB of EX-OR results into carry

Y Label_3
Carry set?
EX-OR E with 18H;
N
If-then store results in E
Label_4
construct Do while
Shift right Ereplacing MSB with carry
flag & LSB with 0 PLUS while-
Label_5 N
Decrement B; B = 0?
do
Shift D to right;
Y
Decrement B N Label_6
Decrement C; C=0?
Do while Increment HL;
Y
decrement C
End
Class Design Exercise1
Programming Exercises

1. Question 1
2. Question 2
3. Question 3
Class Design Example 1
Develop a program that finds the maximum in a
block of locations from memory address 5001H to
memory address 5200H. The numbers are
unsigned values.
Class Design Example 2
A microprocessor based system that works as follows is required:
When temperature is below 20˚C, turn on a heater
If temperature is in the range 20˚C to 28˚C, switch off everything
If temperature is above 28˚C, turn on a fan

The fan is connected to pin 0 and the heater to pin 1 on port


05h. The temperature is provided by an ADC connected between
the temperature sensor and port address 04h.

Design the system

Repeat as assignment given that the


resolution of the ADC is 0.25˚C.
Lecture 11(b)

Programming Design
Class Design Example 3
Write a program to move characters in memory block
addresses 7001H to 8000H to memory block starting
at C000. The source block contains a text body.
When moving it to the new block, any lower case
characters must be converted to uppercase.

S-ar putea să vă placă și