No: 1
ARITHMETIC OPERATION
AIM:
To write and execute an assembly language program for add, subtract, multiply and divide two
16 bit unsigned numbers in 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the First Data in AX-register.
2. Load the First Data in BX-register.
2. Add the two data and get the sum in AX-register.
3. Store the sum in memory location.
4. Stop the program.
PROGRAM:
i) By Using Masm:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 1234H
MOV BX, 1234H
ADD AX, BX
MOV SI, 1200H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
ADDRESS
OPCODE
LABEL
MNEMONIC
COMMENTS
C7,C0,34,1
2
C7,C3,34,1
2
01,D8
MOV AX,1234H
MOV BX,1234H
ADD AX,BX
MOV SI,1200H
100E
C7,C6,00,1
2
89,04
MOV [SI],AX
1010
F4
HLT
1000
1004
1008
100A
OUTPUT:
INPUT
OUTPUT
Register
AX
BX
Data
1234H
1234H
Address
1200H
1201H
Data
68
24
16-BIT SUBTRACTION:
ALGORITHM:
1. Load the First Data in AX-register.
2. Load the First Data in BX-register.
3. Subtract the content of BX-reg from AX-register.
4. Store the result in memory location.
5. Stop the program.
PROGRAM:
i) BY USING MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 0FFFFH
MOV BX, 0EEEEH
SUB AX, BX
MOV SI, 1200H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
OPCODE
ADDRESS
MNEMONIC
COMMENTS
MOV AX,FFFFH
MOV BX,EEEEH
1008
C7,C0,FF,FF
C7,C3,EE,E
E
29,D8
100A
C7,C6,00,12
MOV SI,1200H
100E
89,04
MOV [SI],AX
1010
F4
HLT
1000
1004
LABEL
SUB AX,BX
OUTPUT:
INPUT
Register
AX
BX
OUTPUT
Data
FFFFH
EEEEH
Address
1200H
1201H
Data
11
11
16-BIT MULTIPLICATION
ALGORITHM:
1.
2.
3.
4.
5.
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 4444H
MOV BX, 4444H
MUL BX
MOV SI, 1200H
MOV [SI], DX
MOV SI, 1202H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
ADDRESS
OPCODE
1000
1004
1008
C7,C0, 4444
C7, C3, 4444
F7, E3
MOV AX,4444H
MOV BX,4444H
MUL BX
100a
C7, C6,
00,12
89, 14
MOV SI,1200H
MOV [SI],DX
MOV SI,1202H
1014
C7, C6,
02,12
89,04
MOV [SI],AX
1016
F4
HLT
100e
1010
LABEL
MNEMONIC
COMMENTS
OUTPUT:
INPUT
Register
AX
BX
OUTPUT
Data
4444H
4444H
Address
1200H
1201H
1202H
1203H
Data
34
12
10
32
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV DX, 0000H
MOV AX, 8888H
MOV CX, 4444H
DIV CX
MOV SI, 1200H
MOV [SI], AX
MOV SI, 1202H
MOV [SI], DX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
ADDRESS
OPCODE
LABEL
1000
C7, C2,00,00
1004
C7, C0,88,88
MOV AX,8888H
1008
C7, C1,44,44
COMMENTS
Initialize DX-register with Lsb of
Dividend
Load AX-register with Msb of
Dividend
Load CX-register with Divisor
100C
100E
1012
1014
F7, F1
C7, C6,00,12
89, 04
C7, C6,02,12
DIV CX
MOV SI,1200H
MOV [SI],AX
MOV SI,1202H
Divide AX by CX-register
Assign SI-reg to 1200H
Store the Quotient
Assign SI-reg to 1202H
MOV [SI],DX
HLT
1018
89, 14
101A
F4
MNEMONICS
MOV DX,0000H
OUTPUT:
INPUT
Register
DX
OUTPUT
Data
0000H
Address
1200H
Data
00(quotient)
AX
CX
8888H
4444H
1202H
1203H
1204H
02(quotient)
00(remainder)
00(remainder)
RESULT:
Thus an assembly language program for add, subtract, multiply and divide two 16 bit
unsigned numbers was executed using MASM and 8086 kit.
Ex. No: 1B
LOGICAL OPERATION
AIM:
To write and execute an assembly language program for performing logical OR, AND,
NAND operation in 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BL-register.
3. Logically OR the content of AL with BL-register.
4. Store the result in memory location.
5. Stop the program
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
OR AL, BL
INT 3H
CODE ENDS
END START
ii) By using 8086 kit:
ADDRESS
OPCODE
LABEL
1000
C6,C0,85
1003
C6,C3,99
MNEMONICS
MOV AL,85H
MOV BL,99H
COMMENTS
Load AL-register with 1st Data
Load BX-register with 2nd Data
1006
08,D8
OR AL, BL
1008
MOV SI,1200H
100C
C7,C6,00,1
2
89,04
MOV [SI],AX
100E
F4
HLT
OUTPUT:
INPUT
OUTPUT
Register
AL
BL
Data
85H
95H
Address
1200H
Data
9D
20,D8
1008
C7,C6,00,12
100C
89,04
100E
F4
LABEL
MNEMONICS
Org 1000h
MOV AL,85H
MOV BL,99H
COMMENTS
Starting address of the program
Load AL-register with 1st Data
Load BX-register with 2nd Data
AND AL, BL
MOV SI,1200H
MOV [SI],AX
HLT
OUTPUT:
INPUT
Register
AL
BL
OUTPUT
Data
85H
95H
Address
1200H
Data
81H
MNEMONICS
MOV AL,85H
MOV BL,99H
COMMENTS
Load AL-register with 1st Data
Load BX-register with 2nd Data
MOV SI,1200H
MOV [SI],AX
HLT
1006
20,D8
AND AL, BL
1008
F6,D0
NOT AL
100A
100E
C7,C6,00,1
2
89,04
1010
F4
OUTPUT:
INPUT
Register
AL
BL
OUTPUT
Data
85H
95H
Address
1200H
VIVA QUESTIONS:
1. What is a Microprocessor?
2. What is the need for timing diagram?
3. Define mnemonics.
4. What is the difference between min mode and max mode of 8086?
5. What is flag?
Data
7EH
6. What is stack?
7. What is interrupt?
8. What are the various interrupts in 8086?
9. What is the difference between compiler and assembler?
10. Which interrupts are generally used for critical events?
RESULT:
Thus an assembly language program for performing logical OR, AND, NAND operation was
executed using MASM and 8086 kit.
AIM:
To write and execute an assembly language program for Add, subtract, multiply and division of
two 8-bit numbers using 8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the First Data in A-register.
2. Load the Second Data in B-register.
3. Add the two data with carry.
4. Store the sum in memory location.
5. Stop the program.
PROGRAM:
ADDRESS
4100
4102
4105
OPCODE
74,05
75,F0,05
35,F0
LABEL
PROGRAM
MOV A,#data
MOV B,#data
ADDC A,B
4107
90,45,00
MOV DPTR,#4500H
410A
410B
F0
80, FE
MOVX @ DPTR,A
SJMP STOP
STOP:
COMMENTS
Load data 1 in accumulator.
Load data 2 in B-register
Add the contents of
accumulator and B-reg with
carry.
Initialize DPTR with
address 4500H
Store the result in 4500H
Stop the program
OUTPUT:
INPUT
Register
A-register
B-register
OUTPUT
Data
02H
04H
Address
4500
Data
06H
SUBTRACTION
ALGORITHM:
1. Load the First Data in A-register.
2. Load the Second Data in B-register.
3. Subtract the two data with borrow.
4. Store the sum in memory location.
5. Stop the program.
PROGRAM:
ADDRESS
4100
4102
4105
OPCODE
74,05
75,F0,04
95,F0
LABEL
4107
90 45 00
MOV DPTR,#4500H
410A
410B
F0
80, FE
MOVX @ DPTR,A
SJMP STOP
STOP:
PROGRAM
MOV A,#data
MOV B,#data
SUBB A,B
COMMENTS
Load data 1 in accumulator.
Load data 2 in B-register
Subtract the contents of Breg from accumulator with
borrow.
Initialize DPTR with
address 4500H
Store the result in 4500H
Stop the program
OUTPUT:
INPUT
Register
A-register
B-register
OUTPUT
Data
05H
01H
Address
4500
Data
04H
MULTIPLICATION
ALGORITHM:
1. Get the multiplier in the accumulator.
2. Get the multiplicand in the B register.
3. Multiply A with B.
4. Store the product in memory location.
5. Stop the program.
PROGRAM:
ADDRESS
OPCODE
LABEL
PROGRAM
COMMENTS
4100
74,05
MOV A,#data
4102
75,F0,05
MOV B,#data
4105
A4
MUL AB
4106
90,45,00
MOV DPTR,#4500H
4109
F0
MOVX @ DPTR,A
410A
A3
INC DPTR
410B
E5,F0
410D
F0
410E
80, FE
STOP:
MOV A,B
MOVX @ DPTR,A
SJMP STOP
OUTPUT:
INPUT
REGISTER
A
B
OUTPUT
DATA
5
5
ADDRESS
4500
DATA
19H
DIVISION
ALGORITHM:
1. Get the Dividend in the accumulator.
2. Get the Divisor in the B register.
3. Divide A by B.
4. Store the Quotient and Remainder in memory.
5. Stop the program.
PROGRAM:
ADDRESS
OPCODE
LABEL
PROGRAM
COMMENTS
4100
74,data1
MOV A,#data 1
4102
75,data2
MOV B,#data 2
4104
84
DIV AB
4105
90,45,00
MOV DPTR,#4500H
4108
F0
MOVX @ DPTR,A
4109
A3
INC DPTR
410A
E5,F0
MOV A,B
410C
F0
MOVX @ DPTR,A
410D
80, FE
SJMP STOP
STOP:
OUTPUT:
INPUT
REGISTER
A-Register
B-Register
RESULT:
OUTPUT
DATA
05
03
ADDRESS
4500
4501
DATA
01(quotient)
02(remainder)
Thus an assembly language program for Division of two 8-bit numbers and 16-bit numbers
using 8051 was performed and its output was verified.
AIM:
To write and execute an assembly language program to perform logical operations using 8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the Data 1 in the R0-register.
2. Get the Data 2 in the A register.
3. Logical AND, OR, XOR A with R0.
4. Store the result in memory.
5. Stop the program.
PROGRAM: AND OPERATION
ADDRESS
4100
OPCODE
78,14
4102
4104
74,12
58
4105
90,45,00
4108
4100
F0
80, FE
LABEL
PROGRAM
MOV R0,#DATA 1
COMMENTS
Load data 1 in R0-reg.
MOV A,#DATA 2
ANL A,R0
MOV DPTR,#4500H
STOP:
MOVX @ DPTR,A
SJMP STOP
OUTPUT:
INPUT
OUTPUT
REGISTER
R0-Register
A-Register
DATA
14
12
ADDRESS
4500
DATA
10
PROGRAM: OR OPERATION
ADDRESS
OPCODE
LABEL
4100
78,14
MOV R0,#DATA 1
4102
74,12
MOV A,#DATA 2
4104
58
ORL A,R0
4105
90,45,00
MOV DPTR,#4500H
4108
F0
MOVX @ DPTR,A
4100
80, FE
SJMP STOP
STOP:
PROGRAM
COMMENTS
OUTPUT:
INPUT
REGISTER
R0-Register
A-Register
OUTPUT
DATA
14
12
ADDRESS
4500
DATA
16
OPCODE
4100
78,14
MOV R0,#DATA 1
4102
74,12
MOV A,#DATA 2
4104
68
XRL A,R0
4105
90,45,00
MOV DPTR,#4500H
4108
F0
MOVX @ DPTR,A
SJMP STOP
4100
OUTPUT:
80, FE
LABEL
STOP:
PROGRAM
INPUT
REGISTER
R0-Register
A-Register
COMMENTS
OUTPUT
DATA
14
12
ADDRESS
4500
DATA
06
VIVA QUESTIONS:
1. Difference between microprocessor and microcontroller.
2. Explain DJNZ instructions of Intel 8051 microcontroller?
3. Why 8051 is called 8 bit microcontroller?
4. What is the difference between Harvard and Newman architecture?
5. Intel 8051 follows which architecture: Harvard or Newman?
6. How much on-chip RAM is available?
7. What is special function registers?
8. What are the different industrial applications of micro controllers?
9. What is the difference between the CISC and RISC processors?
10. List the addressing modes of 8051
RESULT:
Thus an assembly language program for logical operations using 8051 was performed and its
output was verified.