1.Write a program in 8086 to find out
maxium of N numbers
Program:
OUTPUT 2500AD
ORG 2000H
MES1:
DB 0AH,0DH,'ENTER THE VALUE'
LEA AX,MES1
CALL FAR 0FE00:0031H
CALL FAR 0FE00:0013H
CALL FAR 0FE00:00C7H
MOV BL,AL
MOV CL,AL
MOV CH,00H
MOV SI,2200H
IN:
CALL FAR 0FE00:0031H
CALL FAR 0FE00:00C7H
MOV [SI],AL
INC SI
DEC CL
JNZ IN
MOV SI,2200H
MOV CL,BL
B1:
MOV AL,[SI]
INC SI
LOOP B1
MOV SI,2200H
MOV CL,BL
DEC CL
MOV AL,[SI]
BACK:
INC SI
CMP AL,[SI]
JNC NEXT
MOV AL,[SI]
NEXT:
LOOP BACK
CALL FAR 0FE00:0031H
CALL FAR 0FE00:0052H
HLT
2.Arranging
set of a number in ascending order
Program:
OUTPUT 2500AD
ORG 2000H
M: CALL
FAR 0FE00:0031H
M1: DB
10,13,'ENTER N VALUE',00H
LEA AX,M1
CALL FAR 0FE00:0013H
CALL FAR 0FE00:0031H
CALL FAR 0FE00:00C7H
MOV DL,AL
MOV BL,AL
MOV DH,00H
MOV CL,AL
MOV CH,00H
MOV SI,2200H
C1: CALL FAR
0FE00:0031H
CALL FAR 0FE00:00C7H
MOV [SI],AL
INC SI
LOOP L1
MOV SI,2200H
L1: DEC DL
MOV CL,DL
MOV AL,[SI]
L2: INC SI
CMP AL,[SI]
JC L3
XCHG AL,[SI]
L3: LOOP L2
SUB SI,DX
MOV [SI],AL
INC SI
CMP DL,01H
JNZ L1
MOV SI,2200H
MOV CX,BX
L4: MOV AL,[SI]
CALL FAR 0FE00:0031H
CALL FAR 0FE00:0052H
INC SI
LOOP L4
HLT
3.
Conversion of HEX to BCD
Program:
OUTPUT 2500AD
ORG 2000H
M: CALL
FAR 0FE00:0031H
M1: DB
10,13,'ENTER 2 DIGIT HEX VALUE',00H
M2: DB
10,13,'THE BCD IS:',00H
LEA AX,M1
CALL FAR 0FE00:0013H
CALL FAR 0FE00:00E0H
MOV AH,00H
MOV BL,64H
DIV BL
MOV DL,AL
MOV AL,AH
MOV AH,00H
MOV BL,0AH
DIV BL
SHL AL
SHL AL
SHL AL
SHL AL
OR AL,AH
MOV AH,DL
MOV BX,AX
CALL FAR 0FE00:0031H
LEA AX,M2
CALL FAR 0FE00:0013H
MOV AX,BX
CALL FAR 0FE00:006AH
JMP M
RET
4. To
check the given number is prime or not?
Program:
OUTPUT 2500AD
ORG 2000H
M1: DB
10,13,' ENTER A NUMBER : ',00H
LEA AX,M1
CALL FAR 0FE00:0013H
CALL FAR 0FE00:00C7H
MOV BL,AL
MOV CH,AL
MOV CL,AL
MOV AH,00H
DEC CL
DEC CL
MOV BH,02H
L1: DIV BH
CMP AH,00H
JE L2
INC BH
MOV AL,CH
MOV AH,00H
DEC CL
JNZ L1
CALL FAR 0FE00:0031H
M2: DB
10,13,' PRIME NUMBER ',00H
LEA AX,M2
CALL FAR 0FE00:0013H
JMP L3
L2: CALL FAR
0FE00:0031H
M3: DB
10,13,' NOT PRIME ',00H
LEA AX,M3
CALL FAR 0FE00:0013H
L3: RET
5. To
find out the Fibonacci series
Program:
OUTPUT 2500AD
ORG 2000H
CALL FAR 0FE00:0031H
MOV AX,0000H
MES1: DB 10,13,'ENTER
THE N VALUE : ',00H
LEA DX,MES1
MOV AX,DX
CALL FAR 0FE00:0013H
CALL FAR 0FE00:00C7H
MOV CL,AL
MOV CH,00H
MOV AL,00H
CALL FAR 0FE00:0031H
CALL FAR 0FE00:0052H
MOV AL,00H
MOV BL,01H
DEC CL
LAB: XCHG AL,BL
ADD AL,BL
CALL FAR 0FE00:0031H
CALL FAR 0FE00:0052H
DEC CL
JNZ LAB
RET
6. Write
a program to search an element in any search method
Program:
OUTPUT 2500AD
ORG 2000H
CALL FAR
0FE00:0031H
CALL FAR
0FE00:00C7H
MOV SI,2200H
MOV BL,AL
MOV CH,00H
MOV CL,AL
CALL FAR
0FE00:0031H
L1: CALL FAR 0FE00:0031H
CALL FAR
0FE00:00C7H
MOV [SI],AL
INC SI
LOOP L1
MOV CH,BL
DEC BL
L4: MOV SI,2200H
MOV CL,BL
L3: MOV AL,[SI]
MOV DI,SI
INC DI
CMP AL,[DI]
JL L2
MOV DL,[DI]
XCHG [DI],AL
XCHG [SI],DL
MOV SI,DI
MOV DL,[DI]
MOV [SI],DL
DEC SI
L2: INC SI
DEC CL
JNZ
L3
DEC CH
JNZ L4
MOV SI,2200H
INC BL
MOV CL,BL
L5: MOV AL,[SI]
CALL FAR
0FE00:0031H
CALL FAR
0FE00:0031H
CALL FAR
0FE00:0052H
INC SI
DEC BL
JNZ L5
RET
7. Write
a program in 8086 Alp to run the stepped motor in different speeds
Program:
OUTPUT 2500AD
ORG 2000H
MOV AX,0000H
;Initialise Segment
MOV
ES,AX
;Registers
MOV DX,0FFE6H
;Initialise
MOV
AL,80H
;all 8255 Ports as o/p
OUT DX,AL
CALL FAR 0FE00:01EDH
JMP SHORT START
MES1:
DB 0AH,0DH,'ENTER DIRECTION'
DB
0AH,0DH,'A-ANTICLOCKWISE C-CLOCKWISE',00H
START:
LEA
DX,MES1
;Display message
MOV AX,DX
;on LCD or Console
CALL FAR 0FE00:0013H
GET:
CALL FAR 0FE00:00A9H ;Wait for user entry
CMP
AL,41H
;If key ='A',
JE
ANTI
;rotate anti-clockwise
CMP
AL,43H
;If key = 'C'
JE
CLO
;rotate clockwise
JMP SHORT
GET ;Accept valid
key only
CLO:
CALL COMMON
R1:
OUT DX,AL
CALL
DELAY
;Introduce delay
RCR
AL,1
;Rotate bits in
JMP
SHORT R1 ;data byte
right & repeat
ANTI:
CALL COMMON
R2:
OUT DX,AL
CALL DELAY
RCL
AL,1
;Rotate bits
JMP SHORT R2
;left & repeat
COMMON:
CALL FAR 0FE00:0031H
CALL FAR 0FE00:00H
MOV
AL,11H
;Output value
MOV DX,0FFE0H ;to
Port A
RET
DELAY:
MOV
CX,800H
;Delay routine
SS:
LOOP SS
RET
END
8.Write a
program to stimulate TLC(Traffic Light Controller) using 8086
Program:
OUTPUT 2500AD
ORG 2000H
START:
MOV
AL,80H
; Initialisation of 8255 Mode 0
MOV DX,0FFE6H
OUT
DX,AL
; All ports as o/p ports
AGAIN:
MOV
SI,2038H
; Table of port values
NEXTST: MOV
AL,[SI]
MOV DX,0FFE0H
OUT
DX,AL
; PortA value
INC SI
ADD DX,2
MOV AL,[SI]
OUT
DX,AL
; PortB value
INC SI
ADD DX,2
MOV AL,[SI]
OUT
DX,AL
; PortC value
INC SI
CALL
DELAY
; Calling Delay routine
CMP
SI,2056H
; Checking for the end of the data values
JNZ NEXTST
JMP AGAIN
DELAY:
MOV
CX,0FFH
; Delay routine
DLY5:
PUSH CX
MOV CX,03FFH
DLY10: NOP
LOOP DLY10
POP CX
LOOP DLY5
RET
ORG 2038H
PORTVALUES: DB
10H,81H,7AH
; State 1
DB
44H,44H,0F0H
; All ambers ON
DB 08H,11H,0E5H
;
State 2
DB
44H,44H,0F0H
; All ambers ON
DB
81H,10H,0DAH
; State 3
DB
44H,44H,0F0H
; All ambers ON
DB
11H,08H,0B5H
; State 4
DB
44H,44H,0F0H
; All ambers ON
DB
88H,88H,00H
; State 5
DB
44H,44H,0F0H
; All ambers ON
DB
00H
; Dummy
9. Write
a program to interface 4 nor of FND 507 to 8086 in multiplexed mode//seven
segment display
Program:
OUTPUT 2500AD
ORG 2000H
MOV AX,0000H
;Initialise segment reg.
MOV DS,AX
MOV DX,FFE6H
;Configure all 8255 ports
MOV
AL,80H
;as
output.
OUT DX,AL
LOOP4: MOV SI,2100H
;Initialise pointer
MOV CL,05H
;set
counter for 5 groups.
LOOP3: MOV
CH,04H
;4 charecters/group
LOOP2: MOV BL,08H
;8
segments/charecter
MOV AL,[SI]
;get
the display code
INC SI
;Increment
pointer
LOOP1: ROL
AL,1
;get
1 data bit
MOV DX,FFE2H
OUT
DX,AL
;o/p
bit to portb
MOV AH,AL
MOV
AL,01H
;o/p
clock to
MOV DX,FFE4H
;shift
register
OUT DX,AL
DEC AL
OUT DX,AL
MOV AL,AH
DEC BL
;all
bits over?
JNZ
LOOP1
;no,continue
DEC
CH
;all
charecters over?
JNZ
LOOP2
;no,continue
CALL DELAY
DEC CL
;all
groups over?
JNZ
LOOP3
;no,continue
JMP SHORT LOOP4
DELAY: PUSH
CX
;delay
subroutine
MOV CX,0
L1: LOOP L1
L2: LOOP L2
POP CX
RET
;Display code table
ORG 2100H
STRING: DB 0FFH,0FFH,0FFH,0FFH
DB 0C6H,086H,0C7H,086H
DB 0BFH,0C0H,0DEH,087H
DB 0BFH,092H,091H,092H
DB 092H,0C8H,086H,087H
END
No comments:
Post a Comment