Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 58

3341101 MALP GTU

PROGRAM-1
AIM: Identify the components of the microprocessor trainer to configure in the programming
mode.

Introduction of 8085 Kit:

 8085 Kit allows you to enter hex code of the program and run the program. You
can observe content of registers and memory locations after and before execution
of assembly language program.
 8085 Kit has 8Kbyte CMOS RAM chip 6264 and 8Kbyte EPROM.
 8085 Kit has various input-output devices such as 8279 (Keyboard display
interface), 8255 (Programmable peripheral interface), 8155 (Programmable I/O
port and timer), 8253 (Programmable interval timer)

8085 Following keys to enter execute and observe result of the program.

 RESET: To reset the system


 VI: To provide hardware interrupt
 SHIFT: To give second level command (Alternate function)
 GO: To execute program
 SI: To execute program in single step mode
 EXMEM: Examine or modify memory locations
 EXREG: Examine or modify CPU registers
 PRE: Used with EXMEM to decrement content of PC (Intermediate
terminator)
 NEXT: Increment PC value. Used while examining memory locations and
contents of registers
 . (DOT): It is terminator to terminate command and write data in the data
field at the location displayed in address field
 DEL: Delete part of the program or data
 INS: Inserts the part of the program or data with relocation by one or more
bytes
 BM: Allows user to move block of memory to any other RAM area
 FILL: Allows user to fill RAM area with a constant
 REL: Relocates a program written for some memory area and transfer to
other memory area
 INSDATA: Inserts one or more data bytes in user program data area
 DELDATA: Deletes one or more data bytes from the user program/data
 MEMC: Compares two blocks of memory
 0-F: Hexadecimal keys to enter program and data

1
3341101 MALP GTU

 8085 kit has six digit seven segment displays. First four digits are called “address field”
and last two digits are called “data field”.
 Memory map for the kit is as follow:
EPROM: 0000 to 1FFF (Used to store in built monitor program)
RAM: 2000 to 3FFF (Used to enter program code in the kit)
Scratch Pad RAM used by monitor program: 2770 to 27FF

Steps for entering and executing assembly language program in the Kit
Let us understand how to enter and execute following program in the kit

MEMORY
LABLE MNEMONICS HEX CODE COMMENT
ADDRESS
2000 MVI A,10h 3E
2001 10
2002 MOV B,A 78
2003 RST-5 EF

Steps to enter program in the kit:


Above program transfers data value 10 into accumulator. Use following steps to enter program in
the kit.
 Switch ON 8085 Kit. Message “know 8085 trainer kit” will be displayed on the LCD
display.
 To enter HEX code of the program press “E/M” key and press enter key.
 Enter start memory address for example 2000
 2000: enter hex code
 Enter HEX code. In our program, first hex code is 3E. It will be displayed on data field.
 Press “ENTER” key
 Enter next HEX code i.e. 10
 Press “ENTER” key
 Enter next HEX code i.e. 78
 Press “ENTER” key
 Enter next HEX code i.e. EF
 Press (.) dot key

Steps to execute the program:


After entering program, now let us understand how to execute this program.
 Press “GO” key
 Enter start memory address of the program i.e. 2000
 Press “.” Key. Program will execute

2
3341101 MALP GTU

Steps to examine result after execution of the program:


After entering and executing program, we wish to examine result of the program. In our
program, we want to examine content of Accumulator. Use following steps to observe content of
accumulator.
 Press “R” Key
 Press “A” to examine content of accumulator and press enter key to check status of other
register
 Press “.” dot Key

3
3341101 MALP GTU

PROGRAM-2
AIM: Develop/Execute a simple programmed to move data from one register to the other
register.

PROGRAM: - Write & Execute Program to store 45h in register A and 59h in register B. Also
copy data of register A & B into register C & D respectively.

ALGORITHM:

 Start the program by loading 45h in register A.


 Loading 59h in register B.
 Copy data of register A into register C.
 Repeat step-3 for data of register B.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 MVI A, 45H
2001
2002 MVI B,59H
2003
2004 MOV C,A
2005 MOV D,B
2006 RST-5

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
45H A 45H
59H B 59H
C 45H
D 59H

4
3341101 MALP GTU

PROGRAM: - Write & Execute Program to load 8-bit number in memory location 2050h.

ALGORITHM:

 Start the program by loading 8-bit number in register A.


 Copy data of register A into 2050h.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 MVI A, 25H
