Professional Documents
Culture Documents
TECHNOLOGY
[Type the abstract of the document here. The abstract is typically a short summary of the contents of the
document. Type the abstract of the document here. The abstract is typically a short summary of the
contents of the document.]
ANNA UNIVERSITY
CHENNAI-600 025
DEPARTMENT OF INFORMATION TECHNOLOGY
YEAR / SEM : II YEAR / IV SEM REGULATION : AUC / 2013
Title of Experiments
Page No
3
4
5
6
2
6
11
13
16
17
18
20
23
27
29
STAFF-IN-CHARGE
31
HOD/IT
IT Dept/KLNCE
EX.NO : 1 A
i.Aim:
To perform arithmetic operations using 8086.
Apparatus:
1.Microprocessor kit
2.Power chord
3.Keyboard.
Two Byte Addition:
Algorithm:
1.Initialize carry register CL with 00.Load AH and AL registers with MSB and LSB
of first data respectively. Load BH and BL registers with MSB and LSB of second
data.
2.Add accumulator register content with base register.
3.Check for carry flag.If carry exixts,increment carry register by one,else go to next
step.
4.Store accumulator content to 1500 and 1501 respectively.
5.Store carry register content to 1502 and stop program.
Program:
Address
Opcode
Operand
Label Mnemonics
Comments
MOV CL,00
MOV
AX,0FFFEH
MOV BX,1010H
ADD AX,BX
JNC L1
INC CL
L1
MOV [1500],AX
MOV [1502],CL
HLT
iv.Multibyte Subtraction:
Algorithm:
1. Load SI and DI with first and second data.
2. Clear the carry flag and initialize CL register with no.of data byte.
3. Subtract content of memory pointer by ES:DI from content of memory pointer
by ES:DI along carry bit with DI pointer acts as destination pointer.
4. Update SI and DI register with carry bit DI pointer acting as decrement
counter.If counter !=0 then go to step 4,otherwise go to next step.
5. Stop the program.
Program:
Address
Opcode
Operand
Label
Mnemonics
Comments
MOV SI,2400
MOV
DI,2404
CLC
MOV CL,04
L1
MOV AL,[SI]
SBB[DI],AL
INC SI
INC DI
DEC CL
JNZ L1
HLT
v.8 Bit Multiplication:
Algorithm:
1. Load accumulator(AL) with 1st data and BL with 2nd data.
2. Multiply and store AX content into memory.
3. Stop the program
Program:
Address
Opcode
Operand
Label
Mnemonics Comments
MOV
AL,0AA
MOV
BL,0BB
MUL BL
MOV[3100],
AX
HLT
vi.16 Bit Multiplication:
Algorithm:
1. Load AX with 1st data and multiply 2nd data with AX content.
2. Move MSB in DX & LSB in AX to memory and stop the program.
IT Dept/KLNCE
Program:
Address
Opcode
Operand
Label
Mnemonics
Comments
MOV
AX,0FFFF
MOV
BX,1010
MUL BX
MOV[2902],D
X
MOV[2900],A
X
HLT
Label
Mnemonic Comments
s
MOV
AX,0002
MOV
BL,01
DIV BL
MOV[2300
],AX
HLT
MOV
DX,1232
MOV
CX,1F20
DIV CX
MOV
[1200],AX
MOV[1202
],DX
HLT
Result:
Thus arithmetic operations using 8086 is done and program is executed and output is
verified.
Ex.NO:1.B
; AX and memory
HLT
OBJECT CODES:
Memory Address
Object Codes
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
C7
C0
34
12
F7
D0
89
06
00
14
F4
Mnemonics
MOV AX,1234
NOT AX
MOV [1400],AX
HLT
Object Codes
8B
Mnemonics
MOV AX,[1200]
IT Dept/KLNCE
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C
06
00
12
81
E0
0F
0F
89
06
00
14
F4
AND AX,0F0F
MOV [1400],AX
HLT
Object Codes
Mnemonics
1000
1001
1002
1003
1004
1005
1006
1007
1008
C7
C0
00
00
81
C8
0F
0F
89
MOV AX,0000
OR AX,0F0F
MOV [1100],AX
IT Dept/KLNCE
1009
100A
100B
100C
06
00
11
F4
HLT
;number of elements in CX
;initialise SI to start of array
;decrement CX and check
;if Zero
LOOP LOOP1
MOV [SUM],AX
HLT
OBJECT CODES:
Memory Address
Object Codes
Mnemonics
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C
C7
C1
05
00
C7
C0
00
00
89
C6
03
06
10
MOV CX, 5
MOV AX, 00
MOV SI, AX
LOOP1 : ADD AX,[1100]
IT Dept/KLNCE
10
100D
100E
100F
1010
1011
1012
1013
1014
1015
1016
1017
1018
11
81
C6
02
00
E2
F6
89
06
00
12
F4
ADD SI,2
LOOP LOOP1
MOV [1200],AX
HLT
EX.NO 3
STRING MANIPULATION OPERATIONS USING 8086
Aim:
1. To transfer a block of 10 data word from one memory to another in forward &
reverse direction
2. Block transfer in forward direction:
Algorithm
1. Move source index register with necessary offset address
2. Move destination index register with necessary offset address
3. Load the count value in CX register
4. Move string byte from source to destination address through accumulator
5. Increment the SI & DI registers
6. Decrement CX,if it is zero ,go to next step else step 4
7. Stop the program
Program
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
SI,1500
MOV
DI,1600
MOV
CX,0005
L1
MOV
AX,[SI]
L1
MOV
[DI],AX
INC SI
INC SI
INC DI
IT Dept/KLNCE
11
L2
INC DI
DEC CX
JNZ L1
HLT
12
step
5. Update the SI content to point to the next data & decrement the CX reg
count.Check for zero flag.If not equal to zero go to next step
6. Move the result in AX and carry reg to memory
7. Stop the program
Program
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
CX,0005
MOV
AX,0000
MOV
BX,0000
MOV
SI,1700
CLC
L2
ADC
AX,[SI]
JNZ L1
INC BX
L1
INC SI
INC SI
DEC CX
JNZ L2
MOV[1600
],AX
MOV[1602
],BX
HLT
Even and odd number generation
1. Load count value to CX register
2. Initialize DI register to a address & clear AL reg
3. Load accumulator with 00 for even number generation and 01 for odd number
generation
4. Move the content of accumulator to memory location pointed by DI
5. Add 02 to accumulator . Increment DI register
6. Decrement CX reg . If zero go to next step,else step 4
7. Stop the program
Even number generation
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
IT Dept/KLNCE
13
L1
Label
L1
CX,0005
MOV
DI,1500
MOV
AL,00
MOV
[DI],AL
ADD
AL,02
INC DI
DEC CX
JNZ L1
HLT
Mnemonics Comments
MOV
CX,0005
MOV
DI,1500
MOV
AL,01
MOV
[DI],AL
ADD AL,02
INC DI
DEC CX
JNZ L1
HLT
Aim:
To perform arithmetic operations using 8086.
Apparatus Required:
1.PC with 8086 emulator
14
Mov bx,0013h
Mov cx,0000h
Add ax,bx
Jnc l1
Inc cx
Mov si,1400h
Mov[si],ax
Add si,0002h
Mov [si],cx
Hlt
SAMPLE DATAS:ADDITION
INPUT
Address/Reg
Ax
Bx
CX
Data
004E
00FF
0000
OUTPUT
Address
Ax
Bx
CX
Data
01 4D
OOFF
OOOO
OUTPUT
Address
Ax
Bx
Data
EFF0
2030
16 bit subtraction
Mov ax,0005h
Mov bx,0003h
Mov cx,0000h
sub ax,bx
Jnc l1
Inc cx
Mov si,1400h
Mov[si],ax
Add si,0002h
Mov [si],cx
Hlt
SAMPLE DATAS:SUBTRACTION
INPUT
Address/Reg
Ax
Bx
Data
1020
20 30
IT Dept/KLNCE
15
CX
0000
CX
0001
16 bit Multiplication
Mov ax,1020h
Mov bx,2020h
Mov cx,0000h
Mov si,1400h
Mul bx
Mov [si],ax
Add si,0002h
Mov[si],cx
hlt
SAMPLE DATAS:MULTIPLICATION
INPUT
Address/Reg
Ax
Bx
CX
Data
1020
20 20
0000
OUTPUT
Address
Ax
Bx
CX
DX
Data
0400
2020
0000
0206
16 bit division
Mov ax,1020h
Mov bx,2020h
Mov cx,0000h
Mov si,1400
Div bx
Mov[si],ax
Add si,0002h
Mov[si],cx
hlt
SAMPLE DATAS:DIVISION
INPUT
OUTPUT
IT Dept/KLNCE
16
Address/Reg
Ax
Bx
CX
Data
0025
0005
0000
Address
Ax
Bx
CX
DX
Data
0007
2025
0000
0002
SORTING IN 8086:
org 1000h
mov ax,0505h
L3:mov bx,1400h
L2:mov ax,[bx]
cmp ax,0002h[bx]
jc l1
xchg ax,0002[bx]
mov [bx],ax
L1:add bx,0002h
dec di
jnc L2
mov cl,ch
dec ch
jmp L3
hlt
BLOCK TRANSFER [Forward ] :
mov si,1400h
mov di,1500h
mov cx,0005h
L1:mov ax,[si]
mov [di],ax
add si,0002h
add di,0002h
dec cx
jnz l1
mov [si],1500h
mov [si],ax
hlt
IT Dept/KLNCE
17
AIM:
Memory Address
Object Codes
Mnemonics
1000
1003
1007
100A
100C
100E
1010
1012
1016
C6 C0 80
E6 26
C7 C3 73 10
C7 C6 7F 10
E8 33 00
8A 04
E6 20
E8 4D 00
46
MOV AL,80H
MOV CL,04
MOV AL,[DI]
MOV C0,AL
MOV DX,1010
DEC DX
JNZ 100F
INC DI
LOOP 1007
IT Dept/KLNCE
18
1017
1019
101A
101C
101F
1020
43
E8 27 00
8A 04
E6 22
E8 41 00
46
43
E8 1B 00
JMP 1000
TABLE 09 05 06 0A
Ex.No:8
Memory Address
Object Codes
Mnemonics
1000
1004
1007
1009
100B
100F
1010
1012
1013
1015
1018
C7 C7 18 10
C6 C1 04
8A 05
E6 C0
C7 C2 1010
4A
75 FD
47
E2 F2
E9 E8 FF
09 05 06 0A
MOV DI,1018
MOV CL,04
MOV AL,[DI]
MOV C0,AL
MOV DX,1010
DEC DX
JNZ 100F
INC DI
LOOP 1007
JMP 1000
TABLE 09 05 06 0A
AIM:To run a stepper motor for required angle within 360 which is equivalent to 256
steps
IT Dept/KLNCE
19
Memory Address
Object Codes
Mnemonics
1000
1003
1007
100A
100C
100E
1010
1012
1016
1017
1019
101A
101C
101F
1020
C7 C3 45
C7 C7 20 10
C6 C1 04
8A 05
E6 C0
FE CB
74 OD
C7 C2 10 10
4A
75 FD
47
E2 EE
E9 E4 FF
F4
09 05 06 0A
MOV DI,1018
MOV CL,04
MOV AL,[DI]
MOV C0,AL
MOV DX,1010
DEC DX
JNZ 100F
INC DI
LOOP 1007
JMP 1000
TABLE 09 05 06 0A
AIM:
To run a stepper motor in both forward and reverse direction with delay
APPARATUS REQUIRED:
8086 MP kit, RS 232 cable, Stepper motor interface
Procedure:
Enter the program and execute it after connecting the stepper motor in port1. Execute the
program. Now stepper motor runs in both forward and reverse direction continuously with a
delay
By converting the requiring steps in decimal to hex and entering the hex data at 1001 the
motor rotates for so much steps and stops.
PROGRAM
Memory Address
Object Codes
Mnemonics
IT Dept/KLNCE
20
1000
1003
1007
100A
100C
100E
1011
1014
1018
101B
101D
101F
1022
1025
1028
102A
102C
1030
1031
1033
1034
1036
1037
103B
103C
103E
103F
1043
C6 C3 20
C7 C7 3F10
E8 1B 00
FE CB
75 F5
E8 2A 00
C6 C3 20
C7 C7 43 10
E8 0A 00
FE CB
75 F5
E8 19 00
E9 DB FF
C6 C1 04
8A 05
E6 C0
C7 C2 10 10
4A 75 FD
47
E2 F2
C3
C7 C2 FF FF
4A
75 FD
C3
09 05 06 0A
0A 06 05 09
MOV BL,20
MOV DI,103F
CALL 1025
DEC BL
JNZ 1003
CALL 103B
MOV BL,20
MOV DI,1043
CALL 1025
DEC BL
JNZ 1014
CALL 103B
JMP 1000
MOV CL,04
MOV AL,[DI]
OUT C0,AL
MOV DX,1010
DEC DX
JNZ 1030
INC DI
LOOP 1028
RET
MOV DX,0FFFF
DEC DX
JNZ 103B
RET
FORWARD DATA
REVERSE DATA
RESULT:
EX.NO:9
DIGITAL CLOCK
Aim
To generate a digital clock in 8086 kit.
Store time value in memory location 1500-SECONDS
1501-MINUTES
1502-HOURS
Address
Opcode
Label
Mnemonics
1000
E8 00 60
START
CALL
CONVERT
1003
E8 00 51
CALL
DISPLAY
Comments
IT Dept/KLNCE
21
1006
B0 B0
1008
100A
100C
100E
1010
1012
1014
1015
1016
1017
1018
101A
101C
101E
1020
1022
1024
1026
E6 16
B1 07
B0 88
E6 14
B0 80
E6 14
90
90
90
90
E4 14
8A D0
E4 14
0A C2
75 F2
FE C9
75 E6
BE 15 00
1029
102B
102D
102F
1031
1033
1035
1037
1038
103A
103C
103E
1040
1042
1044
1046
1047
1049
104B
104D
104F
1051
8A 04
FE C0
88 04
3C 3C
75 CD
B0 00
88 04
46
8A 04
FE C0
88 04
3C 3C
75 BE
B0 00
88 04
46
8A 04
FE C0
88 04
3C 18
75 AF
B0 00
DELAY:
S2:
S1:
MOV
AL,0B0H
OUT 16H,AL
MOV CL,07H
MOV AL,88H
OUT 14H,AL
MOV A;,80H
OUT 14H,AL
NOP
NOP
NOP
NOP
IN AL,14H
MOV DL,AL
IN AL,14H
OR AL,DL
JNZ S1
DEC CL
JNZ S2
MOV
SI,1500H
MOV AL,[SI]
INC AL
MOV [SI],AL
CMP AL,3CH
JNZ START
MOV AL,00H
MOV [SI],AL
INC SI
MOV AL,[SI]
INC AL
MOV [SI],AL
CMP AL,3CH
JNZ START
MOV AL,0
MOV [SI],AL
INC SI
MOV AL,[SI]
INC AL
MOV [SI],AL
CMP AL,18H
JNZ START
MOV AL,0
IT Dept/KLNCE
22
1053
1055
88 04
EB A9
1057
B4 06
1059
BA 1600
105C
B5 01
105E
1060
1062
B1 00
CD 05
C3
1063
BE 1500
1066
BB 1608
1069
106B
B0 24
88 07
106D
8A 04
106F
1071
B4 00
B6 0A
1073
1075
1078
1079
F6 F6
80 C4 30
4B
88 27
107B
107C
107E
4B
04 30
88 07
1080
1081
4B
B0 3A
1083
88 07
1085
1086
MOV [SI],AL
JMP START
DISPLAY:
MOV
AH,06H
MOV
DX,1600H
MOV
CH,01H
MOV CL,0H
INT 5
RET
CONVERT:
4B
MOV
SI,1500H
MOV
BX,1608H
MOV AL,24H
MOV
[BX],AL
MOV AL[SI]
;SECONDS
MOV AH,0
MOV
DH,0AH
DIV DH
ADD AH,30H
DEC BX
MOV
[BX],AL
DEC BX
ADD L,30H
MOV
[BX]AL
DEC BX
MOV
AL,3AH
MOV
[BX],AL
DEC BX
46
INC SI
IT Dept/KLNCE
23
1087
1089
108B
8A 04
B4 00
B6 0A
108D
108F
1092
F6 F6
80 C4 30
88 27
1094
1095
1097
4B
04 30
88 07
1099
109A
4B
B0 3A
109C
88 07
109E
4B
109F
46
10A0
10A2
10A4
8A 04
B4 00
B6 0A
10A6
10A8
10AB
F6 F6
80 C4 30
88 27
10AD
10AE
10B0
4B
04 30
88 07
10B2
C3
10B3
10B5
E4 02
24 FF
10B7
3C F0
10B9
75 F8
;MINUTES
MOV AL,[SI]
MOV AH,0
MOV
DH,0AH
DIV DH
ADD AH,30H
MOV
[BX],AH
DEC BX
ADD AL,30H
MOV
[BX],AL
DEC BX
MOV
AL,3AH
MOV
[BX],AL
DEC BX
INC SI
;HOURS
MOV AL,[SI]
MOV AH,0
MOV
DH,0AH
DIV DH
ADD AH,30H
MOV
[BX],AH
DEC BX
ADD AL,30H
MOV
[BX],AL
RET
GETC:
IN AL,02H
AND
AL,0FFH
CMP
AL,0F0H
JNE GETC
END
IT Dept/KLNCE
24
Result:
EX.NO:10
Aim
A.To display a letter in display interfacing with 8279
B.To roll the display in 8279 using 8086
i)TO DISPLAY A IN THE FIRST DIGIT:
Program
Address
Opcode
Label
Mnemonics
Operand
1000
B0 00
MOV AL,00
1002
E6 C2
OUT C2,AL
1004
B0 CC
MOV
AL,0CC
1006
E6 C2
OUT C2,AL
1008
B0 90
MOV AL,90
100A
E6 C2
OUT C2,AL
100C
B0 88
MOV AL,88
100E
E6 C0
OUT C0,AL
1010
B0 FF
MOV AL,0FF
1012
B9 05 00
MOV
CX,0005
1015
E6 C0
NEXT
OUT C0,AL
1017
E2 FC
LOOP NEXT
1019
F4
HLT
II) ROLLING DISPLAY
PROGRAM:
Address
Opcode
Operand
1000
BE 00 12
1003
B9 0F
1006
1008
100A
100C
100E
1010
1012
1014
B0 10
E6 C2
B0 CC
B0 90
E6 C2
E6 C2
8A 04
E6 C0
Label
Mnemonics
START
MOV SI,1200
MOV
CX,000F
MOV AL,10
OUT C2,AL
MOV AL,CC
OUT C2,AL
MOV AL,90
OUT C2,AL
MOV AL,[SI]
OUT C0,AL
NEXT
Comments
Comments
IT Dept/KLNCE
25
1016
E8 E7 04
1019
101A
101C
46
E2 F6
EB E2
1500
BA,FF,A0
DELAY
1503
1504
1506
4A
74,FD
C3
LOOP1
1200
FF,FF,FF,FF
FF,FF,FF,FF
98,68,7C,C8
FF,1C,29,FF
Ex.No :12a.
CALL
DELAY
INC SI
LOOP NEXT
JMP START
MOV
DX,A0FF
DEC DX
JNZ LOOP1
RET
AIM:
Connect the two serial ports with RS232C Cable. First make the receiver ready and
Then execute the program at transmitter end.
EXAMPLE:
Data in Transmitter :41H
Receiver [1500]:41H
Memory Address
Object Codes
Mnemonics
IT Dept/KLNCE
26
1000
1002
1004
1006
1008
100A
100C
100E
1010
1012
1014
1016
1018
101A
101C
101E
B0 36
E6 CE
B0 10
E6 C8
B0 00
E6 C8
B0 4E
E6 C2
B0 37
E6 C2
E4 C2
24 04
74 FA
B0 41
E6 C0
CD 02
MOV AL,36
OUT CE,AL
MOV AL,10
OUT C8,AL
MOV AL,00
OUT C8,AL
MOV AL,4E
OUT C2,AL
MOV AL,37
OUT C2,AL
LOOP1: IN AL,C2
AND AL,04
JZ LOOP1
MOV AL,41
OUT C0,AL
INT2
Receiver end
Memory Address
Object Codes
1200
1202
1204
1206
1208
120A
120C
120E
1210
1212
1214
1216
1218
121A
121C
B0 36
E6 CE
B0 10
E6 C8
B0 00
E6 C8
B0 4E
E6 C2
B0 37
E6 C2
E4 C2
24 04
74 FA
B0 41
E6 C0
Mnemonics
MOV AL,36
OUT CE,AL
MOV AL,10
OUT C8,AL
MOV AL,00
OUT C8,AL
MOV AL,4E
OUT C2,AL
MOV AL,37
OUT C2,AL
LOOP 2: IN AL,C2
AND AL,02
JZ LOOP2
IN AL,C0
MOV BX,1500
IT Dept/KLNCE
27
121E
CD 02
MOV [BX],AL
INT2
RESULT:
______________________________________
Ex.No:12 b.
Memory Address
Object Codes
Mnemonics
IT Dept/KLNCE
28
1000
1003
1005
1007
1009
100B
BE 00
B0 90
E6 C6
E4 C0
88 04
F4
MOV SI,1500H
MOV AL,90H
OUT C6,AL
IN AL,C0
MOV [SI],AL
HLT
AIM:
To initialize Port A as an input port and port B as output port in mode 0
APPARATUS REQUIRED:
8086 MP kit, 50 core cable, 8255 kit
Procedure:
1. Connect the 8086 kit with 8255 using core cable.
5. Set a known data in SPDT switch
6. Type and execute the program in 8086 kit
7. Verify visually that the data output at the LEDs is same as that set by the SPDT switch
settings
OBJECT CODES:To initialize PORT A as input port and port B as output port in mode-0
Memory Address
Object Codes
Mnemonics
1000
1003
1005
1007
1009
100B
BE 00
B0 90
E6 C6
E4 C0
88 04
F4
ORG 1000H
MOV AL,90H
OUT C6,AL
IN AL,C0
OUT C2,AL
HLT
AIM:
To initialize Port C as an Output port and port B in mode 0 and to explain the BIT
set and reset features of PORT C
APPARATUS REQUIRED:
8086 MP kit, 50 core cable, 8255 kit
IT Dept/KLNCE
29
PROCEDURE:
1. Connect the 8086 kit with 8255 using core cable.
8. Enter the program starting from user RAM address 1000H
9. Type and execute the program in 8086 kit
10. Verify the result at LEDS after changing the datas
OBJECT CODES:To initialize PORT A as input port and port B as output port in mode-0
Memory Address
Object Codes
Mnemonics
1000
1002
1004
1006
1008
100A
100B
100C
B0 80
E6 C6
B0 01
E6 C4
B0 07
E6 C6
F4
ORG 1000H
MOV AL,80
OUT C6,AL
MOV AL,01
OUT C4,AL
MOV AL,07
OUT C6,AL
HLT
Ex.No 13.i.
Aim:
To design an ADC converting using 8086
Algorithm:
1. Select the channel and insert the ALE by sending corresponding data C8
2. Assert the SOC(Start of Conversion) signal high and provide some delay
3. After the delay make the SOC signal low and wait for the EOC(End of
Conversion)
4. Read the converted digital data and stores it in the memory location.
Procedure:
Place jumper J2 in A position
Place jumper J5 in A position
Enter and execute the program
Vary the analog input (using trimpot ) and verify the digital data displayed with
that data stored in memory location 1100H
Program:
Address
Opcode/Oper Label
Mnemonics
Comments
and
1000
C6 C0 10
MOV AL,10
IT Dept/KLNCE
30
1003
1005
1008
100A
100D
100F
1012
1015
1018
101B
101D
101F
1022
1025
1027
1029
E6 C8
C6 C0 18
E8 C8
E6 C0 01
E6 D0
C6 C0 00
C6 C0 00
C6 C0 00
C6 C0 00
E6 D0
E4 D8
80 E0 01
80 E0 01
75 F6
E4 C0
C7 C3 00 11
102D
88 07
102F
F4
LOOP
OUT C8,AL
MOV AL,18
OUT C8,AL
MOV AL,01
OUT D0,AL
MOV AL,00
MOV AL,00
MOV AL,00
MOV AL,00
OUT D0,AL
IN AL,D8
AND AL,01
CMP AL,01
JNZ LOOP
IN AL,C0H
MOV
BX,1100
MOV
[BX],AL
HLT
Result:
Ex.No 13.ii. INTERFACING & PROGRAMMING WITH DAC
Aim
To generate the square wave at the output of DAC 2.
Algorithm
1. Initialize AL and move 00 to AL
2. The accumualator content of AL is then sent to C8
3. After calling 1010 the content of FF is moved to accumulator content AL
4. Again the content of AL is sent to C8 and 1010 is called
5. The 05FF is moved to the CX and looped the content to1013
6. Return the program
Program
Address
Opcode
Mnemonics
Comments
1000
1002
1004
1007
1009
100B
100E
1010
C6 C0 00
E6 C8
E8 09 00
B0 FF
E6 C8
E8 02 00
EB F0
B FF 05
MOV AL,00
OUT C8,AL
CALL 1010
MOV AL,FF
OUT C8,AL
CALL 1010
JMP 1000
MOV CX,05FF
IT Dept/KLNCE
31
1013
1015
E2 FE
C3
LOOP 1013
RET
32
1014
EB EA
JMP L2
JUMP TO L2
EX.NO 14
ARITHMETIC OPERATIONS USIGN 8051
AIM
To write an ALP to perform
Add 2 given 8 bit numbers
Subtract 2 given 8 bit numbers
Multiply 2 8 bit numbers
Divide 2 8 bit numbers
Array addition
APPARATUS REQUIRED
1.8051 Microprocessor kit
2.Eliminator
Algorithm
8 Bit Addition
1.Load the first data into accumulator & 2nd data in RO register.
2.Initialize the carry register(Rl) with OoH and initialize the data pointer with
address of the result location.
3.Add the accumulator content with the second data.
4.Check for carry flag if carry exits then increment carry register by one otherwise
5. go to next step.
6.Store the accumulator and Rl content into memory whose address pointed by
data pointer.
7.Stop the program.
Program
Address
Opcodes
L1
Mnemonics
MOV R1,#00H
MOV A,#FEH
MOV R0,#10H
MOV DPTR,#4500
ADD A,R0
JNC L1
INC R1
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
Comments
IT Dept/KLNCE
33
L2
SJMP L2
8 BIT SUBTRACTION
ALGORTITHM
1.Load the first data into accumulator & 2nd data in r0 register
2.Initialize the carry register (R1) with 00H and initialize the data pointer with
address of the result location
3.Subtract the second data from accumulator content
4.Check for carry flag if carry exists then increment carry register by one by one
otherwise go to next step
5.Store the accumulator and R1 content into memory whose address pointed by data
pointer
6.Stop the program
Address
Opcode
Operand
Label
L1
L2
Mnemonics
Comments
MOV R1,#00H
MOV A,#FEH
MOV R0,#10H
MOV DPTR,#4500
SUB A,R0
JNC L1
INC R1
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
SJMP L2
8 BIT MULTIPLICATION
ALGORITHM
1. Load the accumulator and B register with first and second data
2. Multiply the B register with content of A register
3. Initialize the data pointer with address of the result location
4. Store the accumulator content into the memory location pointed by
the data pointer and then increment data pointer by one
5. Move the B register content to A
6. Store A's content into memory location pointed by DPTR
7. Stop the program
Program
Address Opcode Operand
Label
Mnemonics
MOV A,#05H
MOV B,#03H
MOV DPTR,#4500
Comments
IT Dept/KLNCE
34
L2
MUL A,B
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
SJMP L2
Opcode
Operand
Label
L1
Mnemonics
MOV A,#05H
MOV B,#03H
MOV DPTR,#4500
DIV A,B
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
SJMP L1
Comments
35
6. Increment tha data pointer by one to point to the next data byte
7. Decrement the count register (R0) by one and check whether the
decremented value equal to zero or not,if not go to step 4 else go
to next step
8. Store the content of sum register(B) and carry (R1) into the 2
consecutive memory locations on pointed by data pointer
9. Stop the program
Program:Array addition
Address
Opcode
Operand Label Mnemonics
Comments
MOV DPTR,#4700
MOV R0,#05H
MOV R2,#00H
MOV R1,#00H
L2
MOVX A,@DPTR
ADD A,R2
MOV R2,A
JNC L1
INC R1
L1
INC DPTR
DJNZ R0,L2
MOV A,R2
MOV @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
L3
SJMP L3
Result
EX.NO 14.
LOGICAL AND BIT MANIPULATION IN 8051
(B) i LOGICAL OPERATORS
AIM:
To perform logical & but manipulation in 8051
ALOGRITHM
1. Get 1st byte in R1
2. Get 2nd operand in R2
3. Move R1 to Accumulator
4. And the Accumulator with R2
5. Move the content of the accumulator to R0.
6. Move R1 to Accumulator
7. Or the Accumulator with R2
8. Move Accumulator content to R3
9. Move R1 to Accumulator
IT Dept/KLNCE
36
Operand
Label Mnemonics
MOV R1,#20H
MOV R2 #10H
MOV A,R1
ANL A, R2
MOV R0, A
MOV A,R1
ORL A, R2
MOV R3,A
MOV A, R1
CPL A
MOV R4,A
MOV A,R1
XRL A,R2
MOV R5,A
LCALL 0003H
Comments
First BYTE
Second BYTE
ANDING
R0=R1 AND R2
ORING
R3=R1 OR R2
NEGATION
R4=~R1
XORING
R5=R1 XOR R2
37
HLT:
MOV B, #0A
DIV A, B
INC DPTR
MOVX @DPTR, A
INC DPTR
MOV A,B
MOVX @DPTR,A
SJMP HLT
Result:
The given hexadecimal number is converted into decimal number
11.(b)iii. 8051 DECIMAL TO HEXADECIMAL CONVERSION
AIM:
To perform decimal to hexadecimal conversion
ALGORITHM:
1.Load the number to be converted in the accumulator
2.Separate the higher order digit from lower order.
3.Multiply the higher order digit by 10 and add it with the lower order digit
4.Store the result in the specified memory location
Address Opcode
Operand
Label
HLT:
Mnemonics
MOV DPTR, #4500
MOVX A, @DPTR
MOV B, #0A
MUL A,B
MOV B, A
INC DPTR
MOVX A ,@DPTR
ADD A,B
INC DPTR
MOVX @DPTR, A
MOV DPTR, #4500
MOVX A, @DPTR
SJMP HLT
Comments
RESULT:
The given decimal number is converted to hexadecimal number
IT Dept/KLNCE
38
IT Dept/KLNCE
39