CPU-Z80-Disassembler
view release on metacpan or search on metacpan
t/data/zx81.asm view on Meta::CPAN
; ---
;; SMALL
SMALL:
rst $28 ; FP-CALC
defb $A0 ; stk-zero
;
;; CASES
CASES:
defb $01 ; exchange
defb $2D ; duplicate
defb $2D ; duplicate
defb $04 ; multiply
defb $2D ; duplicate
defb $0F ; addition
defb $A1 ; stk-one
defb $03 ; subtract
;
defb $8C ; series-0C
defb $10 ; Exponent: $60, Bytes: 1
defb $B2 ; (+00,+00,+00)
defb $13 ; Exponent: $63, Bytes: 1
defb $0E ; (+00,+00,+00)
defb $55 ; Exponent: $65, Bytes: 2
defb $E4, $8D ; (+00,+00)
defb $58 ; Exponent: $68, Bytes: 2
defb $39, $BC ; (+00,+00)
defb $5B ; Exponent: $6B, Bytes: 2
defb $98, $FD ; (+00,+00)
defb $9E ; Exponent: $6E, Bytes: 3
defb $00, $36, $75 ; (+00)
defb $A0 ; Exponent: $70, Bytes: 3
defb $DB, $E8, $B4 ; (+00)
defb $63 ; Exponent: $73, Bytes: 2
defb $42, $C4 ; (+00,+00)
defb $E6 ; Exponent: $76, Bytes: 4
defb $B5, $09, $36, $BE ;
defb $E9 ; Exponent: $79, Bytes: 4
defb $36, $73, $1B, $5D ;
defb $EC ; Exponent: $7C, Bytes: 4
defb $D8, $DE, $63, $BE ;
defb $F0 ; Exponent: $80, Bytes: 4
defb $61, $A1, $B3, $0C ;
defb $04 ; multiply
defb $0F ; addition
defb $34 ; end-calc
;
ret ; return.
;
;
; ---------------------
; THE 'ARCSIN' FUNCTION
; ---------------------
; (Offset $1F: 'asn')
; The inverse sine function with result in radians.
; Derived from arctan function above.
; Error A unless the argument is between -1 and +1 inclusive.
; Uses an adaptation of the formula asn(x) = atn(x/sqr(1-x*x))
;
;
; /|
; / |
; 1/ |x
; /a |
; /----|
; y
;
; e.g. We know the opposite side (x) and hypotenuse (1)
; and we wish to find angle a in radians.
; We can derive length y by Pythagoras and then use ATN instead.
; Since y*y + x*x = 1*1 (Pythagoras Theorem) then
; y=sqr(1-x*x) - no need to multiply 1 by itself.
; So, asn(a) = atn(x/y)
; or more fully,
; asn(a) = atn(x/sqr(1-x*x))
; Close but no cigar.
; While PRINT ATN (x/SQR (1-x*x)) gives the same results as PRINT ASN x,
; it leads to division by zero when x is 1 or -1.
; To overcome this, 1 is added to y giving half the required angle and the
; result is then doubled.
; That is, PRINT ATN (x/(SQR (1-x*x) +1)) *2
;
;
; . /|
; . c/ |
; . /1 |x
; . c b /a |
; ---------/----|
; 1 y
;
; By creating an isosceles triangle with two equal sides of 1, angles c and
; c are also equal. If b+c+d = 180 degrees and b+a = 180 degrees then c=a/2.
;
; A value higher than 1 gives the required error as attempting to find the
; square root of a negative number generates an error in Sinclair BASIC.
;; asn
asn:
rst $28 ; FP-CALC x.
defb $2D ; duplicate x, x.
defb $2D ; duplicate x, x, x.
defb $04 ; multiply x, x*x.
defb $A1 ; stk-one x, x*x, 1.
defb $03 ; subtract x, x*x-1.
defb $18 ; negate x, 1-x*x.
defb $25 ; sqr x, sqr(1-x*x) = y.
defb $A1 ; stk-one x, y, 1.
defb $0F ; addition x, y+1.
defb $05 ; division x/y+1.
defb $21 ; atn a/2 (half the angle)
defb $2D ; duplicate a/2, a/2.
defb $0F ; addition a.
defb $34 ; end-calc a.
;
ret ; return.
( run in 1.248 second using v1.01-cache-2.11-cpan-39bf76dae61 )