Open In App
Related Articles

8086 program to find Square Root of a number

Improve Article
Save Article
Like Article

Problem – Write an assembly language program in 8086 microprocessor to find square root of a number.

Example –

Algorithm –

  1. Move the input data in register AX
  2. Move the data 0000 in CX and FFFF in BX
  3. Add 0002 to the contents of BX
  4. Increment the content of CX by 1
  5. Subtract the contents of AX and BX
  6. If Zero Flag(ZF) is not set go to step 3 else go to step 7
  7. Store the data from CX to offset 600
  8. Stop
  9. Program –

    0400 MOV AX, [500] AX <- [500]
    0404 MOV CX, 0000 CX <- 0000
    0407 MOV BX, FFFF BX <- FFFF
    040A ADD BX, 02 BX = BX + 02
    040E INC CX C = C + 1
    040F SUB AX, BX AX = AX – BX
    0411 JNZ 040A JUMP to 040A if ZF = 0
    0413 MOV [600], CX [600] <- CX
    0417 HLT Stop

    Explanation –

    1. M0V AX, [500] is used to move the data from offset 500 to register AX
    2. MOV CX 0000 is used to move 0000 to register CX
    3. MOV BX FFFF is used to move FFFF to register BX
    4. ADD BX, 02 is used to add BX and 02
    5. INC CX is used to increment the content of CX by 1
    6. SUB AX, BX is used to subtract contents of AX with BX
    7. JNZ 040A is used to jump to address 040A if zero flag(ZF) is 0
    8. MOV [600], CX is used to store the contents of CX to offset 600
    9. HLT is used end the program
    Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

    Last Updated : 22 May, 2018
    Like Article
    Save Article
Similar Reads