EXPERIMENT 4: SUBROUTINES

OBJECT:

The object of this experiment is to introduce to write more flexible and efficient programs by using subroutines.

REFERENCE:
Gaonkar, R.S., Microprocessor Architecture, Programming and Applications with the
8085/8080A.
Sections : 6.3, 6.4, 6.5, 7.1, 7.4, 7.5, 8.1, 8.2, 8.3, 8.4, 9.1, 9.2, 9.3, 9.4.
Appendix F 8085/8080A Instruction Set

PRELIMINARY and EXPERIMENTAL WORK :

a) Write a DELAY subroutine to maintain 100 ms or 200 ms delay according to the value in E register, 01H or 02H respectively (clock frequency is 3.072 MHz).

b) Write three subroutines named GREAT, LESS and EQUAL that perform the following operations;

GREAT : Displays the following patterns with a delay of 200 ms on the LEDs, using DELAY subroutine written in part a:

00011000-00100100-01000010-10000001

LESS : Displays the following patterns with a delay of 200 ms on the LEDs, using DELAY subroutine written in part a:

10000001-01000010-00100100-00011000

EQUAL : Displays the following patterns with a delay of 100 ms on the LEDs, using DELAY subroutine written in part a:

00011000-00100100-01000010-10000001-10000001-01000010-00100100-00011000

NOTE: In each subroutine display corresponding pattern in a loop, NOT one-by-one. Do NOT use a structure like the following:

MVI A,81H
OUT 11H
MVI A,42H
OUT 11H
MVI A,24H
OUT 11H
MVI A,18H
OUT 11H

Instead use a loop structure!!!

c) Write an assembly language program that gets the input from the binary dipswitch port and make the following decision according to the content (bit pattern) of the input port:

* If the number of ‘0’ s is greater than number of '1’ s in the bit pattern:

Call GREAT subroutine written in part b and check the dipswitches again.

* If the number of ‘0’ s is less than number of ‘1’ s in the bit pattern:

Call LESS subroutine written in part b and check the dipswitches again.

* If the number of ‘0’ s is equal to number of ‘1’ s in the bit pattern:

Call EQUAL subroutine written in part b and check the dipswitches again.

Use the subroutines written in part a and part b and CONDITIONAL CALLs to these in the main segment of your program. The program must check the dip-switches continuously and display the case.