Professional Documents
Culture Documents
Ex no : 1
Date :
ADDITION OF TWO 16 BIT NUMBERS USING 8086
AIM:
To perform addition of two 16 bit numbers using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV CX,0000 Move value 0 to CX register
Move value in address 2100 to AX
2003 MOV AX,@2100
register
Move value in address 2102 to BX
2007 MOV BX,@2102
register
Add values in AX and BX register
200B ADD AX,BX
and store value in AX register
200D JNC L1 Jump if no carry to L1
200F INC CX Increment value in CX register by 1
Move value in AX register to the
2010 L1 MOV @2104,AX
address location 2104
Move value in CX register to
2013 MOV @2106,CX
address location 2106
2017 HLT Stop
RESULT:
Thus, addition of two 16 bit numbers has been performed and output has been generated
successfully.
PAGE NO: 1
190501060
Ex no : 2
Date :
SUBTRACTION OF TWO 16 BIT NUMBERS USING 8086
AIM:
To perform subtraction of two 16 bit numbers using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV CX,0000 Move value 0 to CX register
Move value in address 2100 to AX
2003 MOV AX,@2100
register
Move value in address 2102 to BX
2007 MOV BX,@2102
register
Subtract values in AX and BX
200B SUB AX,BX register and store value in AX
register
200D JNC L1 Jump if no carry to L1
200F INC CX Increment value in CX register by 1
2010 NEG AX Negate value in AX register
Move value in AX register to the
2012 L1 MOV @2104,AX
address location 2104
Move value in CX register to
2015 MOV @2106,CX
address location 2106
2019 HLT Stop
RESULT:
Thus, subtraction of two 16-bit numbers has been performed and output has been generated
successfully.
PAGE NO: 2
190501060
Ex no : 3
Date :
MULTIPLICATION OF TWO 16 BIT NUMBERS USING 8086
AIM:
To perform multiplication of two 16 bit numbers using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 2100 to AX
2000 MOV AX,@2100
register
Move value in address 2102 to BX
2004 MOV BX,@2102
register
Multiply the value in BX register
2008 MUL BX
with value in AX register
Move value in DX register to the
200A MOV @2104,DX
address location 2104
Move value in AX register to
200E MOV @2106,CX
address location 2106
2011 HLT Stop
ADDRESS DATA
2100 0002
2102 0002
2106 0004
2104 0000
ADDRESS DATA
2100 2002
2102 6002
2106 0004
2104 0C01
RESULT:
Thus, multiplication of two 16 bit numbers has been performed and output has been generated
successfully.
PAGE NO: 3
190501060
Ex no : 4
Date :
DIVISION OF TWO 16 BIT NUMBERS USING 8086
AIM:
To perform division of two 16 bit numbers using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 2100 to AX
2000 MOV AX,@2100
register
Move value in address 2102 to BX
2004 MOV BX,@2102
register
Multiply the value in BX register
2008 DIV BX
with value in AX register
Move value in DX register to the
200A MOV @2104,DX
address location 2104
Move value in AX register to
200E MOV @2106,CX
address location 2106
2011 HLT Stop
ADDRESS DATA
2100 0003
2102 0002
2106 0001
2104 0001
ADDRESS DATA
2100 0005
2102 0003
2106 0001
2104 0002
RESULT:
Thus, division of two 16 bit numbers has been performed and output has been generated
successfully.
PAGE NO: 4
190501060
Ex no : 5
Date :
AND OF TWO 16 BIT NUMBERS USING 8086
AIM:
To perform and operation of two 16-bit numbers using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 2100 to AX
2000 MOV AX, @2100
register.
Move value in address 2102 to BX
2004 MOV BX, @2102
register
Performs And operation of value in
2008 AND AX, BX
AX register with BX register
Move value in AX register to
200A MOV @2200, AX
address location 2200
200D HLT Stop
ADDRESS DATA
2100 0005
2102 0004
2200 0004
ADDRESS DATA
2100 A00C
2102 2A1B
2200 2008
RESULT:
Thus, AND operation of two 16-bit numbers has been performed and output has been
generated successfully.
PAGE NO:5
545
190501060
Ex no : 6
Date :
OR OF TWO 16 BIT NUMBERS USING 8086
AIM:
To perform OR of two 16-bit numbers using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 2100 to AX
2000 MOV AX, @2100
register.
Move value in address 2102 to BX
2004 MOV BX, @2102
register.
Performs OR between values in AX
2008 OR AX, BX
register with value in BX register.
Move the value in AX register to
200A MOV @2200, AX
address 2200.
200D HLT Stop
ADDRESS DATA
2100 0FF0
2102 F00F
2200 FFFF
ADDRESS DATA
2100 0010
2102 5F01
2200 5F11
RESULT:
Thus, OR operation of two 16 bit numbers has been performed and output has been
generated successfully.
PAGE NO: 6
190501060
Ex no : 7
Date :
XOR OF TWO 16 BIT NUMBERS USING 8086
AIM:
To perform XOR of two 16 bit numbers using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 2100 to AX
2000 MOV AX, @2100
register
Move value in address 2102 to BX
2004 MOV BX, @2102
register
Performs XOR of values in AX
2008 XOR AX, BX
register with value in BX register
Move the value in AX register to
200A MOV @2200, AX
address 2200
200D HLT Stop
ADDRESS DATA
2100 0110
2102 1001
2200 1111
ADDRESS DATA
2100 A00C
2102 2A1B
2200 8A17
RESULT:
Thus, XOR operation of two numbers has been performed and output has been executed
successfully.
PAGE NO: 7
190501060
Ex no : 8
Date :
NOT OF A 16 BIT NUMBERS USING 8086
AIM:
To perform a NOT operation of A 16-bit number.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address in 2100 to
2000 MOV AX, @2100
AX register
Performs NOT operation for the
2004 NOT AX
value in AX register
Move value in AX register to
2006 MOV @2200, AX
address 2200
2009 HLT Stop
ADDRESS DATA
2100 000A
2200 FFF5
ADDRESS DATA
2100 ABCA
2200 5435
RESULT:
Thus, NOT operation of a 16-bit number has been performed and output is executed
successfully.
PAGE NO: 8
190501060
Ex no : 9
Date :
SHIFT LEFT BY 1-BIT OF A 16-BIT NUMBER USING 8086
AIM:
To perform left shift by 1-bit of a 16-bit number using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 2100 to AX
2000 MOV AX, @2100
register
Left shift the value in AX register
2004 SHL AX, 01
by 1 bit
2006 MOV @2200, AX Move value in AX to address 2200
2009 HLT Stop
ADDRESS DATA
2100 0007
2200 000E
ADDRESS DATA
2100 AB07
2200 560E
RESULT:
Thus, left shift of a 16-bit number by 1-bit has been performed and the output has been
generated.
PAGE NO: 9
190501060
Ex no : 10
Date :
SHIFT RIGHT BY 1-BIT OF A 16-BIT NUMBER USING 8086
AIM:
To perform right shift by 1-bit of a 16-bit number using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 2100 to AX
2000 MOV AX, @2100
register
Right shift the value in AX register
2004 SHR AX, 01
by 1 bit
2006 MOV @2200, AX Move value in AX to address 2200
2009 HLT Stop
ADDRESS DATA
2100 0005
2200 0002
ADDRESS DATA
2100 7AB1
2200 3058
RESULT:
Thus, right shift of a 16-bit number by 1-bit has been performed and the output has been
generated.
PAGE NO: 10
190501060
Ex no : 11
Date :
AVERAGE OF GIVEN WORD VALUES STORED IN MEMORY USING 8086
AIM:
To find the average of given word values using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV AX, 0000 Move value 0 to AX register
2003 MOV SI, 2020 Move the address 2020 to SI
2006 MOV CS, AX Move value in AX register to CS
2008 MOV CX, 05 Move value 5 to CX register
Add the value in AX register with
200B BAK ADD AX, [SI]
the content of SI
200D INC SI Increment value in SI by 1
200E INC SI Increment value in SI by 1
Loop to label BAK until the value
200F LOOP BAK
in CX register becomes 0
2011 MOV CX, 05 Move value 5 to CX register
Divide value in AX register with
2014 DIV CX
value in CX register
2016 MOV SI, 2030 Move value 2030 to SI
Move value in AX register to
2019 MOV [SI], AX
content of SI
201B INT 03 Stop
190501060
SAMPLE INPUT AND OUTPUT:
PAGE NO: 11
ADDRESS DATA
2020 1000
2022 2000
2024 3000
2026 4000
2028 5000
2030 3000
ADDRESS DATA
2020 30
2022 50
2024 20
2026 60
2028 40
2030 40
RESULT:
Thus, average of given word values using 8086 has been performed and output has been
generated successfully. 190501060
Ex no : 12
Date : PAGE NO: 12
BLOCK TRANSFER USING 8086
AIM:
To transfer data in blocks using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 6100 to AX
2000 MOV CX, @6100
register
2004 MOV SI, 6200 Move value 6200 to SI
2007 MOV DI, 6300 Move value 6300 to DI
Move the content of SI to AX
200A L1 MOV AX, [SI]
Register
Move the value in AX register to
200C MOV [DI], AX
content of D1
200E INC SI Increment value in SI by 1
200F INC SI Increment value in SI by 1
2010 INC DI Increment value in DI by 1
2011 INC DI Increment value in DI by 1
2012 DEC CX Decrement value in CX by 1
2013 JNZ L1 Jump if Non Zero to L1
2015 HLT Stop
190501060
SAMPLE INPUT AND OUTPUT: PAGE NO: 13
ADDRESS DATA
6100 04
6200 01
6202 02
6204 03
6206 04
6300 01
6301 02
6302 03
6303 04
ADDRESS DATA
6100 05
6200 01
6202 03
6204 05
6206 07
6208 09
6300 01
6301 03
6302 05
6303 07
6304 09
RESULT:
The block transfer using 8086 has been performed and output has been generated successfully.
190501060
PAGE NO: 14
Ex no : 13
Date :
CONVERSION OF HEXADECIMAL BYTE VALUE TO ITS ASCII VALUE USING 8086
AIM:
To convert a hexadecimal byte to ASCII value using 8086
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DI,2012 Move value 2012 to DI
The effective address of DI is
2003 LEA BX,[DI]
loaded in BX register
Performs XOR for value in AH
2005 XOR AH,AH
register with value in AH Register
2007 MOV CL,04 Move value 04 to CL Register
Performs right shift for value in AX
2009 ROR AX,CL
register by value inn CL Register
Performs right shift for value in AH
200B ROR AH,CL
register by value inn CL Register
Translate the value in AL register
200D XLAT
by using look up table
Exchange value in AL Register with
200E XCHAG AH,AL
value in AH Register and vice versa
Translate the value in AL register
2010 XLAT
by using look up table
2011 HLT Stop
LOOK UP TABLE:
PAGE NO: 15
INITIAL 0003H
AH AL 0000 0000 0000 0011
AX 0011 0000 0011 0111
INITIAL 0007H
AH AL 0000 0000 0000 0111
AX 0011 0000 0011 0111
RESULT:
Thus, the conversion of Hexadecimal by byte to its ASCII value has been performed and
output has been generated successfully.
190501060
PAGE NO: 16
Ex no : 14
Date :
TO FIND FACTORIAL OF A GIVEN NUMBER USING 8086
AIM:
To find factorial of a given number using 8086
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV AX, 0000 Move value 0 to AX register
2003 MOV CS, AX Move value in AX register with CS
2005 MOV DS, AX Move value in AX register with DS
2007 MOV SI, 3000 Move value 3000 to SI
Move content of SI with AL
200A MOV AL, [SI]
register
Move content of SI with BL
200C NXT MOV BL, [SI]
Register
Decrement value in BL register by
200E DEC BL
1
2010 JZ OVR Jump if zero to OVR
Move value in BL register to
2012 MOV [SI], BL
content of SI
Multiply value of AX register with
2014 MULW [SI]
content of SI
2016 JMP NXT Jump to NXT
2018 MOV DI, 3100 Move value 3100 to DI
Move value in AX register to
201B MOV [DI], AX
content of DI
201D INT 03 Stop
PAGE NO: 17
190501060
SAMPLE INPUT AND OUTPUT:
ADDRESS DATA
3000 05
3100 78
ADDRESS DATA
3000 04
3100 18
RESULT:
Thus, factorial of a given number has been performed and output has been generated.190501060
PAGE NO: 18
Ex no : 15
Date :
TO FIND LARGEST VALUE IN A STRING OF DATA BYTES USING 8086
AIM:
To find the largest value in a string of data bytes using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV AX, 0000 Move 0000 to AX register
Move the value in AX register to
2003 MOV CS, AX
Code Segment (CS)
2005 MOV SI, 2100 Move the value 2100 to SI register
Move the value 0A register to BH
2008 MOV BH, 0A
register
Move content of SI register to AL
200A MOV AL, [SI]
register
200C NXT INC SI Increment value in SI register by 1
Decrement value in BH register by
200D DEC BH
1
200F JZ OVR Jump if zero to OVR
Move the content of SI register to
2011 MOV BL, [SI]
BL register
Compare the value in BL register
2013 CMP AL, BL
with the value in AL register
Jump if carry flag is set and zero
2015 JNBE NXT
flag is 0 to NXT
Move the value in BL register to AL
2017 MOV AL, BL
register
2019 JMP NXT Jump to next
201B OVR INT03 Stop
190501060
SAMPLE INPUT AND OUTPUT:
PAGE NO: 19
ADDRESS DATA
2100 03
2101 05
2102 0A
2103 1B
2104 01
2105 00
2106 02
2107 FF
2108 06
2109 07
OUTPUT
AL FF
ADDRESS DATA
2100 11
2101 12
2102 13
2103 06
2104 08
2105 00
2106 02
2107 04
2108 03
2109 15
OUTPUT:
AL 15
RESULT:
Thus, finding largest number in a string of data bytes has been performed and output has
been generated successfully. 190501060
PAGE NO: 20
Ex no : 16
Date :
TO FIND SMALLEST VALUE IN A STRING OF DATA BYTES USING 8086
AIM:
To find the smallest value in a string of data bytes using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move the value in the address
2000 MOV CL, @6100
6100 to CL register
2004 MOV SI, 6200 Move the value 6200 to SI register
Move the content of SI register to
2007 MOV AX, [SI]
AX register
2009 L1 INC SI Increment value in SI register by 1
Compare the value in BX register
200A CMP AX, BX
with the value in AX register
200E JBE L2 Jump if below or equal to L2
Move the content of SI register to
2010 MOV AX, [SI]
AX register
Decrement value in CL register by
2012 L2 DEC CL
1
2014 JNZ L1 Jump if not zero to L1
Move the value in AX register to
2016 MOV @6300, AX
the address location 6300
2019 HLT Stop
ADDRESS DATA
6100 04
6200 03
6201 02
6202 04
6203 05
OUTPUT:
6300 02
ADDRESS DATA
PAGE NO: 21
190501060
6100 05
6200 FF
6201 10
6202 11
6203 04
6204 05
OUTPUT:
6300 04
RESULT:
Thus, the smallest value in a string of data bytes using 8086 has been performed and output
has been generated successfully. 190501060
PAGE NO: 22
Ex no : 17
Date :
EXCHANGING TWO BLOCKS OF DATA STORED IN MEMORY USING 8086
AIM:
To exchange two blocks of data stored in memory using 8086.
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
3002 02
3003 03
3004 04
3200 13
3201 12
3202 11
3203 10
3204 0F
AFTER EXCHANGING:
ADDRESS DATA
3000 13
3001 12
3002 11
3003 10
3004 0F
3200 00
3201 01
3202 02
3203 03
3204 04
ADDRESS DATA
3000 00
3001 02
3002 04
3003 06
3004 08
3200 01
3201 03
3202 05
3203 07
3204 09 3003 07
3004 09
AFTER EXCHANGING: 3200 00
ADDRESS DATA 3201 02
3000 01 3202 04
3001 03 3203 06
3002 05 3204 08
RESULT:
Thus two blocks of data stored in memory have been exchanged successfully. 190501060
PAGE NO: 24
Ex no : 18
Date :
PACKED BCD TO ASCII USING 8086
AIM:
To convert BCD to ASCII using 8086.
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
4100 04
4102 3034
Initial 04
After
190501060
ADDRESS DATA
PAGE NO: 25
4100 08
4102 3038
Initial 08
AH AL 0000 1000 0000 1000
After
AH AL 0011 0000 0011 1000
RESULT:
Thus, conversion of packed BCD to ASCII has been performed and output has been generated
successfully. 190501060
PAGE NO: 26
Ex no : 19
Date :
ASCII TO PACKED BCD USING 8086
AIM:
To convert ASCII value to packed BCD using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
Move value in address 6100 to AX
2000 MOV AX, @6100
register
Perform AND operation for value
2004 AND AX, 0F0F
in AX register with the value 0F0F
Exchanges values in AH register
2007 XCHG AH, AL
with AL register
2009 MOV CL, 04 Move value 04 to CL register
Shift left value in AH register by
200B SHL AH, CL
value in CL register times
Perform OR operation for value in
200D OR AL, AH AL register with value in AH
register
Move value in AL register to
200F MOV @6102, AL
address 6102
2012 HLT Stop
ADDRESS DATA
6100 37
6101 35
6102 57
ADDRESS DATA
6100 32
6101 34
6102 24
RESULT:
Thus, ASCII to Packed BCD is conversion has been performed and output has been generated
successfully. 190501060
PAGE NO: 27
Ex no : 20
Date :
DECIMAL ADJUST AFTER ADDITION USING 8086
AIM:
To perform decimal adjust after addition using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV CL, 00 Move value 00 to CL register
Move value in address 4100 to AL
2002 MOV AL, @4100
register
Move value in address 4102 to BL
2006 MOV BL, @4102
register
Add the value in BL register with
200A ADD AL, BL
value in AL register
Performs decimal adjust after
200C DAA
addition for value in AL register
200D JNC L1 Jump if no carry to L1
200F INC CL Increment value in CL register by 1
Move value in AL register to
2011 L1 MOV @4200, AL
address 4200
Move value in CL register to
2014 MOV @4202, CL
address 4202
2018 HLT Stop
SAMPLE INPUT AND OUTPUT:
RESULT:
Thus decimal adjust after addition has been performed and output has been generated
successfully. 190501060
PAGE NO: 28
Ex no : 21
Date :
DECIMAL ADJUST AFTER SUBTRACTION USING 8086
AIM:
To perform decimal adjust after subtraction using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV CL, 00 Move value 0 to CL register
Move value in address 2100 to AL
2002 MOV AL, @2100
register
Move value in address 2102 to BL
2006 MOV BL, @2102
register
Perform subtraction for value in BL
200A SUB AL, BL
register with value in AL register
Perform decimal adjust after
200C DAS
subtraction for value in AL register
200D JNC L1 Jump if no carry to L1
200F INC CL Increment value in CL register by 1
Move value in AL register to
2011 L1 MOV @2200, AL
address 2200
Move value in CL register to
2014 MOV @2201, CL
address 2101
2018 HLT Stop
SAMPLE INPUT AND OUTPUT:
RESULT:
Thus, decimal adjust after subtraction has been performed and output has been generated
successfully. 190501060
PAGE NO: 29
Ex no : 22
Date :
TO PERFORM MATRIX ADDITION USING 8086
AIM:
To perform matrix addition using 8086.
PROGRAM:
ADDRE LABE
MNEMONICS OPCODE COMMENTS
SS L
2000 MOV SI, 2100 Move value 2100 to SI register
2003 MOV DI, 2200 Move value 2200 to DI register
2006 MOV BX , 2300 Move value 2300 to BX register
2009 MOV CX , 0004 Move value of 4 to CX register
200C L2 MOV AX , 0000 Move value 0000 to AX register
200F MOV AL , [SI] Move content of SI to AL register
Add the content of DI with AL
2011 ADD AL , [DI]
register
2013 JNC L1 Jump if no carry to L1
2015 INC AH Increment value in AH register by 1
Move the value in AX register to
2017 L1 MOV [BX] , AX
the address in BX register
2019 INC SI Increment value in SI register by 1
201A INC DI Increment value in DI register by 1
201B INC BX Increment value in BX register by 1
201C INC BX Increment value in BX register by 1
Decrement value in CL register by
201D DEC CL
1
201E JNZ L2 Jump if not zero to L2
2020 HLT Stop
190501060
SAMPLE INPUT AND OUTPUT: PAGE NO: 30
ADDRESS DATA
2100 05
2101 06
2102 07
2103 08
2200 01
2201 02
2202 03
2203 04
2300 0006
2302 0008
2304 000A
2306 000C
ADDRESS DATA
2100 0F
2101 02
2102 0B
2103 04
2200 05
2201 06
2202 07
2203 08
2300 0014
2302 0008
2304 0012
2306 000C
RESULT:
Thus matrix addition has been performed and output has been generated successfully.190501060
Ex no : 23 PAGE NO: 31
Date :
TO PERFORM MATRIX SUBRACTION USING 8086
AIM:
To perform matrix subtraction using 8086.
PROGRAM:
ADDRE LABE
MNEMONICS OPCODE COMMENTS
SS L
2000 MOV SI, 2100 Move value 2100 to SI register
2003 MOV DI, 2200 Move value 2200 to DI register
2006 MOV BX , 2300 Move value 2300 to BX register
2009 MOV CX , 0004 Move value of 4 to CX register
200C L2 MOV AX , 0000 Move value 0000 to AX register
200F MOV AL , [SI] Move content of SI to AL register
Perform subtraction for value in DI
2011 SUB AL , [DI]
register with value in AL register
2013 JNC L1 Jump if no carry to L1
2015 INC AH Increment value in AH register by 1
Move the value in AX register to
2017 L1 MOV [BX] , AX
the address in BX register
2019 INC SI Increment value in SI register by 1
201A INC DI Increment value in DI register by 1
201B INC BX Increment value in BX register by 1
201C INC BX Increment value in BX register by 1
Decrement value in CL register by
201D DEC CL
1
201E JNZ L2 Jump if not zero to L2
2020 HLT Stop
190501060
SAMPLE INPUT AND OUTPUT: PAGE NO: 32
190501060
PAGE NO: 33
Ex no : 24
Date :
SORTING AN ARRAY IN ASCENDING ORDER USING 8086
AIM:
To sort an array in ascending order using 8086.
PROGRAM:
ADDRE LABE
MNEMONICS OPCODE COMMENTS
SS L
2000 MOV SI, 5100 Move value 5100 to SI register
2003 MOV CH, [SI] Move content of SI to CH register
2005 L2 MOV SI, 5100 Move value 5100 to SI register
2008 MOV CL, [SI] Move content of SI to CH register
200A DEC CL decrement value in CL register by 1
200C INC SI Increment value in SI register by 1
200D INC SI Increment value in SI register by 1
201E L3 MOV AX, [SI] Move content of SI to AX register
2010 INC SI Increment value in SI register by 1
2011 INC SI Increment value in SI register by 1
Move content of SI register to BX
2012 MOV BX, [SI]
register
Compare value in BX register with
2014 CMP AX, BX
value in AX register
2016 JC L1 Jump if carry to L1
Move value in BX register to
2018 MOV DX, BX
content of DX register
Move value in AX register to
201A MOV [SI], AX
content of SI register
201C DEC SI Decrement value in SI register by 1
201D DEC SI Decrement value in SI register by 1
Move value in DX register to SI
201E MOV [SI] , DX
register
2020 INC SI Increment value in SI register by 1
2021 INC SI Increment value in SI register by 1
Decrement value in CL register by
2022 L1 DEC CL
1
2024 JNZ L3 Jump if not zero to L3 190501060
190501060
PAGE NO: 35
Ex no : 25
Date :
SORTING AN ARRAY IN DESCENDING ORDER USING 8086
AIM:
To sort an array in descending order using 8086.
PROGRAM:
ADDRE LABE
MNEMONICS OPCODE COMMENTS
SS L
2000 MOV SI, 5100 Move value 5100 to SI register
2003 MOV CH, [SI] Move content of SI to CH register
2005 L2 MOV SI, 5100 Move value 5100 to SI register
2008 MOV CL, [SI] Move content of SI to CH register
200A DEC CL decrement value in CL register by 1
200C INC SI Increment value in SI register by 1
200D INC SI Increment value in SI register by 1
201E L3 MOV AX, [SI] Move content of SI to AX register
2010 INC SI Increment value in SI register by 1
2011 INC SI Increment value in SI register by 1
2012 MOV BX, [SI] Move content of SI register to BX
register
Compare value in BX register with
2014 CMP AX, BX
value in AX register
2016 JNC L1 Jump if carry to L1
Move value in BX register to
2018 MOV DX, BX
content of DX register
Move value in AX register to
201A MOV [SI], AX
content of SI register
2020 INC SI Increment value in SI register by 1
2021 INC SI Increment value in SI register by 1
Decrement value in CL register by
2022 L1 DEC CL
1
2024 JNZ L3 Jump if not zero to L3
Decrement value in CH register by
2026 DEC CH
1
2028 JNZ L2 Jump if not zero to L2 190501060
ADDRESS DATA
5100 0004
5102 0001
5104 0002
5106 0003
5108 0004
5100 0004
5102 0004
5104 0003
5106 0002
5108 0001
ADDRESS DATA
5100 0004
5102 0001
5104 0007
5106 0002
5108 0006
5100 0004
5102 0007
5104 0006
5106 0002
5108 0001
RESULT:
Thus, sorting an array in descending order has been performed and output has been
generated successfully. 190501060
Ex no : 26 PAGE NO: 37
Date :
ADDITION USING 8051
AIM:
To Perform addition of two 8 bit numbers using 8051
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8100 Move value 8100 to DPTR register
Move value at address stored in
2003 MOVX A, @DPTR
DPTR to A register
Move value in A register to B
2004 MOV B, A
register
2006 INC DPTR Increment value in DPTR by 1
Move values at address stored in
2007 MOVX A, @DPTR
DPTR to A register
2008 MOV RO, #00 Move value 00 to RO register
Add value in B register with A
200A ADD A, B
register
190501060
SAMPLE INPUT AND OUTPUT:
PAGE NO: 38
ADDRESS DATA
8100 04
8101 03
8102 07
8103 00
ADDRESS DATA
8100 05
8101 05
8102 0A
8103 00
RESULT:
Thus, addition of two 8 bit numbers using 8051 has been performed and output has been
generated successfully. 190501060
PAGE NO: 39
Ex no : 27
Date :
SUBTRACTION USING 8051
AIM:
To Perform subtraction of two 8 bit numbers using 8051
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8100 Move value 8100 to DPTR register
Move value at address stored in
2003 MOVX A, @DPTR
DPTR to A register
Move value in A register to B
2004 MOV B, A
register
2006 INC DPTR Increment value in DPTR by 1
Move values at address stored in
2007 MOVX A, @DPTR
DPTR to A register
2008 MOV RO, #00 Move value 00 to RO register
Subtract value in B register with A
200A SUBB A, B
register
190501060
SAMPLE INPUT AND OUTPUT:
PAGE NO: 40
ADDRESS DATA
8101 09
8102 05
8103 04
8104 00
ADDRESS DATA
8101 0F
8102 0E
8103 01
8104 00
RESULT:
Thus, Subtraction of two 8 bit numbers using 8051 has been performed and output has been
generated successfully.
190501060
PAGE NO: 41
Ex no : 28
Date :
MULTIPLICATION USING 8051
AIM:
To Perform multiplication of two numbers using 8051
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8300 Move value 8300 to DPTR register
Move value at address stored in
2003 MOVX A, @DPTR
DPTR to A register
Move value in A register to B
2004 MOV B, A
register
2006 INC DPTR Increment value in DPTR by 1
Move values at address stored in
2007 MOVX A, @DPTR
DPTR to A register
Multiply value in B register with
2008 MUL A, B
value in A register
Subtract value in B register with A
2009 INC DPTR
register
Move values in A register to
200A MOVX @DPTR, A
Address stored in DPTR
Move values in B register to A
200B MOV A, B
register
Increment value in OPTR register
200D INC OPTR
by 1
Move value in A register to
200E MOVX @DPTR, A
address in DPTR register
190501060
ADDRESS DATA
8300 02
8301 04
8302 08
8303 00
ADDRESS DATA
8300 03
8301 03
8302 09
8303 00
RESULT:
Thus Multiplication of two 8 bit numbers using 8051 has been performed and output has been
generated successfully. 190501060
PAGE NO: 43
Ex no : 29
Date :
DIVISION USING 8051
AIM:
To Perform division of two numbers using 8051
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8100 Move value 8100 to DPTR register
Move value at address stored in
2003 MOVX A, @DPTR
DPTR to A register
Move value in A register to B
2004 MOV B, A
register
2006 INC DPTR Increment value in DPTR by 1
Move values at address stored in
2007 MOVX A, @DPTR
DPTR to A register
Divide value in B register with
2008 DIV A, B
value in A register
Subtract value in B register with A
2009 INC DPTR
register
Move values in A register to
200A MOVX @DPTR, A
Address stored in DPTR
Move values in B register to A
200B MOV A, B
register
Increment value in OPTR register
200D INC OPTR
by 1
Move value in A register to
200E MOVX @DPTR, A
address in DPTR register
190501060
ADDRESS DATA
8101 07
8102 02
8103 03
8104 01
ADDRESS DATA
8100 04
8101 02
8102 02
8103 00
RESULT:
Thus, division of two 8 bit numbers using 8051 has been performed and output has been
generated successfully. 190501060
PAGE NO: 45
Ex no : 30
Date :
AND OPERATION USING 8051
AIM:
To perform and operation using 8051.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8100 Move value 8100 to DPTR register
Move the value in address stored
2003 MOVX A, @DPTR
in DPTR register to A register
Move the value to A register to B
2004 MOV B, A
register
Increment value in DPTR register
2006 INC DPTR
by 1
Move the value in address stored
2007 MOVX A, @DPTR
in DPTR register to A register
Perform AND operation for value
2008 ANL A, B in A register with value in B
register
Increment value in DPTR register
200A INC DPTR
by 1
Move value in A register to
200B MOVX @DPTR, A
address stored in DPTR
200C L1 SJMP L1 Stop.
SAMPLE INPUT AND OUTPUT:
RESULT:
Thus, AND operation of two numbers using the 8051 has been performed and output has
been generated successfully. 190501060
Ex no : 31 PAGE NO: 46
Date :
OR OPERATIION USING 8051
AIM:
To perform or operation of two numbers using 8051.
PROGRAM:
ADDRES
LABEL MNEMONICS OPCODE COMMENTS
S
2000 MOV DPTR, #8100 Move value 8100 to DPTR register.
Move the value stored in address
2003 MOV A, @DPTR
of DPTR to A register.
Move value in A register with B
2004 MOV B,A
register.
2006 INC DPTR Increment value in DPTR by 1.
Move value stored in address of
2007 MOV A, @DPTR
DPTR to A register.
Performs or operation for value in
2008 ORL A, B
A register and B register.
200 A INC DPTR Increment value in DPTR by 1.
Move value in A register to address
200B MOV X @DPTR, A
in DPTR.
200C L1 SJMP l1 Stop.
SAMPLE INPUT AND OUTPUT:
RESULT:
Thus, OR operation of two numbers using 8051 has been performed and output has been
generated successfully. 190501060
PAGE NO: 47
Ex no : 32
Date :
XOR OPERTION USING 8051
AIM:
To perform XOR operation using 8051
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8100 Move value 8100 to DPTR register
Move value in address stored in
2003 MOV A, @DPTR
DPTR to A register
Move value in A register to B
2004 MOV B, A
register
2006 INC DPTR Increment value in DPTR by 1
Move value in address stored in
2007 MOV A, @DPTR
the DPTR to A register
Perform XOR operation for value in
2008 XRL A, B
A register by value in B register
Increment value in DPTR register
200A INC DPTR
by 1
Move value in A register to register
200B MOV @DPTR, A
To address stored in DPTR
200C L1 SJMP L1 Jump to L1
SAMPLE INPUT AND OUTPUT:
RESULT:
Thus, XOR operation using 8051 has been performed and output has been generated
successfully. 190501060
Ex no : 33
PAGE NO: 48
Date :
NOT OPERATION USING 8051
AIM:
To perform not operation using 8051.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8100 Move value 8100 to DPTR register.
Move value in address stored by DPTR
2003 MOV A, @DPTR
to A register.
2004 CPL A Complement value in A register.
2005 INC DPTR Increment value in DPTR by 1.
2006 MOVX @DPTR, A Move value in A register to address
2007 SJMP L1 Jump to L1
ADDRESS DATA
8100 DE
8101 21
ADDRESS DATA
8100 A0
8101 5F
RESULT:
Thus, NOT operation using 8051 has been performed and output has been generated
successfully.
190501060
Ex no : 34
Date :
PAGE NO: 49
SQUARE OF A NUMBER USING 8051
AIM:
To find square of a number using 8051.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8100 Move value 8100 to DPTR
Move value in address stored by
2003 MOVX A, @DPTR
DPTR to A register
Move value in A register to B
2006 MOV B, A
register
Multiply value in A register with
2007 MUL A, B
value in B register
2009 INC DPTR Increment value in DPTR by 1
Move value in A register to
200A MOVX @DPTR, A
address stored in DPTR
200C L1 SJMP L1 Jump to L1
ADDRESS DATA
8100 0002
8101 0004
ADDRESS DATA
8100 0003
8101 0009
RESULT:
Thus, square of a number using 8051 has been performed and output has been generated
successfully.
190501060
Ex no : 35
Date : PAGE NO: 50
CUBE OF A NUMBER USING 8051
AIM:
To find cube of a number using 8051.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DPTR, #8100 Move value 8100 to DPTR
Move value in address stored by
2003 MOVX A, @DPTR
DPTR to A register
Move value in A register to RO
2006 MOV R0, A
register
Move value in A register to B
2007 MOV B, A
register
Multiply value in A register with
2008 MUL A, B
value in B register
Move value in RO register to B
200A MOV B, R0
register
Multiply value in A register with
200B MUL A, B
value in B register
200D INC DPTR Increment value in DPTR by 1
Move value in A register to
200E MOVX @DPTR, A
address stored in DPTR
2010 L1 SJMP L1 Jump to L1
ADDRESS DATA
8100 0003
8101 001B
RESULT:
Thus, cube of a number using 8051 has been performed and output is displayed successfully.
190501060
Ex no : 36
Date : PAGE NO: 51
INTERFACING STEPPER MOTOR WITH 8086
AIM:
To Interfacing stepper motor with 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 MOV DX, FFE6 Move value FFE6 to DX register
2003 MOV AL, 80H Move value 80H to AL register
Send value in AL register to the
2005 OUT DX, AL
part address stored in DX register
2006 MOV AL, 11 Move value 11 to AL register
2008 MOV DX, FFE0 Move Value FFE0 to DX register
Send value in AL register to part
200B L2 OUT DX, AL
address stored in DX register
200C CALL DELAY Call Procedure Delay
Rotate value in AL Register right by
200E ROR AL, 1
1 bit
2011 JMP L2 Jump to L2
2013 DELAY MOV CX, FFFF Move Value FFFF to CX Register
2016 L1 LOOP L1 Loop to L1
2018 RET Return from Procedure
RESULT:
Thus, Interfacing Stepper Motor with 8086 has been performed and output has been verified.
190501060
Ex no : 37
PAGE NO: 52
Date :
TRAFFIC LIGHT CONTROL USING 8086
AIM:
To create traffic control using 8086.
PROGRAM:
ADDRES LABE
MNEMONICS OPCODE COMMENTS
S L
2000 Start MOV AL,80 H Move value 80H to AL register.
2002 MOV DX, FFE6 Move value FFE6 to DX register
Send value in AL register to the
2005 OUT DX, AL
part address stored in DX register.
2006 AGAIN MOV SI,2038 Move value 2038 to SI register.
Move content of SI register to AX
2009 NEXTST MOV AL, [SI]
register.
200B MOV DX, FFE0H Move value FFE0H to DX register.
Send value in AL register to part
200E Out DX, AL
address stored in DX register.
200F INC SI Increment value in SI register by 1.
Add value 02H with value in SI
2010 ADD DL, 02H
register by 1.
2013 MOV AL, [SI] Move content of SI to AL register.
Send value in AL register to part
2015 OUT DX, AL
address stored in DX register.
Increment the value in SI register
2016 INC SI
by 1.
Add value 02H with value in DL
2017 ADD DL,02H
register.
Move the content of SI to AL
201A MOV AL, [SI]
register
Send the value in AL register to
201C OUT DX, AL
part address stored in DX register.
201D INC SI Increment Value in SI register by 1.
201E CALL 2029 Call subroutine in address 2029
Compare value 2056 H with value
2021 CMP SI,2056
in SI register.
2025 JNZ 2009 Jump if not zero to address 190501060
2009.
2027 JMP 2006 Jump to address 2006.
2029 DELAY MOV CX, FFH Move value FFH to CX register.
202C DLY5 PUSH CX Push value in CX register to stack.
202D MOV CX, 03FF Move value 03FFH to CX register.
2030 DLY10 NOP No operation for 3 clock cycles.
2031 LOOP 2030 Loop to address 2030.
Pop value in stack and copy it to
2033 POP CX
CX register.
2034 LOOP 202C Loop to address 202C.
2036 RET Return
2038 DB 10,81,7A State 1
203B DB 44, 44, F0 All ambers ON
203E DB 08, 11, EF State 2
2041 DB 44, 44, F0 All ambers ON
2044 DB 81, 10, DA State 3
2047 DB 44, 44, F0 All ambers ON
204A 11, 08, B50 State 4
204D DB 88,88,00 State 5
2053 DB 44, 44, F0 All ambers ON
2056 DB 00 Dummy
RESULT:
Thus, simulation of traffic light control has been performed and output has been generated.
PAGE NO: 54