mov ax,00A9 ;Find the square root of 169 ; ;Written for the Magic Assembler ;AX=Integer to find the square root of ;CX=Integer square root of AX ; @squareroot xor cx,cx ;Clear the result register mov bx,4000 @1 cmp bx,0 je @3 mov dx,cx add dx,bx shr cx,1 cmp dx,ax ja @2 sub ax,dx add cx,bx @2 shr bx,1 shr bx,1 jmp @1 @3 ;Quickie result display routine cmp cx,0 ;Finished? je @4 ;If so, then end. mov ax,cx ;Move remaining digits into AX and ax,000f ;Mask all except the first digit shl ax,1 ;Double the value to account for '$' characters shr cx,1 ;Shift right eight shr cx,1 ;times to remove the shr cx,1 ;current digit from shr cx,1 ;the next print shr cx,1 ;cycle and prep next shr cx,1 ;digit for display shr cx,1 ;or if finished, shr cx,1 ;zero the register. mov dx,offset(numbers) add dx,ax ;Point to the appropriate number mov ah,09 int 21 ;Print digit jmp @3 ;Repeat cycle @4 mov ah,4c int 21 ;End numbers db '0$1$2$3$4$5$6$7$8$9$A$B$C$D$E$F$'