Write and execute an alp to 8086 Microprocessor to add, subtract and multiply two 16 bit unsigned numbers. Store the result in extra segment
1. Addition of two 16-bit numbers
Aim:
To write an assembly language program to perform addition of two 16-bit signed and unsigned numbers.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AX, OPR1 ADD AX, OPR2 MOV RES, AX HLT CODE ENDS DATA SEGMENT OPR1 DW 4269H OPR2 DW 1000H RES DW ? DATA ENDS END
List file:
ADDRESS | OPCODE | OPERATION | COMMENTS |
---|---|---|---|
0000 | B88E4E | MOV AX,4E8E | INITIALIZATION OF DATA SEGMENT |
0003 | 8ED8 | MOV DS,AX | |
0005 | A10000 | MOV AX,[0000] | THE VALUE IN [0000] IS MOVED TO AX |
0008 | 03060200 | ADD AX,[0002] | THE VALUE IN [0002] IS ADDED TO AX |
000C | A30400 | MOV [0004],AX | THE VALUE IN AX IS MOVED TO [0004] |
000F | F4 | HLT | END OF PROGRAM |
Flow Chart:
Result:
UNSIGNED NUMBERS
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
Input:
OPR1 = 4269H OPR2 = 1000H
Output:
RES = 5269H
SIGNED NUMBERS
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
Input:
OPR1 = 9763H OPR2 = A973H
Output:
RES = 40D6H
2. Subtraction of two 16-bit numbers
Aim:
To write an assembly language program to perform subtraction of two 16-bit signed and unsigned numbers.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AX, OPR1 MOV BX, OPR2 SUB AX, BX MOV RES, AX HLT CODE ENDS DATA SEGMENT OPR1 DW 4269H OPR2 DW 1000H RES DW ? DATA ENDS END
List file:
ADDRESS | OPCODE | OPERATION | COMMENTS |
---|---|---|---|
0000 | B88E4E | MOV AX,4E8E | INITIALIZATION OF DATA SEGMENT |
0003 | 8ED8 | MOV DS,AX | |
0005 | A10000 | MOV AX,[0000] | THE VALUE IN [0000] IS MOVED TO AX |
0008 | 2B060200 | ADD AX,[0002] | THE VALUE IN [0002] IS SUBTRACTED FROM AX |
000C | A30400 | MOV [0004],AX | THE VALUE IN AX IS MOVED TO [0004] |
000F | F4 | HLT | END OF PROGRAM |
Flow Chart:
Result:
UNSIGNED NUMBERS
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
Input:
OPR1 = 4269H OPR2 = 1000H
Output:
RES = 3269H
SIGNED NUMBERS
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
Input:
OPR1 = 9763H OPR2 = 8973H
Output:
RES = 0DF0H
3. Multiplication of two 16-bit unsigned numbers
Aim:
To write an assembly language program to perform multiplication of two 16-bit unsigned numbers.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AX, OPR1 MUL OPR2 MOV RESLW, AX MOV RESHW, DX HLT CODE ENDS DATA SEGMENT OPR1 DW 2000H OPR2 DW 4000H RESLW DW ? RESHW DW ? DATA ENDS END
List file:
ADDRESS | OPCODE | OPERATION | COMMENTS |
---|---|---|---|
0000 | B88E4E | MOV AX,4E8E | INITIALIZATION OF DATA SEGMENT |
0003 | 8ED8 | MOV DS,AX | |
0005 | A10000 | MOV AX,[0000] | THE VALUE IN [0000] IS MOVED TO AX |
0008 | F7260200 | IMULWORD PTR [0002] | THE VALUE IN [0002] IS MULTIPLIED BY AX |
000C | A30400 | MOV [0004],AX | THE VALUE IN AX IS MOVED TO [0004] |
000F | 89160600 | MOV [0006],DX | THE VALUE IN DX IS MOVED TO [0006] |
0013 | F4 | HLT | END OF PROGRAM |
Flow Chart:
Result:
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
Input:
OPR1 = 2000H OPR2 = 4000H
Output:
RESLW = 0000H (AX) RESHW = 0800H (DX)
4. Multiplication of two 16-bit signed numbers.
Aim:
To write an assembly language program to perform multiplication of two 16-bit signed numbers.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AX, OPR1 IMUL OPR2 MOV RESLW, AX MOV RESHW, DX HLT CODE ENDS DATA SEGMENT OPR1 DW 7593H OPR2 DW 6845H RESLW DW ? RESHW DW ? DATA ENDS END
List File:
ADDRESS | OPCODE | OPERATION | COMMENTS |
---|---|---|---|
0000 | B88E4E | MOV AX,4E8E | INITIALIZATION OF DATA SEGMENT |
0003 | 8ED8 | MOV DS,AX | |
0005 | A10000 | MOV AX,[0000] | THE VALUE IN [0000] IS MOVED TO AX |
0008 | F72E0200 | IMULWORD PTR [0002] | THE VALUE IN [0002] IS ADDED TO AX |
000C | A30400 | MOV [0004],AX | THE VALUE IN AX IS MOVED TO [0004] |
000F | 89160600 | MOV [0006],DX | THE VALUE IN DX IS MOVED TO [0006] |
0013 | F4 | HLT | END OF PROGRAM |
Flow Chart:
Result:
Case 1: Two positive numbers
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
Input:
OPR1 = 7593H OPR2 = 6845H
Output:
RESLW = 689FH (AX) RESHW = 2FE3H (DX)
Case 2: one positive number & one negative number
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
Input:
OPR1 = 8A6DH <- 2’s Complement of (-7593H) OPR2 = 6845H
Output:
RESLW = 9761H (AX) <- 2’s Complement RESHW = D01CH (DX) <- of (-2FE3689FH)
Case 3: two negative numbers
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
Input:
OPR1 = 8A6DH <- 2’s Complement of (-7593H) OPR2 = 97BBH <- 2’s Complement of (-6845H)
Output:
RESLW = 689FH (AX) RESHW = 2FE3H (DX)
5. ASCII addition
Aim:
To write an ALP to perform the addition of two ASCII bytes.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AH, 00H MOV AL, CHAR ADD AL, CHAR1 AAA MOV RES, AX HLT CODE ENDS DATA SEGMENT CHAR DB '8' CHAR1 DB '6' RES DW ? DATA ENDS END
List file:
ADDRESS | OPCODE | OPERATION | COMMENTS |
---|---|---|---|
0000 | B88E4E | MOV AX,4E8E | INITIALIZATION OF DATA SEGMENT |
0003 | 8ED8 | MOV DS,AX | |
0005 | B400 | MOV AH,00 | 00H IS STORED IN AH |
0007 | A00000 | MOV AL,[0000] | THE VALUE IN [0000] IS MOVED TO AL |
000A | 02060100 | ADD AL,[0001] | THE VALUE IN [0001] IS ADDED TO AL |
000E | 37 | AAA | ASCII ADJUST AFTER ADDITION |
000F | A30200 | MOV [0002],AX | THE VALUE IN AX IS MOVED TO [0002] |
0012 | F4 | HLT | END OF PROGRAM |
Flow Chart:
Result:
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=1, s=0, z=0, o=0, p=1, a=1, i=1, d=0.
Input:
CHAR = '8' CHAR1 = '6'
Output:
RES = 0104 (AX) <- unpacked BCD of 14
6. ASCII substraction
Aim:
To write an ALP to perform the subtraction of two ASCII bytes.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AH, 00H MOV AL, CHAR SUB AL, CHAR1 AAS MOV RES, AX HLT CODE ENDS DATA SEGMENT CHAR DB '9' CHAR1 DB '5' RES DW ? DATA ENDS END
List file:
ADDRESS | OPCODE | OPERATION | COMMENTS |
---|---|---|---|
0000 | B88E4E | MOV AX,4E8F | INITIALIZATION OF DATA SEGMENT |
0003 | 8ED8 | MOV DS,AX | |
0005 | B400 | MOV AH,00 | 00H IS STORED IN AH |
0007 | A00000 | MOV AL,[0000] | THE VALUE IN [0000] IS MOVED TO AL |
000A | 2A060100 | SUB AL,[0001] | THE VALUE IN [0001] IS SUBTRACTED FROM AL |
000E | 3F | AAS | ASCII ADJUST AFTER SUBTRACTION |
000F | A30200 | MOV [0002],AX | THE VALUE IN AX IS MOVED TO [0002] |
0012 | F4 | HLT | END OF PROGRAM |
Flow Chat:
Result:
Case 1:
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
Input:
CHAR = ‘9’ CHAR1 = ‘5’
Output:
RES = 0004 (AX)
Case 2:
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=1, s=1, z=0, o=0, p=1, a=1, i=1, d=0.
Input:
CHAR = ‘5’ CHAR1 = ‘9’
Output:
RES = FF06 (AX) <- 2’s Complement of (-4)
7. ASCII multiplication
Aim:
To write an ALP to perform the multiplication of two ASCII bytes.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AH, 00 MOV AL, NUM1 MUL NUM2 AAM MOV RES, AX HLT CODE ENDS DATA SEGMENT NUM1 DB 09 NUM2 DB 05 RES DW ? DATA ENDS END
List file:
ADDRESS | OPCODE | OPERATION | COMMENTS |
---|---|---|---|
0000 | B88E4E | MOV AX,4E8F | INITIALIZATION OF DATA SEGMENT |
0003 | 8ED8 | MOV DS,AX | |
0005 | B400 | MOV AH,00 | 00H IS STORED IN AH |
0007 | A00000 | MOV AL,[0000] | THE VALUE IN [0000] IS MOVED TO AL |
000A | F6260100 | MUL BYTE PTR [0001] | THE VALUE IN [0001] IS MULTIPLIED BY AL |
000E | D40A | AAM | ASCII ADJUST AFTER MULTIPLCATION |
000F | A30200 | MOV [0002],AX | THE VALUE IN AX IS MOVED TO [0002] |
0012 | F4 | HLT | END OF PROGRAM |
Flow Chart:
Result:
Flags:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0. After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
Input:
NUM1 = 09 NUM2 = 05
Output:
RES = 0405 (AX) <- unpacked BCD of 45
8. ASCII division
Aim:
To write an ALP to perform the division of two ASCII numbers.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AX, DIVIDEND AAD MOV CH, DIVISOR DIV CH MOV RESQ, AL MOV RESR, AH HLT CODE ENDS DATA SEGMENT DIVIDEND DW 0607H DIVISOR DB 09H RESQ DB ? RESR DB ? DATA ENDS END
List file:
ADDRESS | OPCODE | OPERATION | COMMENTS |
---|---|---|---|
0000 | B88F4E | MOV AX,4E8F | INITIALIZATION OF DATA SEGMENT |
0003 | 8ED8 | MOV DS,AX | |
0005 | A10000 | MOV AH,[0000] | THE VALUE IN [0000] IS MOVED TO AX |
0008 | D50A | AAD | ASCII ADJUST FOR DIVIDION |
000A | 8A2E0200 | MOV CH,[0002] | THE VALUE IN [0002] IS MOVED TO CH |
000E | F6F5 | DIV CH | AX IS DIVIDED BY CH |
0010 | A20300 | MOV [0003],AL | THE VALUE IN AL IS MOVED TO [0003] |
0013 | 88260400 | MOV [0002],AH | THE VALYE IN AH IS MOVED TO [0004] |
0017 | F4 | HLT | END OF PROGRAM |
Flow Chart:
Viva-voce questions:
1. What is meant by microprocessor? 2. What are the main blocks of the microprocessor? 3. What is the word size of the 8086 µP? 4. What are the other possibilities of writing add, sub and mul instructions in other addressing modes? 5. What are the memory locations of results of addition, subtraction and multiplication?
-
UpdatedDec 08, 2019
-
Views56,934
Write and execute an alp to 8086 Microprocessor to add, subtract and multiply two 16 bit unsigned numbers. Store the result in extra segment
Write and execute an alp to 8086 Microprocessor to a sort the give array of 32 bit number in ascending and descending order.
Program to generate following waveforms
- Ramp waveform
- Square waveform
- Step waveform
- Triangle waveform
Write and execute an alp to 8086 Microprocessor to find the length of a given string which terminates with a special character
Write and execute an alp to 8086 Microprocessor to divide a 32 bit unsigned numbers by a 16 bit unsigned number. Store the result in stack segment
Interface a stepper motor to 8086 and operate it in clock wise and anticlockwise by choosing variable stepsize.