2001
2002 LDA 2050H
2003
2004
2005 RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
A 25H 2050H 25H

5
3341101 MALP GTU

PROGRAM: - Write & Execute Program to Store content of memory location 2050h into
register B & memory location 2060h.

ALGORITHM:

 Start the program by loading 8-bit number in 2050h location.


 Copy data from 2050h to register A.
 Copy data from register A to register B.
 Store data of register A into 2060h location.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 LDA 2050H
2001
2002
2003 MOV B,A
2004 LDA 2060H
2005
2006
2007 RST-5/HLT

6
3341101 MALP GTU

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 15H B 15H
2060H 15H

PROGRAM: - Write & Execute Program to copy content of memory location 2050h which is
stored in BC register pair into register D & location 2060h which is stored in DE
register pair.

ALGORITHM:

 Start the program by loading 2050h in BC register pair.


 Loads register A indirectly from content of 2050h location.
 Copy content of reg. A into reg. D.
 Load 2060h in DE reg. pair.
 Copy content of reg. A indirectly in 2060h location.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 LXI B,2050H
2001
2002
2003 LDAX B
2004 MOV D,A
2005 LXI D,2060H
2006
2007
2008 STAX D
2009 RST-5/HLT

7
3341101 MALP GTU

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
BC 2050H D 23H
DE 2060H 2060H 23H
2050H 23H

PROGRAM: - Write & Execute Program to exchange content of HL and DE reg. pair.

ALGORITHM:

 Start the program by loading HL reg. pair with 16-bit number.


 Repeat previous step for DE reg. pair.
 Exchange the content of reg. pair.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 LXI H,2050H
2001
2002
2003 LXI D,1045H
2004
2005
2006 XCHG
2007 RST-5/HLT

8
3341101 MALP GTU

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
HL 2050H HL 1045H
DE 1045H DE 2050H

9
3341101 MALP GTU

PROGRAM-3
AIM: Develop/Execute a programmed for addition.

PROGRAM: - Write & Execute Program to add two 8-bit numbers.

ALGORITHM:

 Start the program by loading first 8-bit number in reg. A.


 Load second 8-bit number in reg. B.
 Add two reg. contents.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 MVI A,05H
2001
2002 MVI B,04H
2003
2004 ADD B
2005 RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
A 05H A 09H
B 04H

10
3341101 MALP GTU

PROGRAM: - Write & Execute Program to add content of two memory location.

ALGORITHM:

 Start the program by loading HL reg. pair with address of mem. Location.
 Move the data into reg. A.
 Increment HL reg. pair.
 Add two reg. contents.
 Increment HL reg. pair and store result on it.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 LXI H,2050H
2001
2002
2003 MOV A,M
2004 INX H
2005 ADD M
2006 INX H
2007 MOV M,A
2008 RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 04H 2052H 07H
2051H 03H

11
3341101 MALP GTU

PROGRAM: - Write & Execute Program to add two 16-bit numbers.

ALGORITHM:

 Start the program by loading first 16-bit number in HL reg. pair.


 Load second 16-bit number in DE reg. pair.
 Add two reg. pair. Contents.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 LXI H,1025H
2001
2002
2003 LXI D,2534H
2004
2005
2006 DAD D
2007 RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
HL 1025H HL 3559H
DE 2534H

12
3341101 MALP GTU

Q-1 W.A.P to add two 16-bit number. (With out using DAD instruction)

13
3341101 MALP GTU

PROGRAM-4
AIM: Develop/Execute a programmed for subtraction.

PROGRAM: - Write & Execute Program to subtract two 8-bit numbers.

ALGORITHM:

 Start the program by loading first 8-bit number in reg. A.


 Load second 8-bit number in reg. B.
 Subtract two reg. contents.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 MVI A,07H
2001
2002 MVI B,04H
2003
2004 SUB B
2005 RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
A 07H A 03H
B 04H

PROGRAM: - Write & Execute Program to subtract content of two memory location.

14
3341101 MALP GTU

ALGORITHM:

 Start the program by loading HL reg. pair with address of mem. Location.
 Move the data into reg. A.
 Increment HL reg. pair.
 Subtract two reg. contents.
 Increment HL reg. pair and store result on it.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 LXI H,2050H
2001
2002
2003 MOV A,M
2004 INX H
2005 SUB M
2006 INX H
2007 MOV M,A
2008 RST-5/HLT

RESULT:

