You are on page 1of 16

SCHOOL OF ENGINEERING SCIENCE AND TECHNOLOGY

DEPARTMENT OF ELECTRICAL, CONTROL, TELECOMMUNICATION AND


COMPUTING.

MICROPROCCESSOR SYSTEMS AND APPLICATIONS B (LAB)

Introduction
The module unit is intended to provide the
trainees with theoretical and practical skills c) Describe data transfer instructions in
for programming
Selection, installation and maintenance of d) Describe the instructions in data
microelectronics, micro-computers and manipulation group
micro e) Describe the input and output instructions
processor based systems. Trainees f) Describe the machine control instructions
undertaking this course will be expected to g) Describe transfer of control instructions
have covered in programming
digital electronics. h) Explain the need and use of assembly
General Objectives directives
By the end of the module unit, the trainee i) Explain various addressing modes
should be able to; j) Write application programs
a) Understand the concepts of a a) Describe the organization of data registers
microprocessor system. b) Explain the operation of machine cycle
b) Program a microprocessor system. Explanation of operation of machine cycle
c) Write and implement microprocessor Description of organization of data registers
programs. Machine Cycle
d) Diagnose faults in microprocessor i. Definition
systems. ii. Fetch
Specific Objectives iii. Decode
By the end of the sub-module unit, the iv. Execute
trainee should be able to: v. Time diagram
a) Describe a machine cycle Instruction format
b) Explain instruction format i. Label
ii. Opcode
iii. Operand
iv. Comment
Writing machine code programs
iii. Running the program i. Machine coding
ii. Inputting a machine code program
LAB1
Ex. NO: 01

DATE:…………………………………
16 BIT ADDITIONS USING ARITHMETIC OPERATION OF 8086 MICROPROCESSOR

AIM:
To write an assembly language program to perform addition of two 16 bit numbers
Using 8086.

APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 2
3. Key board - 1
; PROGRAM FOR ADDITION
; Procedure: Enter the two data in locations 9000 and 9001
; Execute the following and check the result in
; Locations 9002 (LSD) and 9003 (MSD)

8400 BB 00 90 MOV BX, 9000H


8403 8A 07 MOV AL, [BX]
8405 43 INC BX
8406 8A 0F MOV CL, [BX]
8408 43 INC BX
8409 B4 00 MOV AH, 00
840B B5 00 MOV CH, 00
840D 03 C1 ADD AX, CX
840F 89 07 MOV [BX], AX; STORE RESULT
8411 CD 23 INT RSTINT

EXERCISE

1. Write the results.


2. Write the algorithm of this program
3. Write the flow chat of this program

Ex. NO: 02
DATE:…………………………………

; ALP PROGRAM FOR THE SUM OF MEMORY DATA


AIM:
To write an assembly language program to perform addition of MEM data16 Using 8086 processor kit.

APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 2
3. Key board - 1

; Procedure:
; Enter the known data in 16 locations
; From 9000 and execute the program
; Enter 9400 to see the result LSD
; Use INC key to access 9401 which is result MSD
; IF YOU WANT TO ADD 4 OR 5 LOCATIONS ONLY CHANGE BYTE COUNT
8400 BB 00 90 MOV BX, 9000H ; start address of mem block
8403 B1 10 MOV CL,10H ; byte count
8405 B8 00 00 MOV AX,0 ; RESULT = 0 TO START WITH
8408 B6 00 MOV DH,0
840A ADDLOOP1:
840A 8A 17 MOV DL,[BX]
840C 43 INC BX
840D 03 C2 ADD AX,DX
840F FE C9 DEC CL
8411 75 F7 JNZ ADDLOOP1
8413 BB 00 94 MOV BX,9400H ; RESULT LOCATION
8416 89 07 MOV [BX],AX
8418 CD 23 INT RSTINT

Ex. NO: 03
DATE:…………………………………
16 BIT SUBTRACTIONS

AIM:
To write an assembly language program to perform subtraction of two 16 bit
numbers using 8086.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 1
; Procedure:
; Enter the two data in locations 9000 and 9001
; Execute the following and check the result in
; Locations 9002 (LSD) and 9003 (MSD)

