×

Close

- Microprocessor and Microcontroller - MPMC
- Practical
**Priyadarshini Institute of Engg. & Technology - P.I.E.T.**- Electrical and Electronics Engineering
**380 Views**- 6 Offline Downloads
- Uploaded 1 year ago

EXPT NO: 8086 PROGRAMMING DATE: ADDITION & SUBTRACTION AIM: To write an Assembly Language Program (ALP) for performing the addition and subtraction operation of two byte numbers. APPARATUS REQUIRED: SL.N O 1. 2. ITEM Microprocessor kit Power Supply SPECIFICATION 8086 kit +5 V dc QUANTITY 1 1 PROBLEM STATEMENT: Write an ALP in 8086 to add and subtract two byte numbers stored in the memory location 1000H to 1003H and store the result in the memory location 1004H to 1005H.Also provide an instruction in the above program to consider the carry also and store the carry in the memory location 1006H. ALGORITHM: (i) 16-bit addition h) Initialize the MSBs of sum to 0 i) Get the first number. j) Add the second number to the first number. k) If there is any carry, increment MSBs of sum by 1. l) Store LSBs of sum. m) Store MSBs of sum. (ii) 16-bit subtraction f) Initialize the MSBs of difference to 0 g) Get the first number h) Subtract the second number from the first number. i) If there is any borrow, increment MSBs of difference by 1. j) Store LSBs of difference k) Store MSBs of difference.

FLOWCHART ADDITION SUBTRACTION START START SET UP COUNTER (CY) SET UP COUNTER (CARRY) GET FIRST OPERAND GET FIRST OPERAND TO A GET SECOND OPERAND TO A SUBTRACT SECOND OPERAND FROM MEMORY YES A=A+B IS THERE ANY CY YES NO IS THERE ANY CARRY COUNTER = COUNTER + 1 NO STORE THE SUM STORE THE CARRY COUNTER = COUNTER + 1 STORE THE DIFFERENCE STORE THE CARRY STOP STOP 2

ADDITION PROGRAM COMMENTS MOV CX, 0000H Initialize counter CX MOV AX,[1200] Get the first data in AX reg MOV BX, [1202] Get the second data in BX reg ADD AX,BX Add the contents of both the regs AX & BX JNC L1 Check for carry INC CX If carry exists, increment the CX L1 : MOV [1206],CX Store the carry MOV [1204], AX Store the sum HLT Stop the program SUBTRACTION PROGRAM COMMENTS MOV CX, 0000H Initialize counter CX MOV AX,[1200] Get the first data in AX reg MOV BX, [1202] Get the second data in BX reg SUB AX,BX Subtract the contents of BX from AX JNC L1 Check for borrow INC CX If borrow exists, increment the CX L1 : MOV [1206],CX Store the borrow MOV [1204], AX Store the difference HLT Stop the program 3

RESULT:. ADDITION MEMORY DATA SUBTRACTION MEMORY DATA MANUAL CALCULATION Thus addition & subtraction of two byte numbers are performed and the result is stored. 4

## Leave your Comments