15
3341101 MALP GTU

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 04H 2052H 01H
2051H 03H

Q-1 W.A.P. to subtract content of mem. Location 2050h and reg. C. store result in mem.
Location 2060h.

16
3341101 MALP GTU

PROGRAM-5
AIM: Develop/Execute a programmed for multiplication.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Move first byte to register.
3) Get second byte and store in accumulator.
4) Add two register content.
5) Check for carry.
6) Increment the value of carry.
7) Check whether repeated addition is over and store the value of product and
carry in memory location.
8) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
2000 MVI B,02H
2001
2002 MVI C,05H
2003
2004 MVI A,00H
2005
BACK ADD C
JNC NEXT

INR D
NEXT DCR B
JNZ BACK

RST-5/HLT

RESULT:

17
3341101 MALP GTU

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
B 02H A 0AH
C 05H

Q-1 W.A.P. to multiply content of two register. Store LSB of result on mem. Location 2050h

and MSB on location 2051h.

18
3341101 MALP GTU

PROGRAM-6
AIM: Develop/Execute a programmed for division.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Copy first byte from 2050h in to reg. A.
3) Increment HL reg. pair by 1.
4) Copy content of memory in reg. B.
5) Subtract content of reg. A and reg. B.
6) Check status of CY flag. IF CY=1, go to step-9, if CY=0, go to next step.
7) Increment content of reg. C by 1. (count quotient)
8) Go back to step-5.
9) Add content of reg. A with reg. B. (to get remainder)
10) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXI H,2050H

MOV A,M
INX H
MOV B,M
BACK SUB B
JC NEXT
INR C
JMP BACK
NEXT ADD B
MOV D,A
RST-5/HLT

19
3341101 MALP GTU

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 07H C 02H
2051H 03H D 01H

Q-1 W.A.P. to divide content of two register. Store quotient of result on mem. Location

2050h and remainder on location 2051h.

20
3341101 MALP GTU

PROGRAM-7
AIM: Develop/Execute an Assembly language program to convert Hexadecimal to ASCII code
conversion.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Load counter value in reg. B.
3) Get first byte in reg. A.
4) Add 30h in content of reg. A.
5) Compare content of reg. A with 39h.
6) If Z=1, go to step-09 or if Z=0, go to step -7.
7) If CY=1, go to step-09 or if CY=0, go to step -8.
8) Add 07 to content of accumulator.
9) Copy content of reg. A in memory.
10) Increment HL reg. pair by 1.
11) Decrement counter by 1.
12) Check counter value. If count is not zero then go to step-3, or if count is zero
then go to next step.
13) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXI H,2050H

MVI B,05H

BACK MOV A,M


ADI 30H

JZ NEXT

JC NEXT

21
3341101 MALP GTU

ADI 07H

NEXT MOV M,A


INX H
DCR B
JNZ BACK

RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050 05 2050 35
2051 03 2051 33
2052 09 2052 39
2053 0A 2053 41
2054 0B 2054 42

22
3341101 MALP GTU

Q-1 Develop/Execute an Assembly language program to convert ASCII code to Hexadecimal


number.

23
3341101 MALP GTU

PROGRAM-8
AIM: Develop/Execute Assembly language program to check whether given no is odd or even.

PROGRAM: - Write & Execute Program to count ODD numbers from 10-blocks of data. Data
are stored on location 2050h.
ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Load counter value in any register. (N counter value).
3) Take First data in register A.
4) Rotate Content of reg. A in right side with carry.
5) Check status of CY flag. (If no CY then goes to step-7 otherwise continue to
next step.
6) Increment ODD number count reg. by 1.
7) Increment HL reg. pair by 1.
8) Decrement counter value by 1.
9) Check counter value. If count is not zero then go to step-3, or if count is zero
then end the program.
10) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXI H,2050H

MVI C,0AH

MOV A,M
BACK RAR
JNC NEXT

INR B
NEXT INX H
DCR C
JNZ BACK

24
3341101 MALP GTU

RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050 01 B 06H
2051 02
2052 05
2053 06
2054 07
2055 03
2056 08
2057 09
2058 05
2059 04

Q-1 Write & Execute Program to count EVEN numbers from 05-blocks of data. Store result

On 3000h location.

25
3341101 MALP GTU

PROGRAM-9
AIM: Develop/Execute a programmed to transfer a block of data from one memory location to
another memory location.