8400 BB 00 90 MOV BX,9000H


8403 8A 07 MOV AL,[BX]
8405 43 INC BX
8406 8A 0F MOV CL,[BX]
8408 43 INC BX
8409 B4 00 MOV AH,00
840B B5 00 MOV CH,00
840D 2B C1 SUB AX,CX
840F 89 07 MOV [BX],AX ; STORE RESULT
8411 CD 23 INT RSTINT

1. Write the results.


2. Write the algorithm of this program
3. Write the flow chat of this program

Ex. NO: 04

DATE:…………………………………
AIM:
To write an assembly language program to perform Multiplication of two 16
bit numbers using 8086 trainer kit.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 1
; Procedure: Enter the two data in locations 900
0 and 9001
; Execute the following and check the result in
; Locations 9002 (LSD) and 9003 (MSD)

8400 ORG 8400H


8400 BB 0090 MOV BX,9000H
8403 8A 07 MOV AL,[BX]
8405 43 INC BX
8406 8A 0F MOV CL,[BX]
8408 43 INC BX
8409 B4 00 MOV AH,00
840B BA 0000 MOV DX,00
840E ADDLOOP:
840E 03 D0 ADD DX,AX
8410 FE C9 DEC CL
8412 75 FA JNZ ADDLOOP
8414 89 17 MOV [BX],DX ; STORE RESULT
8416 CD 23 INT RSTINT
8418

Ex. NO: 05
DATE:…………………………………
16 BIT DIVISIONS USING ARITHMETIC OPERATION OF 8086 MICROPROCESSOR
AIM:
To write an assembly language program to perform division of two 16 bit
numbers using 8086.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 1
; PROGRAM FOR DIVISION (by repeated subtraction)
; INPUT: Dividend in loc. 9000 (1 byte)
; Divisor in loc. 9001 (1 byte)
; OUTPUT: Quotient in loc 9002
; Reminder in loc 9003
; Procedure: Enter the two data in locations 9000 and 9001
; Execute the following and check the result in
locations 9002 and 9003

8400 BB 00 90 MOV BX,9000H


8403 8A 07 MOV AL,[BX]
8405 43 INC BX
8406 8A 27 MOV AH,[BX]
8408 43 INC BX
8409 B1 00 MOV CL,00
840B B5 00 MOV CH,00
840D LOOP1:
840D 3A C4 CMP AL,AH
840F 72 06 JC OVER1
8411 FE C1 INC CL
8413 2A C4 SUB AL,AH
8415 EB F6 JMP LOOP1
8417 OVER1:
8417 8A E8 MOV CH,AL
8419 88 0F MOV [BX],CL
841B 43 INC BX
841C 88 2F MOV [BX],CH ; STORE RESULT
841E CD 23 INT RSTINT

LAB2
Ex. NO: 06
DATE:…………………………………
Largest & Smallest numbers in an Array
AIM:
To write an assembly language program to finding the max value
Using 8086 trainer kit.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 2
3. Key board - 1
8400 BB 00 90 MOV BX,9000H ; ST. ADD. OF MEMORY BLOCK
8403 B1 05 MOV CL,05H ; BYTE COUNT
8405 B4 00 MOV AH,00 ; MAX VALUE = 00 TO START WITH
8407 CHEKLOOP:
8407 8A 07 MOV AL,[BX]
8409 3A C4 CMP AL,AH
840B 72 02 JC OKAY1
840D 8A E0 MOV AH,AL
840F OKAY1:
840F 43 INC BX
8410 FE C9 DEC CL
8412 75 F3 JNZ CHEKLOOP
8414 BB 00 94 MOV BX,9400H
8417 88 27 MOV [BX],AH
8419 CD 23 INT RSTIN

Ex. NO: 07
DATE:…………………………………
PROGRAM FOR FINDING THE MIN VALUE
AIM:
To write an assembly language program for finding the min value
Using 8086 trainer kit.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 2
3. Key board - 1
; for Minmax 8086 kit
; Program name : EMM6.LST
; INPUT: 5 locations from 9000
; OUTPUT : Min value of locations 9000 to 9004
; stored at 9400

