Wednesday, March 18, 2020

8086 Programs: Basic operations on two 16-bit numbers

Basic operations such as addition and subtraction will be performed on two 16-bit numbers using Assembly programming.

Addition of two 16-bit numbers

Aim: 

To perform the addition of two 16-bit numbers using Assembly language for 8086 microprocessor. 

Software Used:

MASM

Program Code:

CODE SEGMENT
        ORG 2000H
        MOV CL, 00H
        MOV BX, 3000H
        MOV AX, [BX]
        ADD AX, [BX]+02H
        JNC SKIP
        INC CL
SKIP: MOV [BX]+04H, AX
        MOV [BX]+06H, CL
        HLT
CODE ENDS
                END

Sample Input and Output:

Operand 1: 7867h
Operand 2: 9A89h

Input

Output

Address

Data

Address

Data

3000

67

3004

F0

3001

78

3005

12

3002

89

3006

01

3003

9A

 

 

Result: 

Sum = 12F0h, Carry = 01h


Subtraction of two 16-bit numbers

Aim: 

To perform the subtraction of two 16-bit numbers using Assembly language for 8086 microprocessor. 

Software Used:

MASM

Program Code:

CODE     SEGMENT
                MOV CL, 00H
                MOV BX, 3000H
                MOV AX, [BX]
                SUB AX, [BX]+02H
                JNC SKIP
                NEG AX
                INC CL
SKIP:     MOV [BX]+04H, AX
               MOV [BX]+06H, CL
               HLT
CODE    ENDS
               END

Sample Input and Output:

Operand 1: 9A89h
Operand 2: 7867h

Input

Output

Address

Data

Address

Data

3000

89

3004

22

3001

9A

3005

22

3002

67

3006

00

3003

78

 

 

Result: 

Difference = 2222h, Borrow = 00h

No comments:

Post a Comment