PROGRAM: - Write & Execute Program to move ten block of data from memory location
2050h to memory location 2070h.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair and 2060h in DE reg.


pair.
2) Load counter value in reg. C.
3) Load content of memory location 2050h in reg. A.
4) Load content of reg. A into DE reg. pair indirectly.
5) Increment DE reg. pair by 1.
6) Decrement reg. C by 1.
7) Check counter value. If count is not zero then go to step-3, or if count is zero
then end the program.
8) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXI H,2050H

LXI D,2060H

MVI C,0AH

BACK MOV A,M


STAX D
INX H
INX D
DCR C
JNZ BACK

26
3341101 MALP GTU

RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050 01 2060 01
2051 02 2061 02
2052 03 2062 03
2053 04 2063 04
2054 05 2064 05
2055 06 2065 06
2056 07 2066 07
2057 08 2067 08
2058 09 2068 09
2059 0A 2069 0A

Q-1 Write & Execute Program to exchange content of two reg. pair.

27
3341101 MALP GTU

PROGRAM-10
AIM: Develop/Execute a programmed to add 2 decimal numbers in BCD format.

ALGORITHM:

 Start the program by loading first 8-bit number in reg. A.


 Load second 8-bit number in reg. B.
 Add two reg. contents.
 Convert result in BCD number using DAA instruction.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
MVI A,45H

MVI B,25H

ADD B
DAA
RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
A 45H A 70
B 25H

28
3341101 MALP GTU

PROGRAM-11
AIM: Develop/Execute a programmed to convert data from grey code to binary code.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Load counter value in reg. D.
3) Copy first byte from 2050h in to reg. B.
4) Copy content of reg. B in reg. A.
5) Rotate content of reg. A in right side with carry.
6) Perform ex-or operation of reg. B with reg. A.
7) Copy content of reg. A in reg. B.
8) Decrement counter by 1.
9) Check counter value. If count is not zero then go to step-5, or if count is zero
then go to next step.
10) Copy content of reg. A in 2050h.
11) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXI H,2050H

MVI D,08H

MOV B,M
MOV A,B
BACK RAR
XRA B
MOV B,A
DCR D
JNZ BACK

MOV M,A

29
3341101 MALP GTU

RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 04H 2050H 07H

30
3341101 MALP GTU

PROGRAM-12
AIM: Develop/Execute a programmed to convert data from binary code to gray code.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Copy first byte from 2050h in to reg. A.
3) Copy content of reg. A in reg. B.
4) Rotate content of reg. A in right side with carry.
5) Perform ex-or operation of reg. B with reg. A.
6) Increment HL reg. pair by 1.
7) Copy content of reg. A in memory.
8) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXI H,2050H

MOV A,M
MOV B,A
RAR
XRA B
INX H
MOV M,A
RST-5/HLT

31
3341101 MALP GTU

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050 07 2051 04

32
3341101 MALP GTU

PROGRAM-13
AIM: Develop/Execute an Assembly language programs based on 8 bit Logical instructions.

PROGRAM: - Write & Execute Program to perform Logical AND operation between two 8-bit
numbers. Store result on location 2050h.

ALGORITHM:

 Start the program by loading first 8-bit number in reg. A.


 Load second 8-bit number in reg. B.
 Perform AND operation of two reg. contents.
 End the program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
MVI A,45H

MVI B,0FH

ANA B

RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
A 45H A 05H
B 0FH

33
3341101 MALP GTU

Q-1 Write & Execute Program to perform Logical OR operation between two 8-bit numbers.
Store result on location 2050h.

Q-2 Write & Execute Program to perform Logical EX-OR operation between content of two
mem. Location.

34
3341101 MALP GTU

PROGRAM-14
AIM: Develop/Execute an Assembly language programmed to sum integers from 0 to 9.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Load counter value in any register. (N-1 counter value).
3) Load content of memory (HL reg. pair) in reg. A.
4) Increment HL reg. pair by 1.
5) Add content of reg. A and memory.
6) Increment HL reg. pair by 1.
7) Decrement counter value by 1.
8) Check counter value. If count is not zero then go to step-3, or if count is zero
then end the program.
9) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXIH,2050H

MVI C,09H

MOV A,M
INX H
BACK ADD M
INX H
DCR C
JNZ BACK

RST-5/HLT

35
3341101 MALP GTU

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 00 A 2Dh
2051 01
2052 02
2053 03
2054 04
2055 05
2056 06
2057 07
2058 08
2059 09