8400 BB 00 90 MOV BX,9000H ; START ADD. OF MEMORY BLOCK


8403 B1 05 MOV CL,05H ; BYTE COUNT
8405 B4 FF MOV AH,FFH ; MIN VALUE = FF TO START WITH
CHEKLOOP:
8407 8A 07 MOV AL,[BX]
8409 3A C4 CMP AL,AH
840B 73 02 JNC OKAY1
840D 8A E0 MOV AH,AL
840F OKAY1:
840F 43 INC BX
8410 FE C9 DEC CL
8412 75 F3 JNZ CHEKLOOP
8414 BB 00 94 MOV BX,9400H
8417 88 27 MOV [BX],AH
8419 CD 23 INT RSTINT
Ex. NO: 07

DATE:…………………………………
PROGRAM FOR COMPARING TWO STRINGS
AIM:
To write an assembly language program for comparing two strings and storing 00 if
strings are not the same and 01 if strings are the same
Using 8086 trainer kit.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 2
3. Key board - 1
; For Minmax 8086 kit
; INPUT: Load 9000H
Load 9100H
; OUTPUT: Store 00 or 01 at 9400H

8400 BB 00 90 MOV BX, 9000H; START ADD. OF STRING1


8403 BE 00 91 MOV SI, 9100H; START ADD. OF STRING2
8406 B1 05 MOV CL, 05H; BYTE COUNT
CHECK1:
8408 8A 07 MOV AL, [BX]
840A 8A 24 MOV AH, [SI]
840C 3A C4 CMP AL, AH
840E 75 0F JNZ OVER1; Not equal it is over
8410 43 INC BX
8411 46 INC SI
8412 FE C9 DEC CL
8414 75 F2 JNZ CHECK1; If equal go to next
8416 B0 01 MOV AL, 01
8418 BB 00 90 MOV BX, 9000H
841B 88 07 MOV [BX], AL

; PROGRAM FOR FACTORIAL VALUE OF A NUMBER (HEX NUMBER)


; INPUT: THE NUMBER IS SET IN LOC. 9000H
; OUTPUT: THE FACTORIAL VALUE IS STORED IN 9001 AND 9002
8400 BB 00 90 MOV BX,9000H
8403 8A 0F MOV CL,[BX]; NUMBER IN CL NOW
8405 43 INC BX
8406 B5 00 MOV CH,00
8408 B8 00 00 MOV AX,00
840B ADDLOOP1:
840B 03 C1 ADD AX,CX
840D FE C9 DEC CL
840F 75 FA JNZ ADDLOOP1
8411 89 07 MOV [BX], AX
8413 CD 23 INT RSTINT
LAB3
EXP.NO: 08
DATE:…………………………………

TRAFFIC LIGHT CONTROLLER


AIM:
To write an assembly language program in 8086 to Traffic light control simulation.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 kit 1
2. Power supply + 5 v dc 2
3. Key board – 1
4. Traffic light controller interface card-1
0000 CODE SEGMENT
ASSUME CS: CODE, DS: CODE, SS: CODE, ES: CODE
= 0046 CMDB8255 EQU 46H
= 0040 PAB8255 EQU 40H
= 0042 PBB8255 EQU 42H
= 0044 PCB8255 EQU 44H
8400 ORG 8400H
8400 B0 80 MOV AL, 80H
8402 E6 46 OUT CMDB8255, AL ; INIT 8255 FOR OUT
8404 START:
8404 B0 0C MOV AL, 0CH
8406 E6 40 OUT PAB8255, AL
8408 B0 93 MOV AL, 93H
840A E6 42 OUT PBB8255, AL
840C B0 09 MOV AL, 09H
840E E6 44 OUT PCB8255, AL; FIRST SET OUTPUT
8410 E8 31 00 CALL DELAY
8413 E8 2E 00 CALL DELAY
8416 B0 14 MOV AL, 14H
8418 E6 40 OUT PAB8255, AL
841A B0 A5 MOV AL, 0A5H
841C E6 42 OUT PBB8255, AL
841E B0 0A MOV AL, 0AH
8420 E6 44 OUT PCB8255, AL ; SECOND SET OUTPUT
8422 E8 1F 00 CALL DELAY
8425 B0 61 MOV AL, 61H
8427 E6 40 OUT PAB8255,AL
8429 B0 68 MOV AL,68H
842B E6 44 OUT PCB8255,AL ; THIRD SET OUTPUT
842D E8 14 00 CALL DELAY
8430 E8 11 00 CALL DELAY
8433 B0 A2 MOV AL,0A2H
8435 E6 40 OUT PAB8255,AL
8437 B0 AB MOV AL,0ABH
8439 E6 42 OUT PBB8255,AL
843B B0 0A MOV AL,0AH
843D E6 44 OUT PCB8255,AL ; FOURTH SET OUTPUT
843F E8 02 00 CALL DELAY
8442 EB C0 JMP START ; BE IN LOOP INFINITELY

