Multi byte Addition and Subtraction using BCD numbers (8086)


Program for Multi byte Addition and Subtraction using BCD numbers (8086)

Description:

This program adds and subtracts two 64 bits (8bytes) signed BCD numbers using 8086 instructions.

Program:

NAME                   ADDSUBBCD

TITLE                    8086 ALP FOR MULTIBYTE ADDITION/SUBTRACTION

VALUES               SEGMENT

N1      DB      12H,23H,34H,45H,56H,67H,78H,89H

N2      DB      12H,23H,34H,45H,56H,67H,78H,89H

S       DB      8 DUP (0)

D       DB      8 DUP (0)

VALUES               ENDS

CODES           SEGMENT

ASSUME CS: CODES, DS: VALUES

ADDSUB:         MOV     AX, VALUES

MOV     DS, AX

MOV      CX, 8

MOV      BX,7

CLC

ADDAGN:         MOV     AL, N1[BX]

ADC       AL, N2[BX]

DAA

MOV     S[BX], AL

DEC       BX

LOOP     ADDAGN

MOV      CX, 8

MOV      BX, 7

CLC

SUBAGN:         MOV     AL, N1[BX]

SBB        AL, N2[BX]

DAS

MOV     D[BX], AL

DEC       BX

LOOP     SUBAGN

INT         3

CODES           ENDS

END       ADDSUB

Advertisements

One thought on “Multi byte Addition and Subtraction using BCD numbers (8086)

Comments are closed.