Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

8086 program to find the square root of a perfect square root number | Set-2

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Prerequisite – 8086 program to find Square Root of a number Problem – Write a program to find the square root of a perfect number where starting address for code is 2000 and number is stored at 3000 memory address and store result into 3002 memory address. Example – Algorithm –

  1. Move 0000 to register CX immediately
  2. Move value of memory 3000 into register BX
  3. Move CX into AX
  4. Multiply value of accumulator with CX
  5. Compare AX with BX
  6. Jump if zero to step
  7. Increase CX register by 1
  8. Jump if no zero to step 3
  9. Move content of register CX into memory 3002
  10. Stop

Program –

MemoryMnemonicsOperandsComment
2000MOVCX, 0000[CX] <- 0000
2003MOVBX, [3000][BX] <- [3000]
2007MOVAX, CX[AX] <- [CX]
2009MULCX[AX] <- [AX] * [CX]
200BCMPAX, BX[AX] – [BX]
200DJZ2015Jump if zero
2010INCCX[CX] <- [CX] + 1
2012JNZ2007Jump if not zero
2015MOV[3002], CX[3002] <- CX
2019HLT Stop

Explanation – Registers AX, BX, CX, are used for general purpose.

  1. MOV is used to transfer the data
  2. INC is used to increase given register by 1
  3. JNZ is used to jump to the given step if there is no zero
  4. JZ is used to jump to the given step if there is zero
  5. MUL is used to multiply value of AX with the given register
  6. CMP is used to compare the value of two registers
  7. HLT is used to halt the program
My Personal Notes arrow_drop_up
Last Updated : 15 Sep, 2022
Like Article
Save Article
Similar Reads