8444 DELAY:
8444 B9 FF 04 MOV CX,04FFH
8447 49 LP: DEC CX
8448 74 05 JZ LP1
844A EB FB JMP LP
844C B9 FF 04 MOV CX,04FFH
844F 49 LP1: DEC CX
8450 74 02 JZ EXT
8452 EB FB JMP LP1
8454 C3 EXT: RET

EX. NO: 09
DATE:…………………………………

STEPPER MOTOR INTERFACING


AIM:
To write an assembly language program in 8086 to rotate the motor at
different speeds.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 1
2. Power Supply +5 V, dc, +12 V dc 1
3. Stepper Motor Interface board - 1
4. Stepper Motor -1
THEORY:
A motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a stepwise manner
from one equilibrium position to the next. Two-phase scheme: Any two adjacent
stator windings are energized. There are two magnetic fields active in quadrature
and none of the rotor pole faces can be in direct alignment with the stator poles. A partial
but symmetric alignment of the rotor poles is of course possible.
8400 B0 80 MOV AL,80H
8402 E6 46 OUT CMDB8255,AL
8404 INFLOOP:
8404 B0 0E MOV AL,0EH ; OUTPUT 0E,0D,0B,07 FOR

8406 E6 40 OUT PAB8255,AL; CLOCKWISE ROTATION


8408 E8 17 00 CALL DELAY

840B B0 0D MOV AL,0DH ; OUTPUT 07,0B,0D,0E


840D E6 40 OUT PAB8255,AL ; ANTICLOCKWISE ROT
840F E8 10 00 CALL DELAY

8412 B0 0B MOV AL,0BH


8414 E6 40 OUT PAB8255,AL
8416 E8 09 00 CALL DELAY

8419 B0 07 MOV AL,07H


841B E6 40 OUT PAB8255,AL
841D E8 02 00 CALL DELAY

8420 EB E2 JMP INFLOOP


8422 DELAY:
8422 B8 FF 02 MOV AX,0FFFH; DELAY CONSTANT
8425 DELLOP:
8425 48 DEC AX
8426 75 FD JNZ DELLOP
8428 C3 RET
Ex. NO: 10
DATE:…………………………………

INTERFACING DIGITAL – TO – ANALOG CONVERTER


USING 8086
AIM:
To convert digital inputs into analog outputs and to generate different
Waveforms.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 2. Power Supply +5 V, dc, +12 V dc 1
3. DAC Interface board - 1
THEORY:
Since DAC 0800 is an 8 bit DAC and the output voltage variation is
between –5v and +5v. The output voltage varies in steps of 10/256 = 0.04
(approximately). The digital data input and the corresponding output voltages are
presented in the table. The basic idea behind the generation of waveforms is the
continuous generation of analog output of DAC. With 00 (Hex) as input to DAC2
the analog output is –5v. Similarly with FF H as input, the output is +5v.
Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square
wave of amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to
DAC2. Repeat this sequence again and again. As a result a saw-tooth wave will be
generated at DAC2 output. Output digital data from 00 to FF in constant steps of
01 to DAC2. Output digital data from FF to 00 in constant steps of 01 to DAC2.
0000 CODE SEGMENT
ASSUME CS: CODE, DS: CODE, SS: CODE, ES: CODE

