;This is the program to find out the square root of the ;given 8-bit number by traditional shift & sub method. ;The number is logically extended to 16-bit number & ;is stored in r0 & r1.The final answer is stored in ;r2.The 8-bit number will have 4-bit square rooot. numh equ 0 numl equ 1 sqrt equ 2 sub equ 3 cntr equ 4 org 100h ;initialisation. mov numh,#0 mov numl,#121 mov sqrt,#0 mov cntr,#4 ;main loop. bck:mov a,sqrt; clr c; rlc a; setb c; rlc a; mov sub,a;sub=sqrt<<2. ;num=num<<2. clr c; mov a,numl; rlc a; mov numl,a mov a,numh; rlc a; mov numh,a; clr c; mov a,numl; rlc a; mov numl,a; mov a,numh; rlc a; mov numh,a; ;numh=numh-sub. clr c; subb a,sub; jc skip;if negative, skip. mov numh,a;else store the result. ;sqrt=sqrt<<1. skip:mov a,sqrt; cpl c;if answer is neg. pad lsb with 0. ;else pad with 1. rlc a; mov sqrt,a; djnz cntr,bck;loop back till the counter is exhausted. nop end