Prerequisite – 8254 Control Register and Operating modes
Problem – Write an assembly language program in 8085 microprocessor which generates 1 KHz square waveform by using counter 1 as a binary counter if clock frequency of 8254 is 2 MHz.
Assumption – Assume the port addresses are 80 H, 81 H, 82 H, 83 H for C0(Counter 0), C1(Counter 1), C2(Counter 2), CR(Control Register).
For the above problem, 8254 must work in Mode 3 which is the square wave generator.
Count for register is given as clock frequency / square wave frequency
count = 2 MHz / 1 KHz
= 2000
= (07D0) H
Now the data is 16 bit so value of RW1 = 1 and RW0 = 1 in Control Register. As we want to select C1 (Counter 1) the value of SC1 = 0 and SC0 = 1 in Control Register. Value of M2 = 0, M1 = 1 and M2 = 1 for Mode 3 in Control Register. For binary counter value of LSB in CR is 0.
Hence the Control Register(CR) is given by,

Algorithm –
- Move the data 76 in A
- Display the contents of A to port 83
- Move the data D0 in A
- Display the contents of A to port 81
- Move the data 07 in A
- Display the contents of A to port 81
- Stop
Program –
| MEMORY ADDRESS | MNEMONICS | COMMENT |
|---|---|---|
| 2000 | MVI A 76 | A <- 76 |
| 2002 | OUT 83 | CR <- A |
| 2004 | MVI A D0 | A <- D0 | 2006 | OUT 81 | C1 <- A | 2008 | MVI A 07 | A <- 07 | 200A | OUT 81 | C1 <- A | 200C | HLT | Stop |
Explanation–
- MVI A 76 is used to move the content of CR(Control Register) to register A.
- OUT 83 is used to assign the value of A to port 83 which is Control Register.
- MVI A D0 is used to move the move the lower byte of data of Counter 1 to register A.
- OUT 81 is used to assign the value of A to port 81 which is Counter 1.
- MVI A 07 is used to move the move the higher byte of data of Counter 1 to register A.
- OUT 81 is used to assign the value of A to port 81 which is Counter 1.
- HLT is used end the program.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Recommended Posts:
- Microprocessor | 8254 programmable interval timer
- Interface 8255 with 8085 microprocessor for addition
- Interface 8255 with 8085 microprocessor for 1’s and 2’s complement of a number
- 8254 Control Word and Operating modes
- Interrupts in 8085 microprocessor
- Addressing modes in 8085 microprocessor
- Registers of 8085 microprocessor
- Flag register in 8085 microprocessor
- Instruction cycle in 8085 microprocessor
- Arithmetic instructions in 8085 microprocessor
- Logical instructions in 8085 microprocessor
- Data transfer instructions in 8085 microprocessor
- Branching instructions in 8085 microprocessor
- Reset Accumulator (8085 & 8086 microprocessor)
- Differences between 8085 and 8086 microprocessor
- Pin diagram of 8085 microprocessor
- Bus organization of 8085 microprocessor
- Subtract content of two ports by interfacing 8255 with 8085 microprocessor
- Serial I/O Lines in 8085 Microprocessor
- Difference between SIM and RIM instructions in 8085 microprocessor
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