= 0046 CMD8255B EQU 46H


= 0040 PAB8255 EQU 40H; FIRST DAC INPUT
= 0044 PCB8255 EQU 44H; SECOND DAC INPUT

8400 ORG 8400H


8400 B0 80 MOV AL,80H; Initialize ALL OUPUT
8402 E6 46 OUT CMD8255B,AL
8404 INFLOOP:
8404 B0 00 MOV AL,00H
8406 E6 44 OUT PCB8255,AL
8408 E6 40 OUT PAB8255,AL ;OUTPUT VALUES OF 00
840A E8 0B 00 CALL DELAY
840D B0 FF MOV AL,0FFH
840F E6 44 OUT PCB8255,AL
8411 E6 40 OUT PAB8255,AL ;OUTPUT VALUES OF FF

8413 E8 02 00 CALL DELAY


8416 EB EC JMP INFLOOP
8418 DELAY:
8418 B8 FF 1F MOV AX,1FFFH ; DELAY CONSTANT
841B DELLOP:
841B 48 DEC AX
841C 75 FD JNZ DELLOP
841E C3 RET
; PROGRAM TO GENERATE SQ.WAVE AT CH-2 OUTPUT
; EXECUTE THIS PROGRAM AND SEE SQUARE WAVEFORM
; IN PIN-17 (CH-2 OUTPUT) IN OSCILLOSCOPE
; OSCILLOSCOPE GROUND TO BE CONNECTED TO KIT GROUND

= 0066 CMD8253 EQU 66H


= 0060 CH08253 EQU 60H
= 0062 CH18253 EQU 62H
= 0064 CH28253 EQU 64H
8400 ORG 8400H
8400 B0 B6 MOV AL,0B6H
8402 E6 66 OUT CMD8253,AL ; SEL COUNTER-1 MODE 3
8404 B0 0C MOV AL,0CH
8406 E6 64 OUT CH28253,AL ; LSB OF 16 BIT DIVISOR
8408 B0 00 MOV AL,00H
840A E6 64 OUT CH28253,AL ; MSB OF 16 BIT DIVISOR
840C INFLOOP:
840C EB FE JMP INFLOOP
840E CODE ENDS
END

Ex. NO: 11
DATE:…………………………………

Triangular waveform:
AIM:
To write an assembly language program in 8086 to generate triangular waveform as seen
using a CRO.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 1
2. Power Supply +5 V, dc, +12 V dc 1
3. DAC Interface board - 1
; THIS PROGRAM OUTPUTS 00 OR FF INFINITELY TO DAC0800

0000 CODE SEGMENT


ASSUME CS: CODE, DS: CODE, SS: CODE, ES: CODE

= 0046 CMD8255B EQU 46H


= 0040 PAB8255 EQU 40H; FIRST DAC INPUT
= 0044 PCB8255 EQU 44H; SECOND DAC INPUT

8400 ORG 8400H


8400 B0 80 MOV AL,80H; Initialize ALL OUPUT
8402 E6 46 OUT CMD8255B,AL

8404 B0 00 LP2: MOV AL,00H


8406 E6 44 OUT PCB8255,AL
8408 E6 40 OUT PAB8255,AL ;OUTPUT VALUES OF 00
840A 90 NOP
840B 90 NOP
840C B0 FF MOV AL,0FFH
840E E6 44 OUT PCB8255,AL
8410 E6 40 OUT PAB8255,AL ;OUTPUT VALUES OF ff
8412 90 NOP
8413 90 NOP
8414 EB EE JMP LP2
8416 CODE ENDS
END

Ex. NO: 12
DATE:…………………………………

; TO GENERATE RAMP WAVE AT DAC OUTPUT

RAMP waveform:
AIM:
To write an assembly language program in 8086 to generate RAMP waveform as seen
using a CRO.
APPARATUS REQUIRED:
1. Microprocessor kit 8086 1
2. Power Supply +5 V, dc, +12 V dc 1
3. DAC Interface board - 1