Q-1 Develop/Execute an Assembly language programmed to add 5-block of data.

36
3341101 MALP GTU

PROGRAM-15
AIM: Develop a programmed to find the smallest number from an array of 10 numbers.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Load counter value in reg. B.
3) Get first byte in reg. A.
4) Increment HL reg. pair by 1.
5) Compare the content of mem. add. by HL reg. pair with reg. A.
6) If CY=1, go to step-09 or if CY=0, go to step -8.
7) Move content of memory address by HL to reg. A.
8) Decrement counter by 1.
9) Check counter value. If count is not zero then go to step-3, or if count is zero
then go to next step.
10) Store smallest number in memory.
11) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXIH,2050H

MVI B,09H

MOV A,M
BACK INX H
CMP M
JC NEXT

MOV A,M
NEXT DCR B
JNZ BACK

37
3341101 MALP GTU

STA 2060H

RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 23 2060 01
2051 45
2052 67
2053 43
2054 05
2055 36
2056 89
2057 27
2058 01
2059 63

Q-1 Develop a programmed to find the maximum number from an array of 05 numbers.

38
3341101 MALP GTU

PROGRAM-16
AIM: Develop a programmed to count negative values from 10- block of data.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Load counter value in reg. B.
3) Increment HL reg. pair by 1.
4) Get first byte in reg. A.
5) Rotate content of A in left side.
6) Checks carry flag. If CY=1, go to step-07 or if CY=0, go to step -8.
7) Increment negative number count.
8) Check counter value. If count is not zero then go to step-3, or if count is zero
then go to next step.
9) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXI H,2050H

MVI B,0AH

BACK MOV A,M


RAL
JNC NEXT

INR C
NEXT INX H
DCR B
JNZ BACK

RST-5/HLT

39
3341101 MALP GTU

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050 95 C 05H
2051 06
2052 65
2053 83
2054 20
2055 45
2056 95
2057 40
2058 86
2059 70

Q-1 Develop a programmed to count positive number from 05- block of data.

Q-2 Develop a programmed to count number of zero (00h) from 05- block of data.

PROGRAM-17

40
3341101 MALP GTU

AIM: Develop/Execute a program to find the square of given integer.

ALGORITHM:

1) Starting a program by loading 2050h in HL register pair.


2) Copy content of memory in reg. B.
3) Copy content of memory in reg. C. (counter)
4) Clear reg. A.
5) Add content of reg. A and B.
6) Decrement counter value by 1.
7) Check counter value. If count is not zero then go to step-5, or if count is zero
then go to next step.
8) Increment HL reg. pair by 1.
9) Copy content of reg. A in memory.
10) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
LXI H,2050H

MOV B,M
MOV C,B
MVI A,00H

BACK ADD B
DCR C
JNZ BACK

INX H
MOV M,A
RST-5/HLT

41
3341101 MALP GTU

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 04H 2051H 10H

42
3341101 MALP GTU

PROGRAM-18
AIM: Develop/Execute an Assembly language programmed to sort given array of ten bytes in
descending order.

ALGORITHM:

1) Initialize memory pointer at location 2050h by HL register pair


2) Initialize register C as a counter for number of data
3) Reset register D to use as a indicator
4) Get first value in accumulator
5) Compare value of accumulator with content of next memory location
Increment negative number count.
6) If A<content of next memory location, exchange contents, set indicator End
program.
7) Decrements register C and repeat steps 5 and 6 until register C
becomes zero.
8) If indicator (Register D) is set in step 6, repeat step 1 to 7 else stop
9) End program.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE
MVI B,05H

LOOP LXI H,2050H

MVI C,04H

BACK MOV A,M


INX H
CMP M
JNC NEXT

MOV D,M
MOV M,A

43
3341101 MALP GTU

DCX H
MOV M,D
INX H
NEXT DCR C
JNZ BACK

DCR B
JNZ LOOP

RST-5/HLT

RESULT:

INPUT OUTPUT
REG. / MEM. REG. / MEM.
DATA DATA
LOCATION LOCATION
2050H 05 2050H 09
2051 08 2051 08
2052 06 2052 06
2053 09 2053 05
2054 04 2054 04

44
3341101 MALP GTU

Q-1 Develop/Execute an Assembly language programmed to arrange 5-block of data in

Ascending order.

45
3341101 MALP GTU

