Calculate Square Roots
Find out the square root of the 16-bit number.
; +-----------------------------------------------------------------+; | Purpose: Find out the square root of the 16-bit number |; | 8-Bit version by Joao Dartagnan Antunes Oliveira (04/20/1993) |; | 16-Bit modification by Bruno Marcio Diogo Venancio (08/10/2007) |; | Email: bruno.marcio@bol.com.br |; | Brazil v1.1 |; | Input: B (MSB) and A (LSB) (binary) |; | Output: A |; | Destroy : R02,R03,R04,R05,R06,R07 |; | THIS CODE CAN BE FREELY DISTRIBUTED WITHOUT CHANGES |; +-----------------------------------------------------------------+;COUNT_L:EQUR02COUNT_H:EQUR03ACC_L:EQUR04ACC_H:EQUR05X_L:EQUR06X_H:EQUR07ORG#0x0000;; Test Routine;LOOP:MOVA#0x4000MOVB#0x4000CALLSQRTBI; SQRT(40000)=200SJMP$LOOP;; METHOD:;; Add in one accumulator an odd number counter until it cotains a value great or; equal than X , at this moment, the counter value divided for 2 will be SQRT(X);SQRTBI:MOVX_LAMOVX_HBMOVCOUNT_L#0x0001; COUNTER <- 1MOVCOUNT_H#0x0000MOVACC_L#0x0000; ACUMULATOR <- 0MOVACC_H#0x0000RET