0000 CODE SEGMENT


ASSUME CS: CODE, DS: CODE, SS: CODE, ES: CODE

= 0046 CMD8255B EQU 46H


= 0040 PAB8255 EQU 40H; FIRST DAC INPUT
= 0044 PCB8255 EQU 44H; SECOND DAC INPUT

8400 ORG 8400H


8400 B0 80 MOV AL,80H; Initialize ALL OUPUT
8402 E6 46 OUT CMD8255B,AL
8404 LP1:
8404 B0 00 MOV AL,00H
8406 E6 44 LP2: OUT PCB8255,AL
8408 E6 40 OUT PAB8255,AL ;OUTPUT VALUES OF AL

840A FE C0 IN0C AL
840C 3C FF CMP AL,0FFH
840E 75 F6 JNZ LP2
8410 LP3:
8410 E6 40 OUT PAB8255,AL
8412 E6 44 OUT PCB8255,AL
8414 FE C8 DEC AL
8416 3C 00 CMP AL,0
8418 75 F6 JNZ LP3
841A EB E8 JMP LP1
841C CODE ENDS

Ex. NO: 13
DATE:…………………………………
PROGRAM READS ADC, DISPLAYS THE HEX VALUE OF THE INPUT.
AIM:
To write an assembly language program in 8086 displays the hex value of the input
APPARATUS REQUIRED:
1. Microprocessor kit 8086 1
2. Power Supply +5 V, dc, +12 V dc 1
3. ADC Interface board - 1

= 0021 DISINT EQU 21H


= 0046 CMD8255B EQU 46H
= 0040 PAB8255 EQU 40H
= 0042 PBB8255 EQU 42H
= 0044 PCB8255 EQU 44H
= 9E00 DSPBUF EQU 9E00H; address of display buffer
; To display fill the display buffer and use DISINT
8400 ORG 8400H
8400 B0 92 MOV AL,92H; Initialize port A & C as
8402 E6 46 OUT CMD8255B,AL; o/p & B as i/p
8484 B0 07 LP2: MOV AL,07H
8406 E6 44 OUT PCB8255,AL; Select 7th channel
8408 0C 08 OR AL,08
840A E6 44 OUT PCB8255,AL; Set start of conversion
840C 24 F7 AND AL,0F7H ; Reset SOC bit(pulse)
840E 90 NOP
840F E6 44 OUT PCB8255,AL
8411 90 NOP
8412 90 NOP
8413 E4 42 LP1: IN AL,PBB8255; Wait for EOC(end of
8415 24 01 AND AL,01H ; conversion)
8417 74 FA JZ LP1
8419 E4 44 IN AL,PCB8255
841B 0C 10 OR AL,10H
841D E6 44 OUT PCB8255,AL; Set output enable
841F 90 NOP
8420 90 NOP
8421 E4 40 IN AL,PAB8255; Read ADC output
8423 8A D0 MOV DL,AL ; Store temporarily in DL
8425 BE 844E R MOV SI,OFFSET RESMES+8000H
8428 BF 9E00 MOV DI,DSPBUF; Move result message
842B B9 0008 MOV CX,08H; into display buffer
842E F3/ A5 REP MOVSW

8430 8A C2 MOV AL,DL


8432 B1 04 MOV CL,04H ; Get the upper nibble
8434 D2 E8 SHR AL,CL
8436 E8 0025 R CALL ASCII
8439 BF 9E0E MOV DI,DSPBUF+0EH
843C 88 05 MOV [DI],AL
843E 8A C2 MOV AL,DL
8440 24 0F AND AL,0FH
8442 E8 0019 R CALL ASCII
8445 BF 9E0F MOV DI,DSPBUF+0FH
8448 88 05 MOV [DI],AL
844A CD 21 INT DISINT
844C EB B6 JMP LP2; Be in an infinite loop
844E RESMES:
844E 44 69 67 69 74 61 6C DB 'Digital O/P : 00'
20 4F 2F 50 20 3A 20 30 30
845E 04 30 ASCII: ADD AL,30H ; If no. < 0AH,add 30H
8460 3C 3A CMP AL,3AH
8462 72 02 JC RET1
8464 04 07 ADD AL,07H; If no. >= 0AH,add 37H
8466 C3 RET1: RET