PROGRAM-19
AIM: Write & Execute program to alternatively blink LEDs connected on Port –B of 8255 at an
interval of 0.1 second. Draw Interface diagram.

Introduction:
The programmable peripheral interface (PPI) IC-8255 is widely used parallel input output
device. It can be programmed to transfer data under various conditions. It has three 8 bit ports
named as Port A, Port B & Port C. Pin diagram of IC-8255 is as shown in the Fig. 1 and block
diagram is as shown in the Fig. 2

Fig. 1 Pin diagram of 8255A

46
3341101 MALP GTU

Fig. 2 Block diagram of 8255A

In this experiment, we will understand mode 0 that is simple input output mode Control word
format is shown in the Fig. 3
In simple I/O mode,
 Outputs are latched
 Inputs are not latched
 Ports do not have handshaking or interrupt facility
 Port A,B & C can be used as an input or output port

Depending upon required operation, control word is decided from the specified format & written
into control register. Port A, Port B, Port C & control register (CR) can be selected with chip
select signal and Address lines A0, A1.

47
3341101 MALP GTU

Fig. 3 Control word format

Control word for Mode 0, Port A, B & C output port:

D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 0 0 0 0 0 = 80H

Addresses of 8255 for Microprocessor Kit:

PORT A: 00h
PORT B: 01h
PORT C: 02h
Control Word: 03h

48
3341101 MALP GTU

Procedure:
 Connect your LED/seven segment card with 8085 kit connector CN4
 Connect power supply with the microprocessor kit & switch on the unit
 Enter software code and execute program
 Observe Flashing of LEDs
 If you have not prepared card, measure voltage carefully
 Change the delay and execute program again

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE

49
3341101 MALP GTU

50
3341101 MALP GTU

PROGRAM-20
AIM: Develop/Execute an Assembly language programmed for 8279 to Interface keypad and
display on 7-segment LED.

Introduction:
The INTEL 8279 is specially developed for interfacing keyboard and display devices to
8085/8086/8088 microprocessor based system. The important features of 8279 are,

 Simultaneous keyboard and display operations.


 Scanned keyboard mode.

 Scanned sensor mode.

 8-character keyboard FIFO.

 1 6-character display.

 Right or left entry 1 6-byte display RAM.

 Programmable scan timing.

Block diagram of 8279:

51
3341101 MALP GTU

The four major sections of 8279 are keyboard, scan, display and CPU interface.

(1) Keyboard section:


 The keyboard section consists of eight return lines RL0 - RL7 that can be used to form
the columns of a keyboard matrix.

 It has two additional inputs: shift and control/strobe. The keys are automatically
debounced.

 The two operating modes of keyboard section are 2-key lockout and N-key rollover.

 In the 2-key lockout mode, if two keys are pressed simultaneously, only the first key is
recognized.

 In the N-key rollover mode simultaneous keys are recognized and their codes are stored
in FIFO.

 The keyboard sections also have an 8 x 8 FIFO (First in First Out) RAM.

52
3341101 MALP GTU

 The FIFO can store eight key codes in the scan keyboard mode. The status of the shift
key and control key are also stored along with key code. The 8279 generate an interrupt
signal when there is an entry in FIFO. The format of key code entry in FIFO for scan
keyboard mode is,

 In sensor matrix mode the condition (i.e., open/close status) of 64 switches is stored in
FIFO RAM. If the condition of any of the switches changes then the 8279 asserts IRQ as
high to interrupt the processor.

Display section:
 The display section has eight output lines divided into two groups A0-A3 and B0-B3.
 The output lines can be used either as a single group of eight lines or as two groups of
four lines, in conjunction with the scan lines for a multiplexed display.

 The output lines are connected to the anodes through driver transistor in case of common
cathode 7-segment LEDs.

 The cathodes are connected to scan lines through driver transistors.

 The display can be blanked by BD (low) line.

 The display section consists of 16 x 8 display RAM. The CPU can read from or write into
any location of the display RAM.

Scan section:
 The scan section has a scan counter and four scan lines, SL0 to SL3.
 In decoded scan mode, the output of scan lines will be similar to a 2-to-4 decoder.

 In encoded scan mode, the output of scan lines will be binary count, and so an external
decoder should be used to convert the binary count to decoded output.

 The scan lines are common for keyboard and display.

 The scan lines are used to form the rows of a matrix keyboard and also connected to digit
drivers of a multiplexed display, to turn ON/OFF.

53
3341101 MALP GTU

