8051 Square Root of a Given Number

Square Root of a Given Number

THEORY:

  • A square root of a number a is a number y such that y2 = a, or, in other words, a number y whose square (the result of multiplying the number by itself, or y × y) is a. For example, 3 is a square root of 09 because 32 = 09.
  • 8 bit square root number for follows  

INPUT:

  • 8600        09H

OUTPUT:

  • 8700        03H 

PROGRAM:

ADDRESSOPCODESMNEMONICS 
850090 86 00MOV DPTR,#8600 
8503E0MOVX A,@DPTR 
8504F9MOV R1,A 
85057A 01MOV R2,#01 
8507E9LOOP:      MOV A,R1 
85088A F0MOV F0,R2 
850A84DIV AB 
850BFBMOV R3,A 
850CAC F0MOV R4,F0 
850E9ASUBB A,R2 
850F60 03JZ RESULT 
85110AINC R2 
851280 F3SJMP LOOP 
851490 87 00RESULT:   MOV DPTR,#8700 
8517EBMOV A,R3 
8518F0MOVX @DPTR,A 
851980 FEHERE:       SJMP HERE 

You may also like...

error: Content is protected !!