Está en la página 1de 6

EC2308: MICROPROCESSOR AND MICROCONTROLLER LAB

Exp. No:
Basic Arithmetic Operations on two 16-bit data
Date:

Aim:
To write an assembly language program to find the sum, difference and product of two 16-
bit numbers and to divide a 16-bit number by another 16-bit number.

Apparatus Required:
Intel 8086 based ESA 86 Trainer Kit.

Algorithm:

a. Sum of two 16-bit numbers

1 Initialize the BX register with the offset of the starting address of the data.
2 Initialize the CL register with 00H to monitor whether the result will have a
carry or not.
3 Move the first operand to Accumulator (AX) from external data memory.
4 Update the BX register to access the second operand.
5 Add the content Memory pointed by BX Register with the current content of
Accumulator.
6 Check whether there is a carry. If there is no carry jump to Step 8 otherwise
continue.
7 Increment CL register content by 1.
8 Update the BX register to store the results.
9 Move the content of Accumulator to the next external data memory locations.
10 Move the content of CL register in to the next external data memory location.
11 Stop the program execution

b. Sum of two 16-bit numbers

1 Initialize the BX register with the offset of the starting address of the data.
2 Initialize the CL register with 00H to monitor whether the result will have a
borrow or not.
3 Move the first operand to Accumulator (AX) from external data memory.
4 Update the BX register to access the second operand.
5 Subtract the content Memory pointed by BX Register with the current content of
Accumulator.
6 Check whether there is a carry. If there is no carry jump to Step 9 otherwise
continue.
7 Find the two’s complement of Accumulator content
8 Increment CL register content by 1.
9 Update the BX register to store the results.
10 Move the content of Accumulator to the next external data memory locations.
11 Move the content of CL register in to the next external data memory location.
12 Stop the program execution.

1
EC2308: MICROPROCESSOR AND MICROCONTROLLER LAB

c. Product of two 16-bit numbers

1 Initialize the SI register with the offset of the starting address of the data.
2 Move the first operand to Accumulator (AX) from external data memory.
3 Update the SI register to access the second operand.
4 Multiply the content Memory pointed by SI Register with the content of
Accumulator.
5 Update the SI register to store the results.
6 Move the content of Accumulator (AX) to the next external data memory
locations. (lower word of product)
7 Move the content of DX register in to the next external data memory locations.
(higher word of product)
8 Stop the program execution

d. Division Operation of two 16-bit numbers

1 Initialize the SI register with the offset of the starting address of the data.
2 Move the first operand to Accumulator (AX) from external data memory.
3 Convert the word operand in AX register to double word operand.
4 Update the SI register to access the second operand.
5 Divide the content of Accumulator by the content Memory pointed by SI
Register.
6 Update the SI register to store the results.
7 Move the content of Accumulator (AX) to the next external data memory
locations. (quotient)
8 Move the content of DX register in to the next external data memory locations.
(remainder)
9 Stop the program execution

2
EC2308: MICROPROCESSOR AND MICROCONTROLLER LAB
Program Name: 8086 – Basic Arithmetic Operations on 16-bit Binary Data

Address Hex codes Label Mnemonic Operands Comments

a. Sum of two 16-bit binary data


2000 B1 00 MOV CL, 00H [CL] ← 00 H

2002 BB 00 30 MOV BX, 3000H [BX] ← 3000 H

2005 8B 07 MOV AX, [BX] [AX] ← [ [BX] ]

[AX] ←
2007 03 47 02 ADD AX, [BX]+02H [AX] + [ [BX]+02 ]
Check for carry
200A 73 02 JNC SKIP flag
Increment CL reg.
200C FE C1 INC CL by 1

200E 89 47 04 SKIP MOV [BX]+04H, AX [[BX]+04] ← [AX]

2011 88 4F 06 MOV [BX]+06H, CL [[BX]+04] ← [CL]

2014 F4 HLT Halt

