Well, after checking my previous fixes, it seems that a person shouldn't do this sort of stuff late in the day. This version seems to check out. ;Square Root. ;Call with four byte number in n_a (ms).. n_d (ls) ;Two byte result in r_a (ms) r_b (ls) ;Also uses n_x, p_a, p_b, t_a, t_b, t_x ;56 program memory locations. ;Execution time, worst case about 760 clock cycles. sq_root: clrf n_x clrf r_a clrf r_b movlw b'10000000' movwf p_a clrf p_b root_loop: clrf t_x ;Set up next trial root bcf STATUS, C rrf p_a, w iorwf r_a, w movwf t_a rrf p_b, w iorwf r_b, w movwf t_b btfss STATUS, C ;Check for last bit goto ww btfss n_c, 7 ;'Subtract' incfsz t_b, w ;Propagate borrow goto ww incf t_a, f ww: ;Test trial root: n - r subwf n_b, w movwf t_b btfss STATUS, C incfsz t_a, f goto xx incf t_x, f xx: movf t_a, w subwf n_a, w movwf t_a btfss STATUS, C incf t_x, f yy: movf t_x, w subwf n_x, w bnc shift ;Branch if trial root too big movwf n_x ;Else save result movf t_a, w movwf n_a movf t_b, w movwf n_b movf p_a, w ;'Or' root with position bit iorwf r_a, f movf p_b, w iorwf r_b, f bcf STATUS, C shift: ;Shift position bit right rrf p_a, f rrf p_b, f bc done rlf n_d, f ;Shift number left rlf n_c, f rlf n_b, f rlf n_a, f rlf n_x, f goto root_loop done: return -- Bob Fehrenbach Wauwatosa, WI bfehrenb@execpc.com