Addition Subtraction

Addition Subtraction

<p>EXPT NO: DATE:</p><p>ADDITION & SUBTRACTION</p><p>AIM To write assembly language program for performing addition and subtraction operation of two byte numbers.</p><p>APPARATUS REQUIRED: SL.NO ITEM SPECIFICATION QUANTITY</p><p>1. Microprocessor kit 8086 kit 1 2. Power Supply +5 V dc 1 3. Keyboard 1</p><p>ALGORITHM: (i ) 16 - b i t a dd i t i o n 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 - b i t s ub t r a ctio n 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. (i) Mu lti p lic a ti o n o f 16 - b i t n umb ers : a) Get the multiplier. b) Get the multiplicand c) Initialize the product to 0. d) Product = product + multiplicand e) Decrement the multiplier by 1 f) If multiplicand is not equal to 0, repeat from step (d) otherwise store the product. (ii) D i v i s io n o f 1 6 - b i t n u m b e r s . a) Get the dividend b) Get the divisor c) Initialize the quotient to 0. d) Dividend = dividend – divisor e) If the divisor is greater, store the quotient. Go to step g. f) If dividend is greater, quotient = quotient + 1. Repeat from step (d) g) Store the dividend value as remainder. FLOWCHART ADDITION SUBTRACTION</p><p>START START</p><p>SET UP COUNTER (CY) SET UP COUNTER (CARRY)</p><p>GET FIRST OPERAND GET FIRST OPERAND TO A</p><p>GET SECOND OPERAND SUBTRACT TO A SECOND OPERAND FROM MEMORY</p><p>YES A = A + B IS THERE ANY CY YES NO IS THERE COUNTER = ANY CARRY COUNTER + 1 COUNTER = COUNTER + 1 STORE THE DIFFERENCE NO</p><p>STORE THE SUM STORE THE CARRY</p><p>STORE THE CARRY STOP</p><p>STOP MULTIPLICATION DIVISION</p><p>Start Start</p><p>Load Divisor & Dividend Get Multiplier & Multiplicand</p><p>REGISTER=00 QUOTIENT = 0</p><p>DIVIDEND = DIVIDEND - DIVISOR REGISTER = REGISTER + MULTIPLICAND</p><p>QUOTIENT = QUOTIENT + 1 Multiplier=MULTIPLIER – 1</p><p>IS IS NO NO MULTIPLIER DIVIDEND < =0? DIVISIOR?</p><p>YES STORE THE RESULT YES</p><p>STORE QUOTIENT STORE REMAINDER = DIVIDEND NOW STOP STOP ADDITION PROGRAM COMMENTS</p><p>MOV CX, 0000H Reset counter CX</p><p>MOV AX,[1200] Get the first data in AX reg</p><p>MOV BX, [1202] Get the second data in BX reg</p><p>ADD AX,BX Add the contents of both the regs AX & BX and store the result in AX JNC L1 Check for carry</p><p>INC CX If carry exists, increment the CX by 1</p><p>L1 MOV [1206],CX Store the carry in CX</p><p>MOV [1204], AX Store the sum in AX</p><p>INT 3 Stop the program</p><p>SUBTRACTION PROGRAM COMMENTS</p><p>MOV CX, 0000H Reset counter CX</p><p>MOV AX,[1200] Get the first data in AX reg</p><p>MOV BX, [1202] Get the second data in BX reg</p><p>SUB AX,BX Subtract the contents of BX from AX and store the result in AX JNC L1 Check for borrow</p><p>INC CX If borrow exists, increment the CX</p><p>L1 MOV [1206],CX Store the borrow</p><p>MOV [1204], AX Store the difference</p><p>INT 3 Stop the program MULTIPLICATION</p><p>PROGRAM COMMENTS</p><p>MOV AX,[1200] Get the first data</p><p>MOV BX, [1202] Get the second data</p><p>MUL BX Multiply both</p><p>MOV [1206],AX Store the lower order product</p><p>MOV [1208],DX Store the higher order product</p><p>INT 3 Stop the program</p><p>DIVISION</p><p>PROGRAM COMMENTS</p><p>MOV AX,[1200] Get the first data (Dividend)</p><p>MOV DX, [1202] Initialize DX register with 0000h</p><p>MOV BX, [1204] Get the second data(Divisor)</p><p>DIV BX Divide the dividend by divisor</p><p>MOV [1206],AX Store the Quotient</p><p>MOV [1208],DX Store the remainder</p><p>INT 3 Stop the program OUTPUT:</p><p>ADDITION- With carry/without carry</p><p> input output</p><p>MEMORY</p><p>DATA</p><p>SUBTRACTION-with borrow/without borrow</p><p>MEMORY</p><p>DATA</p><p>MULTIPLICATION</p><p>MEMORY</p><p>DATA</p><p>DIVISON</p><p>MEMORY</p><p>DATA</p><p>RESULT:</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us