b. Difference of two 16-bit binary data


2000 B1 00 MOV CL, 00H [CL] ← 00 H

2002 BB 00 30 MOV BX, 3000H [BX] ← 3000 H

2005 8B 07 MOV AX, [BX] [AX] ← [ [BX] ]

[AX] ←
2007 2B 47 02 SUB AX, [BX]+02H [AX] - [ [BX]+02 ]
Check for carry
200A 73 04 JNC SKIP flag
Take 2’s
200C F7 D8 NEG AX complement of
[AX]
Increment CL reg.
200E FE C1 INC CL by 1

2010 89 47 04 SKIP MOV [BX]+04H, AX [[BX]+04] ← [AX]

2013 88 4F 06 MOV [BX]+06H, CL [[BX]+04] ← [CL]

2016 F4 HLT Halt

Page …….. of ………

3
EC2308: MICROPROCESSOR AND MICROCONTROLLER LAB

Program Name: 8086 – Basic Arithmetic Operations on 16-bit Binary Data

Address Hex codes Label Mnemonic Operands Comments

c. Product of two 16-bit binary data


2000 BE 00 30 MOV SI, 3000H [SI] ← 3000 H

2003 8B 04 MOV AX, [SI] [AX] ← [ [SI] ]

2005 8B 4C 02 MOV CX, [SI]+02H [CX] ← [ [SI]+02 ]

[DX.AX] ←
2008 F7 E1 MUL CX [AX] × [CX]

200A 89 44 04 MOV [SI]+04H, AX [[SI]+04] ← [AX]

200D 89 54 06 MOV [SI]+06H, DX [[SI]+06] ← [DX]

2010 F4 HLT Halt

d. Division Operation of two 16-bit binary data


2000 BE 00 30 MOV SI, 3000H [SI] ← 3000 H

2003 8B 04 MOV AX, [SI] [AX] ← [ [SI] ]

Extend the sign


2005 99 CWD bit of AX reg to
all bits of DX reg.

2006 8B 4C 02 MOV CX, [SI]+02H [CX] ← [ [SI]+02 ]

[AX.DX] ←
2009 F7 F1 DIV CX [AX] ÷ [CX]

200B 89 44 04 MOV [SI]+04H, AX [[SI]+04] ← [AX]

200E 88 54 06 MOV [SI]+06H, DX [[SI]+06] ← [DX]

2011 F4 HLT Halt

Page …….. of ………

4
EC2308: MICROPROCESSOR AND MICROCONTROLLER LAB

Sample Input & Output:

a. Sum of two 16-bit binary data

Data: Op1: 7867h and Op2: 9A89h


Input Output
Address (EA) Data Address (EA) Data
3000 67 3004 F0
3001 78 3005 12
3002 89 3006 01
3003 9A 3007
Result: Sum: 12F0 H and Carry: 01 H

b. Difference of two 16-bit binary data

Data: Op1: 9A89h and Op2: 7867h


Input Output
Address (EA) Data Address (EA) Data
3000 89 3004 22
3001 9A 3005 22
3002 67 3006 00
3003 78 3007
Result: Difference: 12F0 H and Borrow: 01 H

c. Product of two 16-bit binary data

Data: Op1: 7A89h and Op2: 2222h


Input Output
Address (EA) Data Address (EA) Data
3000 89 3004 1F
3001 7A 3005 65
3002 22 3006 AE
3003 22 3007 48
Result: Product: 48AE 651F H

5
EC2308: MICROPROCESSOR AND MICROCONTROLLER LAB

d. Division of 16-bit binary data by another 16-bit binary data

Data: Op1: 7A89h and Op2: 2222h


Input Output
Address (EA) Data Address (EA) Data
3000 89 3004 03
3001 7A 3005 00
3002 22 3006 23
3003 22 3007 14
Result: Quotient: 0003 h; Remainder: 1423 h

Result:

También podría gustarte