CPU interface section:


 The CPU interface section takes care of data transfer between 8279 and the processor.
 This section has eight bidirectional data lines DB0 to DB7 for data transfer between 8279
and CPU.

 It requires two internal address A =0 for selecting data buffer and A = 1 for selecting
control register of8279.

 The control signals WR (low), RD (low), CS (low) and A0 are used for read/write to
8279.

 It has an interrupt request line IRQ, for interrupt driven data transfer with processor.

 The 8279 require an internal clock frequency of 100 kHz. This can be obtained by
dividing the input clock by an internal prescaler.

 The RESET signal sets the 8279 in 16-character display with two -key lockout keyboard
modes.

Programming the 8279:


 The 8279 can be programmed to perform various functions through eight command
words.

In a microprocessor b system, when keyboard and 7-segment LED display is interfaced using
ports or latches then the processor has to carry the following task.
 Keyboard scanning
 Key debouncing

 Key code generation

 Sending display code to LED

 Display refreshing

Interfacing 8279 with 8085 processor:


 A typical Hex keyboard and 7-segment LED display interfacing circuit using 8279 is
shown.

54
3341101 MALP GTU

 The circuit can be used in 8085 microprocessor system and consist of 16 numbers of hex-
keys and 6 numbers of 7-segment LEDs.

 The 7-segment LEDs can be used to display six digit alphanumeric character.

 The 8279 can be either memory mapped or I/O mapped in the system. In the circuit
shown is the 8279 is I/O mapped.

 The address line A0 of the system is used as A0 of 8279.

 The clock signal for 8279 is obtained by dividing the output clock signal of 8085 by a
clock divider circuit.

 The chip select signal is obtained from the I/O address decoder of the 8085 system. The
chip select signals for I/O mapped devices are generated by using a 3-to-8 decoder.

 The address lines A4, A5 and A6 are used as input to decoder.

 The address line A7 and the control signal IO/M (low) are used as enable for decoder.

55
3341101 MALP GTU

 The chip select signal IOCS-3 is used to select 8279.

 The I/O addresses of the internal devices of 8279 are shown in table.

 The circuit has 6 numbers of 7-segment LEDs and so the 8279 has to be programmed in
encoded scan. (Because in decoded scan, only 4 numbers of 7-segment LEDs can be
interfaced)

 In encoded scan the output of scan lines will be binary count. Therefore an external, 3-to-
8 decoder is used to decode the scan lines SL0, SL1 and SL2 of 8279 to produce eight
scan lines S0 to S7.

 The decoded scan lines S0 and S1 are common for keyboard and display.

 The decoded scan lines S2 to S5 are used only for display and the decoded scan lines S6
and S7 are not used in the system.

 Anode and Cathode drivers are provided to take care of the current requirement of LEDs.

 The pnp transistors, BC 158 are used as driver transistors.

 The anode drivers are called segment drivers and cathode drivers are called digit drivers.

 The 8279 output the display code for one digit through its output lines (OUT A0 to OUT
A3 and OUT B0 to OUT B3) and send a scan code through, SL0- SL3.

 The display code is inverted by segment drivers and sent to segment bus.

 The scan code is decoded by the decoder and turns ON the corresponding digit driver.
Now one digit of the display character is displayed. After a small interval (10 milli-
second, typical), the display is turned OFF (i.e., display is blanked) and the above process
is repeated for next digit. Thus multiplexed display is performed by 8279.

 The keyboard matrix is- formed using the return lines, RL0 to RL3 of 8279 as columns
and decoded scan lines S0 and S1 as rows.

56
3341101 MALP GTU

 A hex key is placed at the crossing point of each row and column. A key press will short
the row and column. Normally the column and row line will be high.

 During scanning the 8279 will output binary count on SL0 to SL3, which is decoded by
decoder to make a row as zero. When a row is zero the 8279 reads the columns. If there is
a key press then the corresponding column will be zero.

 If 8279 detects a key press then it waits for debounce time and again read the columns to
generate key code.

 In encoded scan keyboard mode, the 8279 stores an 8-bit code for each valid key press.
The key code consist of the binary value of the column and row in which the key is found
and the status of shift and control key.

 After a scan time, the next row is made zero and the above process is repeated and so on. Thus 8279 continuously scan
the keyboard.

MEMORY HEX
LABEL MNEMONICS COMMENT
LOCATION CODE

57
3341101 MALP GTU

58

You might also like