| Routines

384A: THE 'SQUARE ROOT' FUNCTION (offset +28)

The address of this routine is found in the table of addresses. It is called via the calculator literal +28 by the routines at CD_PRMS1 and asn. It is also called indirectly via fp_calc_2. This subroutine handles the function SQR X and returns the positive square root of the real number X if X is positive, and zero if X is zero. A negative value of X gives rise to report A - invalid argument (via to_power). This subroutine treats the square root operation as being X**0.5 and therefore stacks the value 0.5 and proceeds directly into to_power.
sqr | 384A | RST $28 | X
| 384B | DEFB $31 | duplicate: X, X
| 384C | DEFB $30 | f_not: X, (1/0)
| 384D | DEFB $00 | jump_true to LAST: X
| 384E | DEFB $1E
The jump is made if X=0; otherwise continue with:
| 384F | DEFB $A2 | stk_half: X, 0.5
| 3850 | DEFB $38 | end_calc
Continue into to_power to find the result of X**0.5.