EX. NO: 14
DATE:…………………………………
INTERFACING PRGRAMMABLE KEYBOARD AND
DISPLAY CONTROLLER 8279
AIM:
To display the message “2” using Keyboard and Display Controller-8279
APPARATUS REQUIRED:
SL.NO ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 1
2. Power Supply +5 V, dc, +12 V dc 1
3. 8279- Interface board - 1
0000 CODE SEGMENT
ASSUME CS: CODE, DS: CODE, ES: CODE, SS:
CODE
= 0046 CMDB8255 EQU 46H
= 0040 PAB8255 EQU 40H
= 0042 PBB8255 EQU 42H
= 0044 PCB8255 EQU 44H

8400 ORG 8400H


8400 B0 88 MOV AL,88;init 8255forportand
8402 E6 46 OUT CMDB8255,AL ; port C high as output
; Port B and port C low as output
8404 READKEY:
8404 B2 00 MOV DL,0 ;clear E/DL register

8406 B0 F0 MOV AL,0F0H ;output all one's To PC high


8408 E6 44 OUT PCB8255,AL
840A LP:
840A E4 44 IN AL,PCB8255
840C 24 F0 AND AL,0F0H
840E 3C F0 CMP AL,0F0H
8410 75 F8 JNZ LP
8412 E8 8451 R CALL ONEMS
8415 KEYCHK:
8415 E4 44 IN AL,PCB8255
8417 24 F0 AND AL,0F0H
8419 3C F0 CMP AL,0F0H
841B 74 F8 JZ KEYCHK ;wait for key press
841D E8 8451 R CALL ONEMS
8420 B0 7F MOV AL,7FH
8422 B7 04 MOV BH,04H
8424 NXTCOLM:
8424 D0 C0 ROL AL,01 ;scan each column
8426 8A F0 MOV DH,AL ;and wait for the data
8428 E6 44 OUT PCB8255,AL ;in any of the four
842A E4 44 IN AL,PCB8255 ;rows
842C 24 F0 AND AL,0F0H
842E B1 04 MOV CL,04H
8430 NXTROW:
8430 D0 C0 ROL AL,01
8432 73 0E JNC CODEN
8434 FE C2 INC DL ;increment to get
8436 FE C9 DEC CL ;the desired address from
8438 75 F6 JNZ NXTROW ;the lookup table
843A 8A C6 MOV AL,DH
843C FE CF DEC BH
843E 75 E4 JNZ NXTCOLM
8440 EB D3 JMP KEYCHK
8442 CODEN:
8442 8A C2 MOV AL,DL
8444 B6 00 MOV DH,0
8446 BB 845A R MOV BX,OFFSET LOOKUP+8000H
8449 03 DA ADD BX,DX
844B 8A 07 MOV AL,BYTE PTR[BX]
844D E6 42 OUT PBB8255,AL
844F EB B3 JMP READKEY
; delay routine
8451 ONEMS:
8451 50 PUSH AX
8452 B0 FF MOV AL,0FFH
8454 LOP:
8454 FE C8 DEC AL
8456 75 FC JNZ LOP
8458 58 POP AX
8459 C3 RET
845A LOOKUP:
845A 00 04 08 0C 01 05 09 DB 00,4,8,0CH,1,5,9,0BH
0B
8462 02 06 0A 0E 03 07 0B DB 2,6,0AH,0EH,3,7,0BH,0FH
0F

046A CODE ENDS


END
Pre and Post Lab Assignments:
1. List the condition of the flags in the status register after ADD instructions has been executed.
2. List some 8086 instructions which are used for addition and storing of data
3. Write the flowcharts for the above programs
4. Rewrite the algorithm for the above programs
5. Rewrite the program using the full format of ALP using both direct and indirect methods.
6. State some of the addressing modes present in the above program
7. Code the program using the instruction set to obtain the source code
8. Enter and run the code
Tabulate the results before and after the program execution

You might also like