Home » Archimedes archive » Micro User » MU 1992-05.adf » PD » Fractal/!Fractal/Asm/SampNewton

Fractal/!Fractal/Asm/SampNewton

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Micro User » MU 1992-05.adf » PD
Filename: Fractal/!Fractal/Asm/SampNewton
Read OK:
File size: 17DF bytes
Load address: 0000
Exec address: 0000
File contents
   10REM > <Frac$Dir>.Asm.SampNewton
   20REM Newton : z*z*z-1=0 plotter
   30REM Algorithm from Becker & Dorfler
   40LIBRARY "<Frac$Dir>.Asm.Fraclib":PROCfracvars
   50LIBRARY "<Frac$Dir>.Asm.FPlib":PROCfpinit
   60LIBRARY "<Frac$Dir>.Asm.FPElib"
   70REM === Function specific code follows
   80newton=0:nvarstart=0:nvarend=0:REM initialise to a dummy value
   90REM === End of function specific code
  100DIM code% 10000
  110FOR asm=4 TO 7 STEP 3
  120P%=0:O%=code%
  130[OPT asm
  140; Following is the list of fractal functions in this module
  150FNfrachdr ; Identify ourselves as a fractal module
  160;
  170; One or more function definition pointers follow
  180DCD newton_func
  190;
  200DCD -1 ; End of functions
  210;--------------------------------------------------------------
  220; Now we define Newton's characteristics
  230;
  240.newton_func FNfracfunc("SampNewton",newton,fZoom+fheight+fxy,0,5,nvarend-nvarstart)
  250;
  260; Newton's Variables after here
  270.nvarstart
  280FNafg2var(AFG_dbl,0,8):.nx0 FNfp("DFD -2.00")
  290FNafg2var(AFG_dbl,0,8):.ny0 FNfp("DFD -1.60")
  300FNafg2var(AFG_dbl,0,8):.nw FNfp("DFD 4.0")
  310FNafg2var(AFG_dbl,0,8):.nh FNfp("DFD 3.2")
  320FNafg2var(AFG_int,0,4):.niter DCD 128
  330.nvarend ; End of variables
  340;
  350; Variable names after here; 1 for each variable above
  360FNvarname("         x0")
  370FNvarname("         y0")
  380FNvarname("      width")
  390FNvarname("     height")
  400FNvarname("  Max. Iter")
  410;-------------------------------------
  420; The entry point to Newton
  430.newton
  440FNfenter ; Initialise
  450; R0=Fractal Event, R1=Address of Data
  460MOV R9,#0
  470STR R9,[R1,#fevent_rc] ; clear return code
  480CMP R0,#fplotinit
  490BEQ nplotinit
  500CMP R0,#fdatainit
  510BEQ ndatainit
  520CMP R0,#fdatachk
  530BEQ ndatachk
  540; Unsupported event - just return
  550FNfexit
  560;
  570; Init Newton data
  580.ndatainit
  590FNfp("LDFD F0,inx")
  600FNfp("STFD F0,nx0")
  610FNfp("LDFD F0,iny")
  620FNfp("STFD F0,ny0")
  630FNfp("LDFD F0,inw")
  640FNfp("STFD F0,nw ")
  650FNfp("LDFD F0,inh")
  660FNfp("STFD F0,nh ")
  670LDR R0,initer
  680STR R0,niter
  690FNfexit
  700.inx FNfp("DFD -2.00") ; Initial values
  710.iny FNfp("DFD -1.60")
  720.inw FNfp("DFD 4.0")
  730.inh FNfp("DFD 3.2")
  740.initer DCD 128
  750;
  760; Verify data input or zoom range
  770.ndatachk
  780FNfp("LDFD F0,nx0")
  790FNfp("CMFD F0,#4")
  800BGT nbaddata            ; x0 too large
  810FNfp("CNFD F0,#4")      ; <-4?
  820BLT nbaddata            ; x0 too small
  830FNfp("LDFD F0,ny0")
  840FNfp("CMFD F0,#4")
  850BGT nbaddata            ; y0 too large
  860FNfp("CNFD F0,#4")      ; <-4?
  870BLT nbaddata            ; y0 too small
  880;
  890; For width & height, check not smaller than integer fp range.
  900FNfp("LDFD F1,ninint")  ; smallest value for fp integer
  910FNfp("LDFD F0,nw ")
  920FNfp("CMFD F0,#4")
  930BGT nbaddata            ; w too large
  940FNfp("CMFD F0,F1")     ; within accuracy range?
  950BLT nbaddata            ; w too small
  960FNfp("LDFD F0,nh ")
  970FNfp("CMFD F0,#4")
  980BGT nbaddata           ; h too large
  990FNfp("CMFD F0,F1")     ; within accuracy range?
 1000BLT nbaddata           ; h too small
 1010;
 1020; Verify maxiter not too small
 1030LDR R0,niter
 1040CMP R0,#10             ; too small?
 1050MOVLT R0,#10
 1060STRLT R0,niter         ; yes - set to 10
 1070FNfexit
 1080;
 1090.nbaddata
 1100MOV R0,#1
 1110STR R0,[R1,#fevent_rc] ; set return code
 1120FNfexit
 1130
 1140.ninint FNfp("DFD 1e-5")
 1150;-------------------------------------
 1160; Initialise ready for a plot
 1170.nplotinit
 1180LDR R0,[R1,#plot_flags]
 1190ORR R0,R0,#plot_ffp     ; fast float maths
 1200STR R0,[R1,#plot_flags] ; tell Fractal
 1210ADR R0,newtonfp
 1220STR R0,newton_func+fdefn_xyrtn  ; Our plot routine
 1230FNfexit
 1240;----------------------------------
 1250]
 1260REM newton registers
 1270REM x & y set on entry
 1280x=2:y=3:xy=4:x2=5:y2=6:wrk1=7:wrk2=8:wrk3=9:root=10:e=11:depth=12
 1290[OPT asm
 1300.newtonfp
 1310STMFD R13!,{R14}        ; Return address
 1320MOV x,R0
 1330MOV y,R1
 1340FNfp_sqr(y2,y)          ; y*y
 1350LDR e,newton_e          ; epsilon
 1360LDR depth,niter
 1370MOV root,#0
 1380.nloop                  ; do for each iteration
 1390FNfp_mul(xy,x,y)        ; x*y
 1400ADD xy,xy,#1<<23        ; 2*x*y
 1410;
 1420FNfp_sqr(x2,x)          ; x*x
 1430MOV R1,y2
 1440BL fp_add               ; x*x+y*y
 1450MOVS R1,R0
 1460BEQ nexit               ; too small
 1470BL fp_sqr               ; d4=(x*x+y*y)*(x*x+y*y)
 1480LDR R1,fp_three
 1490BL fp_mul               ; 3*d4
 1500MOVS wrk1,R0
 1510BEQ nexit               ; underflow
 1520; calc new x
 1530LDR R1,twothird
 1540FNfp_mul(wrk2,x,1)      ; x*2/3
 1550FNfp_sub(0,x2,y2)       ; x*x-y*y
 1560FNfp_div(0,0,wrk1)      ; (x*x-y*y)/d4
 1570FNfp_add(x,0,wrk2)      ; x=x*2/3+(x2-y2)/d4
 1580; calc new y
 1590FNfp_div(wrk2,xy,wrk1)  ; (2*x*y)/d4
 1600LDR R1,twothird
 1610FNfp_mul(0,y,1)         ; y*2/3
 1620FNfp_sub(y,0,wrk2)      ; y=y*2/3-(2*x*y)/d4
 1630;
 1640FNfp_sqr(y2,y)          ; y*y
 1650; Check for root=1
 1660MOV R1,#127<<23         ; 1.0
 1670FNfp_sub(0,x,1)         ; x-1
 1680FNfp_sqr(0,0)           ; (x-1)*(x-1)
 1690FNfp_add(0,0,y2)        ; (x-1)*(x-1)+y2
 1700CMP R0,e                ; ((x-1)*(x-1)+y2)<e?
 1710MOVLT root,#1
 1720BLT nexit               ; root=1
 1730; Check for root=2
 1740MOV R1,#126<<23         ; 0.5
 1750FNfp_add(0,x,1)         ; x+0.5
 1760FNfp_sqr(wrk1,0)        ; xr=(x+0.5)*(x+0.5)
 1770LDR wrk2,newton_r2
 1780FNfp_sub(0,y,wrk2)      ; y-0.8660254
 1790FNfp_sqr(0,0)           ; yr=(y-0.8660254)*(y-0.8660254)
 1800FNfp_add(0,wrk1,0)      ; xr+yr
 1810CMP R0,e                ; Root 2?
 1820MOVLT root,#2
 1830BLT nexit
 1840; Check for root=3
 1850FNfp_add(0,y,wrk2)      ; y+0.8660254
 1860FNfp_sqr(0,0)           ; yr=(y+0.8660254)*(y+0.8660254)
 1870FNfp_add(0,wrk1,0)      ; xr+yr
 1880CMP R0,e                ; Root 3?
 1890MOVLT root,#3
 1900BLT nexit
 1910;
 1920SUBS depth,depth,#1
 1930BNE nloop
 1940LDR depth,niter         ; No colour if at max
 1950.nexit
 1960LDR R0,niter
 1970SUB R0,R0,depth         ; return colour
 1980ADD R0,R0,#16           ; avoid dark colours
 1990LDMFD R13!,{PC}^        ; exit
 2000;
 2010.twothird FNfp("DFS 0.66666666")
 2020.newton_e FNfp("DFS 0.0025")
 2030.newton_r2 FNfp("DFS 0.8660254")
 2040.fp_three FNfp("DFS 3.0")
 2050;--------------------------
 2060FNfinterface            ; Necessary C Interface code
 2070FNfpeasm(FALSE)         ; FPE routines
 2080]:NEXT
 2090SYS "OS_File",10,"<Frac$Dir>.SampNewton",&FFA,,code%,O%
 2100END
!� > <Frac$Dir>.Asm.SampNewton
 � Newton : z*z*z-1=0 plotter
%� Algorithm from Becker & Dorfler
()ț "<Frac$Dir>.Asm.Fraclib":�fracvars
2%ț "<Frac$Dir>.Asm.FPlib":�fpinit
<ț "<Frac$Dir>.Asm.FPElib"
F(� === Function specific code follows
P@newton=0:nvarstart=0:nvarend=0:� initialise to a dummy value
Z'� === End of function specific code
d� code% 10000
n� asm=4 � 7 � 3
xP%=0:O%=code%
�[OPT asm
�?; Following is the list of fractal functions in this module
�5�frachdr ; Identify ourselves as a fractal module
�;
�5; One or more function definition pointers follow
�DCD newton_func
�;
�DCD -1 ; End of functions
�C;--------------------------------------------------------------
�,; Now we define Newton's characteristics
�;
�W.newton_func �fracfunc("SampNewton",newton,fZoom+fheight+fxy,0,5,nvarend-nvarstart)
�;
#; Newton's Variables after here
.nvarstart
/�afg2var(AFG_dbl,0,8):.nx0 �fp("DFD -2.00")
"/�afg2var(AFG_dbl,0,8):.ny0 �fp("DFD -1.60")
,,�afg2var(AFG_dbl,0,8):.nw �fp("DFD 4.0")
6,�afg2var(AFG_dbl,0,8):.nh �fp("DFD 3.2")
@(�afg2var(AFG_int,0,4):.niter DCD 128
J.nvarend ; End of variables
T;
^:; Variable names after here; 1 for each variable above
h�varname("         x0")
r�varname("         y0")
|�varname("      width")
��varname("     height")
��varname("  Max. Iter")
�*;-------------------------------------
�; The entry point to Newton
�.newton
��fenter ; Initialise
�*; R0=Fractal Event, R1=Address of Data
�
MOV R9,#0
�.STR R9,[R1,#fevent_rc] ; clear return code
�CMP R0,#fplotinit
�BEQ nplotinit
�CMP R0,#fdatainit
�BEQ ndatainit
CMP R0,#fdatachk
BEQ ndatachk
%; Unsupported event - just return
&
�fexit
0;
:; Init Newton data
D.ndatainit
N�fp("LDFD F0,inx")
X�fp("STFD F0,nx0")
b�fp("LDFD F0,iny")
l�fp("STFD F0,ny0")
v�fp("LDFD F0,inw")
��fp("STFD F0,nw ")
��fp("LDFD F0,inh")
��fp("STFD F0,nh ")
�LDR R0,initer
�STR R0,niter
�
�fexit
�*.inx �fp("DFD -2.00") ; Initial values
�.iny �fp("DFD -1.60")
�.inw �fp("DFD 4.0")
�.inh �fp("DFD 3.2")
�.initer DCD 128
�;
�%; Verify data input or zoom range

.ndatachk
�fp("LDFD F0,nx0")
�fp("CMFD F0,#4")
 *BGT nbaddata            ; x0 too large
*!�fp("CNFD F0,#4")      ; <-4?
4*BLT nbaddata            ; x0 too small
>�fp("LDFD F0,ny0")
H�fp("CMFD F0,#4")
R*BGT nbaddata            ; y0 too large
\!�fp("CNFD F0,#4")      ; <-4?
f*BLT nbaddata            ; y0 too small
p;
zB; For width & height, check not smaller than integer fp range.
�:�fp("LDFD F1,ninint")  ; smallest value for fp integer
��fp("LDFD F0,nw ")
��fp("CMFD F0,#4")
�)BGT nbaddata            ; w too large
�2�fp("CMFD F0,F1")     ; within accuracy range?
�)BLT nbaddata            ; w too small
��fp("LDFD F0,nh ")
��fp("CMFD F0,#4")
�(BGT nbaddata           ; h too large
�2�fp("CMFD F0,F1")     ; within accuracy range?
�(BLT nbaddata           ; h too small
�;
�"; Verify maxiter not too small
LDR R0,niter
'CMP R0,#10             ; too small?
MOVLT R0,#10
$,STRLT R0,niter         ; yes - set to 10
.
�fexit
8;
B
.nbaddata
L
MOV R0,#1
V,STR R0,[R1,#fevent_rc] ; set return code
`
�fexit
j
t.ninint �fp("DFD 1e-5")
~*;-------------------------------------
�!; Initialise ready for a plot
�.nplotinit
�LDR R0,[R1,#plot_flags]
�-�R R0,R0,#plot_ffp     ; fast float maths
�*STR R0,[R1,#plot_flags] ; tell Fractal
�ADR R0,newtonfp
�6STR R0,newton_func+fdefn_xyrtn  ; Our plot routine
�
�fexit
�';----------------------------------
�]
�� newton registers
�� x & y set on entry
Ex=2:y=3:xy=4:x2=5:y2=6:wrk1=7:wrk2=8:wrk3=9:root=10:e=11:depth=12

[OPT asm

.newtonfp
,STMFD R13!,{R14}        ; Return address
(MOV x,R0
2MOV y,R1
< �fp_sqr(y2,y)          ; y*y
F%LDR e,newton_e          ; epsilon
PLDR depth,niter
ZMOV root,#0
d3.nloop                  ; do for each iteration
n �fp_mul(xy,x,y)        ; x*y
x#ADD xy,xy,#1<<23        ; 2*x*y
�;
� �fp_sqr(x2,x)          ; x*x
�
MOV R1,y2
�%BL fp_add               ; x*x+y*y
�MOVS R1,R0
�'BEQ nexit               ; too small
�4BL fp_sqr               ; d4=(x*x+y*y)*(x*x+y*y)
�LDR R1,fp_three
�"BL fp_mul               ; 3*d4
�MOVS wrk1,R0
�'BEQ nexit               ; underflow
�; calc new x
�LDR R1,twothird
"�fp_mul(wrk2,x,1)      ; x*2/3
$�fp_sub(0,x2,y2)       ; x*x-y*y
)�fp_div(0,0,wrk1)      ; (x*x-y*y)/d4
"/�fp_add(x,0,wrk2)      ; x=x*2/3+(x2-y2)/d4
,; calc new y
6'�fp_div(wrk2,xy,wrk1)  ; (2*x*y)/d4
@LDR R1,twothird
J"�fp_mul(0,y,1)         ; y*2/3
T/�fp_sub(y,0,wrk2)      ; y=y*2/3-(2*x*y)/d4
^;
h �fp_sqr(y2,y)          ; y*y
r; Check for root=1
|!MOV R1,#127<<23         ; 1.0
� �fp_sub(0,x,1)         ; x-1
�(�fp_sqr(0,0)           ; (x-1)*(x-1)
�+�fp_add(0,0,y2)        ; (x-1)*(x-1)+y2
�1CMP R0,e                ; ((x-1)*(x-1)+y2)<e?
�MOVLT root,#1
�$BLT nexit               ; root=1
�; Check for root=2
�!MOV R1,#126<<23         ; 0.5
�"�fp_add(0,x,1)         ; x+0.5
�/�fp_sqr(wrk1,0)        ; xr=(x+0.5)*(x+0.5)
�LDR wrk2,newton_r2
�(�fp_sub(0,y,wrk2)      ; y-0.8660254
�;�fp_sqr(0,0)           ; yr=(y-0.8660254)*(y-0.8660254)
"�fp_add(0,wrk1,0)      ; xr+yr
%CMP R0,e                ; Root 2?
MOVLT root,#2
&
BLT nexit
0; Check for root=3
:(�fp_add(0,y,wrk2)      ; y+0.8660254
D;�fp_sqr(0,0)           ; yr=(y+0.8660254)*(y+0.8660254)
N"�fp_add(0,wrk1,0)      ; xr+yr
X%CMP R0,e                ; Root 3?
bMOVLT root,#3
l
BLT nexit
v;
�SUBS depth,depth,#1
�
BNE nloop
�1LDR depth,niter         ; No colour if at max
�
.nexit
�LDR R0,niter
�+SUB R0,R0,depth         ; return colour
�0ADD R0,R0,#16           ; avoid dark colours
�"LDMFD R13!,{PC}^        ; exit
�;
�#.twothird �fp("DFS 0.66666666")
�.newton_e �fp("DFS 0.0025")
�#.newton_r2 �fp("DFS 0.8660254")
�.fp_three �fp("DFS 3.0")
;--------------------------
7�finterface            ; Necessary C Interface code
%�fpeasm(�)         ; FPE routines
 ]:�
*:ș "OS_File",10,"<Frac$Dir>.SampNewton",&FFA,,code%,O%
4�
�
00000000  0d 00 0a 21 f4 20 3e 20  3c 46 72 61 63 24 44 69  |...!. > <Frac$Di|
00000010  72 3e 2e 41 73 6d 2e 53  61 6d 70 4e 65 77 74 6f  |r>.Asm.SampNewto|
00000020  6e 0d 00 14 20 f4 20 4e  65 77 74 6f 6e 20 3a 20  |n... . Newton : |
00000030  7a 2a 7a 2a 7a 2d 31 3d  30 20 70 6c 6f 74 74 65  |z*z*z-1=0 plotte|
00000040  72 0d 00 1e 25 f4 20 41  6c 67 6f 72 69 74 68 6d  |r...%. Algorithm|
00000050  20 66 72 6f 6d 20 42 65  63 6b 65 72 20 26 20 44  | from Becker & D|
00000060  6f 72 66 6c 65 72 0d 00  28 29 c8 9b 20 22 3c 46  |orfler..().. "<F|
00000070  72 61 63 24 44 69 72 3e  2e 41 73 6d 2e 46 72 61  |rac$Dir>.Asm.Fra|
00000080  63 6c 69 62 22 3a f2 66  72 61 63 76 61 72 73 0d  |clib":.fracvars.|
00000090  00 32 25 c8 9b 20 22 3c  46 72 61 63 24 44 69 72  |.2%.. "<Frac$Dir|
000000a0  3e 2e 41 73 6d 2e 46 50  6c 69 62 22 3a f2 66 70  |>.Asm.FPlib":.fp|
000000b0  69 6e 69 74 0d 00 3c 1e  c8 9b 20 22 3c 46 72 61  |init..<... "<Fra|
000000c0  63 24 44 69 72 3e 2e 41  73 6d 2e 46 50 45 6c 69  |c$Dir>.Asm.FPEli|
000000d0  62 22 0d 00 46 28 f4 20  3d 3d 3d 20 46 75 6e 63  |b"..F(. === Func|
000000e0  74 69 6f 6e 20 73 70 65  63 69 66 69 63 20 63 6f  |tion specific co|
000000f0  64 65 20 66 6f 6c 6c 6f  77 73 0d 00 50 40 6e 65  |de follows..P@ne|
00000100  77 74 6f 6e 3d 30 3a 6e  76 61 72 73 74 61 72 74  |wton=0:nvarstart|
00000110  3d 30 3a 6e 76 61 72 65  6e 64 3d 30 3a f4 20 69  |=0:nvarend=0:. i|
00000120  6e 69 74 69 61 6c 69 73  65 20 74 6f 20 61 20 64  |nitialise to a d|
00000130  75 6d 6d 79 20 76 61 6c  75 65 0d 00 5a 27 f4 20  |ummy value..Z'. |
00000140  3d 3d 3d 20 45 6e 64 20  6f 66 20 66 75 6e 63 74  |=== End of funct|
00000150  69 6f 6e 20 73 70 65 63  69 66 69 63 20 63 6f 64  |ion specific cod|
00000160  65 0d 00 64 11 de 20 63  6f 64 65 25 20 31 30 30  |e..d.. code% 100|
00000170  30 30 0d 00 6e 13 e3 20  61 73 6d 3d 34 20 b8 20  |00..n.. asm=4 . |
00000180  37 20 88 20 33 0d 00 78  11 50 25 3d 30 3a 4f 25  |7 . 3..x.P%=0:O%|
00000190  3d 63 6f 64 65 25 0d 00  82 0c 5b 4f 50 54 20 61  |=code%....[OPT a|
000001a0  73 6d 0d 00 8c 3f 3b 20  46 6f 6c 6c 6f 77 69 6e  |sm...?; Followin|
000001b0  67 20 69 73 20 74 68 65  20 6c 69 73 74 20 6f 66  |g is the list of|
000001c0  20 66 72 61 63 74 61 6c  20 66 75 6e 63 74 69 6f  | fractal functio|
000001d0  6e 73 20 69 6e 20 74 68  69 73 20 6d 6f 64 75 6c  |ns in this modul|
000001e0  65 0d 00 96 35 a4 66 72  61 63 68 64 72 20 3b 20  |e...5.frachdr ; |
000001f0  49 64 65 6e 74 69 66 79  20 6f 75 72 73 65 6c 76  |Identify ourselv|
00000200  65 73 20 61 73 20 61 20  66 72 61 63 74 61 6c 20  |es as a fractal |
00000210  6d 6f 64 75 6c 65 0d 00  a0 05 3b 0d 00 aa 35 3b  |module....;...5;|
00000220  20 4f 6e 65 20 6f 72 20  6d 6f 72 65 20 66 75 6e  | One or more fun|
00000230  63 74 69 6f 6e 20 64 65  66 69 6e 69 74 69 6f 6e  |ction definition|
00000240  20 70 6f 69 6e 74 65 72  73 20 66 6f 6c 6c 6f 77  | pointers follow|
00000250  0d 00 b4 13 44 43 44 20  6e 65 77 74 6f 6e 5f 66  |....DCD newton_f|
00000260  75 6e 63 0d 00 be 05 3b  0d 00 c8 1d 44 43 44 20  |unc....;....DCD |
00000270  2d 31 20 3b 20 45 6e 64  20 6f 66 20 66 75 6e 63  |-1 ; End of func|
00000280  74 69 6f 6e 73 0d 00 d2  43 3b 2d 2d 2d 2d 2d 2d  |tions...C;------|
00000290  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000002c0  2d 2d 2d 2d 2d 2d 2d 2d  0d 00 dc 2c 3b 20 4e 6f  |--------...,; No|
000002d0  77 20 77 65 20 64 65 66  69 6e 65 20 4e 65 77 74  |w we define Newt|
000002e0  6f 6e 27 73 20 63 68 61  72 61 63 74 65 72 69 73  |on's characteris|
000002f0  74 69 63 73 0d 00 e6 05  3b 0d 00 f0 57 2e 6e 65  |tics....;...W.ne|
00000300  77 74 6f 6e 5f 66 75 6e  63 20 a4 66 72 61 63 66  |wton_func .fracf|
00000310  75 6e 63 28 22 53 61 6d  70 4e 65 77 74 6f 6e 22  |unc("SampNewton"|
00000320  2c 6e 65 77 74 6f 6e 2c  66 5a 6f 6f 6d 2b 66 68  |,newton,fZoom+fh|
00000330  65 69 67 68 74 2b 66 78  79 2c 30 2c 35 2c 6e 76  |eight+fxy,0,5,nv|
00000340  61 72 65 6e 64 2d 6e 76  61 72 73 74 61 72 74 29  |arend-nvarstart)|
00000350  0d 00 fa 05 3b 0d 01 04  23 3b 20 4e 65 77 74 6f  |....;...#; Newto|
00000360  6e 27 73 20 56 61 72 69  61 62 6c 65 73 20 61 66  |n's Variables af|
00000370  74 65 72 20 68 65 72 65  0d 01 0e 0e 2e 6e 76 61  |ter here.....nva|
00000380  72 73 74 61 72 74 0d 01  18 2f a4 61 66 67 32 76  |rstart.../.afg2v|
00000390  61 72 28 41 46 47 5f 64  62 6c 2c 30 2c 38 29 3a  |ar(AFG_dbl,0,8):|
000003a0  2e 6e 78 30 20 a4 66 70  28 22 44 46 44 20 2d 32  |.nx0 .fp("DFD -2|
000003b0  2e 30 30 22 29 0d 01 22  2f a4 61 66 67 32 76 61  |.00").."/.afg2va|
000003c0  72 28 41 46 47 5f 64 62  6c 2c 30 2c 38 29 3a 2e  |r(AFG_dbl,0,8):.|
000003d0  6e 79 30 20 a4 66 70 28  22 44 46 44 20 2d 31 2e  |ny0 .fp("DFD -1.|
000003e0  36 30 22 29 0d 01 2c 2c  a4 61 66 67 32 76 61 72  |60")..,,.afg2var|
000003f0  28 41 46 47 5f 64 62 6c  2c 30 2c 38 29 3a 2e 6e  |(AFG_dbl,0,8):.n|
00000400  77 20 a4 66 70 28 22 44  46 44 20 34 2e 30 22 29  |w .fp("DFD 4.0")|
00000410  0d 01 36 2c a4 61 66 67  32 76 61 72 28 41 46 47  |..6,.afg2var(AFG|
00000420  5f 64 62 6c 2c 30 2c 38  29 3a 2e 6e 68 20 a4 66  |_dbl,0,8):.nh .f|
00000430  70 28 22 44 46 44 20 33  2e 32 22 29 0d 01 40 28  |p("DFD 3.2")..@(|
00000440  a4 61 66 67 32 76 61 72  28 41 46 47 5f 69 6e 74  |.afg2var(AFG_int|
00000450  2c 30 2c 34 29 3a 2e 6e  69 74 65 72 20 44 43 44  |,0,4):.niter DCD|
00000460  20 31 32 38 0d 01 4a 1f  2e 6e 76 61 72 65 6e 64  | 128..J..nvarend|
00000470  20 3b 20 45 6e 64 20 6f  66 20 76 61 72 69 61 62  | ; End of variab|
00000480  6c 65 73 0d 01 54 05 3b  0d 01 5e 3a 3b 20 56 61  |les..T.;..^:; Va|
00000490  72 69 61 62 6c 65 20 6e  61 6d 65 73 20 61 66 74  |riable names aft|
000004a0  65 72 20 68 65 72 65 3b  20 31 20 66 6f 72 20 65  |er here; 1 for e|
000004b0  61 63 68 20 76 61 72 69  61 62 6c 65 20 61 62 6f  |ach variable abo|
000004c0  76 65 0d 01 68 1b a4 76  61 72 6e 61 6d 65 28 22  |ve..h..varname("|
000004d0  20 20 20 20 20 20 20 20  20 78 30 22 29 0d 01 72  |         x0")..r|
000004e0  1b a4 76 61 72 6e 61 6d  65 28 22 20 20 20 20 20  |..varname("     |
000004f0  20 20 20 20 79 30 22 29  0d 01 7c 1b a4 76 61 72  |    y0")..|..var|
00000500  6e 61 6d 65 28 22 20 20  20 20 20 20 77 69 64 74  |name("      widt|
00000510  68 22 29 0d 01 86 1b a4  76 61 72 6e 61 6d 65 28  |h").....varname(|
00000520  22 20 20 20 20 20 68 65  69 67 68 74 22 29 0d 01  |"     height")..|
00000530  90 1b a4 76 61 72 6e 61  6d 65 28 22 20 20 4d 61  |...varname("  Ma|
00000540  78 2e 20 49 74 65 72 22  29 0d 01 9a 2a 3b 2d 2d  |x. Iter")...*;--|
00000550  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000570  2d 2d 2d 0d 01 a4 1f 3b  20 54 68 65 20 65 6e 74  |---....; The ent|
00000580  72 79 20 70 6f 69 6e 74  20 74 6f 20 4e 65 77 74  |ry point to Newt|
00000590  6f 6e 0d 01 ae 0b 2e 6e  65 77 74 6f 6e 0d 01 b8  |on.....newton...|
000005a0  18 a4 66 65 6e 74 65 72  20 3b 20 49 6e 69 74 69  |..fenter ; Initi|
000005b0  61 6c 69 73 65 0d 01 c2  2a 3b 20 52 30 3d 46 72  |alise...*; R0=Fr|
000005c0  61 63 74 61 6c 20 45 76  65 6e 74 2c 20 52 31 3d  |actal Event, R1=|
000005d0  41 64 64 72 65 73 73 20  6f 66 20 44 61 74 61 0d  |Address of Data.|
000005e0  01 cc 0d 4d 4f 56 20 52  39 2c 23 30 0d 01 d6 2e  |...MOV R9,#0....|
000005f0  53 54 52 20 52 39 2c 5b  52 31 2c 23 66 65 76 65  |STR R9,[R1,#feve|
00000600  6e 74 5f 72 63 5d 20 3b  20 63 6c 65 61 72 20 72  |nt_rc] ; clear r|
00000610  65 74 75 72 6e 20 63 6f  64 65 0d 01 e0 15 43 4d  |eturn code....CM|
00000620  50 20 52 30 2c 23 66 70  6c 6f 74 69 6e 69 74 0d  |P R0,#fplotinit.|
00000630  01 ea 11 42 45 51 20 6e  70 6c 6f 74 69 6e 69 74  |...BEQ nplotinit|
00000640  0d 01 f4 15 43 4d 50 20  52 30 2c 23 66 64 61 74  |....CMP R0,#fdat|
00000650  61 69 6e 69 74 0d 01 fe  11 42 45 51 20 6e 64 61  |ainit....BEQ nda|
00000660  74 61 69 6e 69 74 0d 02  08 14 43 4d 50 20 52 30  |tainit....CMP R0|
00000670  2c 23 66 64 61 74 61 63  68 6b 0d 02 12 10 42 45  |,#fdatachk....BE|
00000680  51 20 6e 64 61 74 61 63  68 6b 0d 02 1c 25 3b 20  |Q ndatachk...%; |
00000690  55 6e 73 75 70 70 6f 72  74 65 64 20 65 76 65 6e  |Unsupported even|
000006a0  74 20 2d 20 6a 75 73 74  20 72 65 74 75 72 6e 0d  |t - just return.|
000006b0  02 26 0a a4 66 65 78 69  74 0d 02 30 05 3b 0d 02  |.&..fexit..0.;..|
000006c0  3a 16 3b 20 49 6e 69 74  20 4e 65 77 74 6f 6e 20  |:.; Init Newton |
000006d0  64 61 74 61 0d 02 44 0e  2e 6e 64 61 74 61 69 6e  |data..D..ndatain|
000006e0  69 74 0d 02 4e 16 a4 66  70 28 22 4c 44 46 44 20  |it..N..fp("LDFD |
000006f0  46 30 2c 69 6e 78 22 29  0d 02 58 16 a4 66 70 28  |F0,inx")..X..fp(|
00000700  22 53 54 46 44 20 46 30  2c 6e 78 30 22 29 0d 02  |"STFD F0,nx0")..|
00000710  62 16 a4 66 70 28 22 4c  44 46 44 20 46 30 2c 69  |b..fp("LDFD F0,i|
00000720  6e 79 22 29 0d 02 6c 16  a4 66 70 28 22 53 54 46  |ny")..l..fp("STF|
00000730  44 20 46 30 2c 6e 79 30  22 29 0d 02 76 16 a4 66  |D F0,ny0")..v..f|
00000740  70 28 22 4c 44 46 44 20  46 30 2c 69 6e 77 22 29  |p("LDFD F0,inw")|
00000750  0d 02 80 16 a4 66 70 28  22 53 54 46 44 20 46 30  |.....fp("STFD F0|
00000760  2c 6e 77 20 22 29 0d 02  8a 16 a4 66 70 28 22 4c  |,nw ").....fp("L|
00000770  44 46 44 20 46 30 2c 69  6e 68 22 29 0d 02 94 16  |DFD F0,inh")....|
00000780  a4 66 70 28 22 53 54 46  44 20 46 30 2c 6e 68 20  |.fp("STFD F0,nh |
00000790  22 29 0d 02 9e 11 4c 44  52 20 52 30 2c 69 6e 69  |")....LDR R0,ini|
000007a0  74 65 72 0d 02 a8 10 53  54 52 20 52 30 2c 6e 69  |ter....STR R0,ni|
000007b0  74 65 72 0d 02 b2 0a a4  66 65 78 69 74 0d 02 bc  |ter.....fexit...|
000007c0  2a 2e 69 6e 78 20 a4 66  70 28 22 44 46 44 20 2d  |*.inx .fp("DFD -|
000007d0  32 2e 30 30 22 29 20 3b  20 49 6e 69 74 69 61 6c  |2.00") ; Initial|
000007e0  20 76 61 6c 75 65 73 0d  02 c6 19 2e 69 6e 79 20  | values.....iny |
000007f0  a4 66 70 28 22 44 46 44  20 2d 31 2e 36 30 22 29  |.fp("DFD -1.60")|
00000800  0d 02 d0 17 2e 69 6e 77  20 a4 66 70 28 22 44 46  |.....inw .fp("DF|
00000810  44 20 34 2e 30 22 29 0d  02 da 17 2e 69 6e 68 20  |D 4.0").....inh |
00000820  a4 66 70 28 22 44 46 44  20 33 2e 32 22 29 0d 02  |.fp("DFD 3.2")..|
00000830  e4 13 2e 69 6e 69 74 65  72 20 44 43 44 20 31 32  |...initer DCD 12|
00000840  38 0d 02 ee 05 3b 0d 02  f8 25 3b 20 56 65 72 69  |8....;...%; Veri|
00000850  66 79 20 64 61 74 61 20  69 6e 70 75 74 20 6f 72  |fy data input or|
00000860  20 7a 6f 6f 6d 20 72 61  6e 67 65 0d 03 02 0d 2e  | zoom range.....|
00000870  6e 64 61 74 61 63 68 6b  0d 03 0c 16 a4 66 70 28  |ndatachk.....fp(|
00000880  22 4c 44 46 44 20 46 30  2c 6e 78 30 22 29 0d 03  |"LDFD F0,nx0")..|
00000890  16 15 a4 66 70 28 22 43  4d 46 44 20 46 30 2c 23  |...fp("CMFD F0,#|
000008a0  34 22 29 0d 03 20 2a 42  47 54 20 6e 62 61 64 64  |4").. *BGT nbadd|
000008b0  61 74 61 20 20 20 20 20  20 20 20 20 20 20 20 3b  |ata            ;|
000008c0  20 78 30 20 74 6f 6f 20  6c 61 72 67 65 0d 03 2a  | x0 too large..*|
000008d0  21 a4 66 70 28 22 43 4e  46 44 20 46 30 2c 23 34  |!.fp("CNFD F0,#4|
000008e0  22 29 20 20 20 20 20 20  3b 20 3c 2d 34 3f 0d 03  |")      ; <-4?..|
000008f0  34 2a 42 4c 54 20 6e 62  61 64 64 61 74 61 20 20  |4*BLT nbaddata  |
00000900  20 20 20 20 20 20 20 20  20 20 3b 20 78 30 20 74  |          ; x0 t|
00000910  6f 6f 20 73 6d 61 6c 6c  0d 03 3e 16 a4 66 70 28  |oo small..>..fp(|
00000920  22 4c 44 46 44 20 46 30  2c 6e 79 30 22 29 0d 03  |"LDFD F0,ny0")..|
00000930  48 15 a4 66 70 28 22 43  4d 46 44 20 46 30 2c 23  |H..fp("CMFD F0,#|
00000940  34 22 29 0d 03 52 2a 42  47 54 20 6e 62 61 64 64  |4")..R*BGT nbadd|
00000950  61 74 61 20 20 20 20 20  20 20 20 20 20 20 20 3b  |ata            ;|
00000960  20 79 30 20 74 6f 6f 20  6c 61 72 67 65 0d 03 5c  | y0 too large..\|
00000970  21 a4 66 70 28 22 43 4e  46 44 20 46 30 2c 23 34  |!.fp("CNFD F0,#4|
00000980  22 29 20 20 20 20 20 20  3b 20 3c 2d 34 3f 0d 03  |")      ; <-4?..|
00000990  66 2a 42 4c 54 20 6e 62  61 64 64 61 74 61 20 20  |f*BLT nbaddata  |
000009a0  20 20 20 20 20 20 20 20  20 20 3b 20 79 30 20 74  |          ; y0 t|
000009b0  6f 6f 20 73 6d 61 6c 6c  0d 03 70 05 3b 0d 03 7a  |oo small..p.;..z|
000009c0  42 3b 20 46 6f 72 20 77  69 64 74 68 20 26 20 68  |B; For width & h|
000009d0  65 69 67 68 74 2c 20 63  68 65 63 6b 20 6e 6f 74  |eight, check not|
000009e0  20 73 6d 61 6c 6c 65 72  20 74 68 61 6e 20 69 6e  | smaller than in|
000009f0  74 65 67 65 72 20 66 70  20 72 61 6e 67 65 2e 0d  |teger fp range..|
00000a00  03 84 3a a4 66 70 28 22  4c 44 46 44 20 46 31 2c  |..:.fp("LDFD F1,|
00000a10  6e 69 6e 69 6e 74 22 29  20 20 3b 20 73 6d 61 6c  |ninint")  ; smal|
00000a20  6c 65 73 74 20 76 61 6c  75 65 20 66 6f 72 20 66  |lest value for f|
00000a30  70 20 69 6e 74 65 67 65  72 0d 03 8e 16 a4 66 70  |p integer.....fp|
00000a40  28 22 4c 44 46 44 20 46  30 2c 6e 77 20 22 29 0d  |("LDFD F0,nw ").|
00000a50  03 98 15 a4 66 70 28 22  43 4d 46 44 20 46 30 2c  |....fp("CMFD F0,|
00000a60  23 34 22 29 0d 03 a2 29  42 47 54 20 6e 62 61 64  |#4")...)BGT nbad|
00000a70  64 61 74 61 20 20 20 20  20 20 20 20 20 20 20 20  |data            |
00000a80  3b 20 77 20 74 6f 6f 20  6c 61 72 67 65 0d 03 ac  |; w too large...|
00000a90  32 a4 66 70 28 22 43 4d  46 44 20 46 30 2c 46 31  |2.fp("CMFD F0,F1|
00000aa0  22 29 20 20 20 20 20 3b  20 77 69 74 68 69 6e 20  |")     ; within |
00000ab0  61 63 63 75 72 61 63 79  20 72 61 6e 67 65 3f 0d  |accuracy range?.|
00000ac0  03 b6 29 42 4c 54 20 6e  62 61 64 64 61 74 61 20  |..)BLT nbaddata |
00000ad0  20 20 20 20 20 20 20 20  20 20 20 3b 20 77 20 74  |           ; w t|
00000ae0  6f 6f 20 73 6d 61 6c 6c  0d 03 c0 16 a4 66 70 28  |oo small.....fp(|
00000af0  22 4c 44 46 44 20 46 30  2c 6e 68 20 22 29 0d 03  |"LDFD F0,nh ")..|
00000b00  ca 15 a4 66 70 28 22 43  4d 46 44 20 46 30 2c 23  |...fp("CMFD F0,#|
00000b10  34 22 29 0d 03 d4 28 42  47 54 20 6e 62 61 64 64  |4")...(BGT nbadd|
00000b20  61 74 61 20 20 20 20 20  20 20 20 20 20 20 3b 20  |ata           ; |
00000b30  68 20 74 6f 6f 20 6c 61  72 67 65 0d 03 de 32 a4  |h too large...2.|
00000b40  66 70 28 22 43 4d 46 44  20 46 30 2c 46 31 22 29  |fp("CMFD F0,F1")|
00000b50  20 20 20 20 20 3b 20 77  69 74 68 69 6e 20 61 63  |     ; within ac|
00000b60  63 75 72 61 63 79 20 72  61 6e 67 65 3f 0d 03 e8  |curacy range?...|
00000b70  28 42 4c 54 20 6e 62 61  64 64 61 74 61 20 20 20  |(BLT nbaddata   |
00000b80  20 20 20 20 20 20 20 20  3b 20 68 20 74 6f 6f 20  |        ; h too |
00000b90  73 6d 61 6c 6c 0d 03 f2  05 3b 0d 03 fc 22 3b 20  |small....;..."; |
00000ba0  56 65 72 69 66 79 20 6d  61 78 69 74 65 72 20 6e  |Verify maxiter n|
00000bb0  6f 74 20 74 6f 6f 20 73  6d 61 6c 6c 0d 04 06 10  |ot too small....|
00000bc0  4c 44 52 20 52 30 2c 6e  69 74 65 72 0d 04 10 27  |LDR R0,niter...'|
00000bd0  43 4d 50 20 52 30 2c 23  31 30 20 20 20 20 20 20  |CMP R0,#10      |
00000be0  20 20 20 20 20 20 20 3b  20 74 6f 6f 20 73 6d 61  |       ; too sma|
00000bf0  6c 6c 3f 0d 04 1a 10 4d  4f 56 4c 54 20 52 30 2c  |ll?....MOVLT R0,|
00000c00  23 31 30 0d 04 24 2c 53  54 52 4c 54 20 52 30 2c  |#10..$,STRLT R0,|
00000c10  6e 69 74 65 72 20 20 20  20 20 20 20 20 20 3b 20  |niter         ; |
00000c20  79 65 73 20 2d 20 73 65  74 20 74 6f 20 31 30 0d  |yes - set to 10.|
00000c30  04 2e 0a a4 66 65 78 69  74 0d 04 38 05 3b 0d 04  |....fexit..8.;..|
00000c40  42 0d 2e 6e 62 61 64 64  61 74 61 0d 04 4c 0d 4d  |B..nbaddata..L.M|
00000c50  4f 56 20 52 30 2c 23 31  0d 04 56 2c 53 54 52 20  |OV R0,#1..V,STR |
00000c60  52 30 2c 5b 52 31 2c 23  66 65 76 65 6e 74 5f 72  |R0,[R1,#fevent_r|
00000c70  63 5d 20 3b 20 73 65 74  20 72 65 74 75 72 6e 20  |c] ; set return |
00000c80  63 6f 64 65 0d 04 60 0a  a4 66 65 78 69 74 0d 04  |code..`..fexit..|
00000c90  6a 04 0d 04 74 1b 2e 6e  69 6e 69 6e 74 20 a4 66  |j...t..ninint .f|
00000ca0  70 28 22 44 46 44 20 31  65 2d 35 22 29 0d 04 7e  |p("DFD 1e-5")..~|
00000cb0  2a 3b 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |*;--------------|
00000cc0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
00000cd0  2d 2d 2d 2d 2d 2d 2d 0d  04 88 21 3b 20 49 6e 69  |-------...!; Ini|
00000ce0  74 69 61 6c 69 73 65 20  72 65 61 64 79 20 66 6f  |tialise ready fo|
00000cf0  72 20 61 20 70 6c 6f 74  0d 04 92 0e 2e 6e 70 6c  |r a plot.....npl|
00000d00  6f 74 69 6e 69 74 0d 04  9c 1b 4c 44 52 20 52 30  |otinit....LDR R0|
00000d10  2c 5b 52 31 2c 23 70 6c  6f 74 5f 66 6c 61 67 73  |,[R1,#plot_flags|
00000d20  5d 0d 04 a6 2d 84 52 20  52 30 2c 52 30 2c 23 70  |]...-.R R0,R0,#p|
00000d30  6c 6f 74 5f 66 66 70 20  20 20 20 20 3b 20 66 61  |lot_ffp     ; fa|
00000d40  73 74 20 66 6c 6f 61 74  20 6d 61 74 68 73 0d 04  |st float maths..|
00000d50  b0 2a 53 54 52 20 52 30  2c 5b 52 31 2c 23 70 6c  |.*STR R0,[R1,#pl|
00000d60  6f 74 5f 66 6c 61 67 73  5d 20 3b 20 74 65 6c 6c  |ot_flags] ; tell|
00000d70  20 46 72 61 63 74 61 6c  0d 04 ba 13 41 44 52 20  | Fractal....ADR |
00000d80  52 30 2c 6e 65 77 74 6f  6e 66 70 0d 04 c4 36 53  |R0,newtonfp...6S|
00000d90  54 52 20 52 30 2c 6e 65  77 74 6f 6e 5f 66 75 6e  |TR R0,newton_fun|
00000da0  63 2b 66 64 65 66 6e 5f  78 79 72 74 6e 20 20 3b  |c+fdefn_xyrtn  ;|
00000db0  20 4f 75 72 20 70 6c 6f  74 20 72 6f 75 74 69 6e  | Our plot routin|
00000dc0  65 0d 04 ce 0a a4 66 65  78 69 74 0d 04 d8 27 3b  |e.....fexit...';|
00000dd0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000df0  2d 2d 0d 04 e2 05 5d 0d  04 ec 16 f4 20 6e 65 77  |--....]..... new|
00000e00  74 6f 6e 20 72 65 67 69  73 74 65 72 73 0d 04 f6  |ton registers...|
00000e10  18 f4 20 78 20 26 20 79  20 73 65 74 20 6f 6e 20  |.. x & y set on |
00000e20  65 6e 74 72 79 0d 05 00  45 78 3d 32 3a 79 3d 33  |entry...Ex=2:y=3|
00000e30  3a 78 79 3d 34 3a 78 32  3d 35 3a 79 32 3d 36 3a  |:xy=4:x2=5:y2=6:|
00000e40  77 72 6b 31 3d 37 3a 77  72 6b 32 3d 38 3a 77 72  |wrk1=7:wrk2=8:wr|
00000e50  6b 33 3d 39 3a 72 6f 6f  74 3d 31 30 3a 65 3d 31  |k3=9:root=10:e=1|
00000e60  31 3a 64 65 70 74 68 3d  31 32 0d 05 0a 0c 5b 4f  |1:depth=12....[O|
00000e70  50 54 20 61 73 6d 0d 05  14 0d 2e 6e 65 77 74 6f  |PT asm.....newto|
00000e80  6e 66 70 0d 05 1e 2c 53  54 4d 46 44 20 52 31 33  |nfp...,STMFD R13|
00000e90  21 2c 7b 52 31 34 7d 20  20 20 20 20 20 20 20 3b  |!,{R14}        ;|
00000ea0  20 52 65 74 75 72 6e 20  61 64 64 72 65 73 73 0d  | Return address.|
00000eb0  05 28 0c 4d 4f 56 20 78  2c 52 30 0d 05 32 0c 4d  |.(.MOV x,R0..2.M|
00000ec0  4f 56 20 79 2c 52 31 0d  05 3c 20 a4 66 70 5f 73  |OV y,R1..< .fp_s|
00000ed0  71 72 28 79 32 2c 79 29  20 20 20 20 20 20 20 20  |qr(y2,y)        |
00000ee0  20 20 3b 20 79 2a 79 0d  05 46 25 4c 44 52 20 65  |  ; y*y..F%LDR e|
00000ef0  2c 6e 65 77 74 6f 6e 5f  65 20 20 20 20 20 20 20  |,newton_e       |
00000f00  20 20 20 3b 20 65 70 73  69 6c 6f 6e 0d 05 50 13  |   ; epsilon..P.|
00000f10  4c 44 52 20 64 65 70 74  68 2c 6e 69 74 65 72 0d  |LDR depth,niter.|
00000f20  05 5a 0f 4d 4f 56 20 72  6f 6f 74 2c 23 30 0d 05  |.Z.MOV root,#0..|
00000f30  64 33 2e 6e 6c 6f 6f 70  20 20 20 20 20 20 20 20  |d3.nloop        |
00000f40  20 20 20 20 20 20 20 20  20 20 3b 20 64 6f 20 66  |          ; do f|
00000f50  6f 72 20 65 61 63 68 20  69 74 65 72 61 74 69 6f  |or each iteratio|
00000f60  6e 0d 05 6e 20 a4 66 70  5f 6d 75 6c 28 78 79 2c  |n..n .fp_mul(xy,|
00000f70  78 2c 79 29 20 20 20 20  20 20 20 20 3b 20 78 2a  |x,y)        ; x*|
00000f80  79 0d 05 78 23 41 44 44  20 78 79 2c 78 79 2c 23  |y..x#ADD xy,xy,#|
00000f90  31 3c 3c 32 33 20 20 20  20 20 20 20 20 3b 20 32  |1<<23        ; 2|
00000fa0  2a 78 2a 79 0d 05 82 05  3b 0d 05 8c 20 a4 66 70  |*x*y....;... .fp|
00000fb0  5f 73 71 72 28 78 32 2c  78 29 20 20 20 20 20 20  |_sqr(x2,x)      |
00000fc0  20 20 20 20 3b 20 78 2a  78 0d 05 96 0d 4d 4f 56  |    ; x*x....MOV|
00000fd0  20 52 31 2c 79 32 0d 05  a0 25 42 4c 20 66 70 5f  | R1,y2...%BL fp_|
00000fe0  61 64 64 20 20 20 20 20  20 20 20 20 20 20 20 20  |add             |
00000ff0  20 20 3b 20 78 2a 78 2b  79 2a 79 0d 05 aa 0e 4d  |  ; x*x+y*y....M|
00001000  4f 56 53 20 52 31 2c 52  30 0d 05 b4 27 42 45 51  |OVS R1,R0...'BEQ|
00001010  20 6e 65 78 69 74 20 20  20 20 20 20 20 20 20 20  | nexit          |
00001020  20 20 20 20 20 3b 20 74  6f 6f 20 73 6d 61 6c 6c  |     ; too small|
00001030  0d 05 be 34 42 4c 20 66  70 5f 73 71 72 20 20 20  |...4BL fp_sqr   |
00001040  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 64 34  |            ; d4|
00001050  3d 28 78 2a 78 2b 79 2a  79 29 2a 28 78 2a 78 2b  |=(x*x+y*y)*(x*x+|
00001060  79 2a 79 29 0d 05 c8 13  4c 44 52 20 52 31 2c 66  |y*y)....LDR R1,f|
00001070  70 5f 74 68 72 65 65 0d  05 d2 22 42 4c 20 66 70  |p_three..."BL fp|
00001080  5f 6d 75 6c 20 20 20 20  20 20 20 20 20 20 20 20  |_mul            |
00001090  20 20 20 3b 20 33 2a 64  34 0d 05 dc 10 4d 4f 56  |   ; 3*d4....MOV|
000010a0  53 20 77 72 6b 31 2c 52  30 0d 05 e6 27 42 45 51  |S wrk1,R0...'BEQ|
000010b0  20 6e 65 78 69 74 20 20  20 20 20 20 20 20 20 20  | nexit          |
000010c0  20 20 20 20 20 3b 20 75  6e 64 65 72 66 6c 6f 77  |     ; underflow|
000010d0  0d 05 f0 10 3b 20 63 61  6c 63 20 6e 65 77 20 78  |....; calc new x|
000010e0  0d 05 fa 13 4c 44 52 20  52 31 2c 74 77 6f 74 68  |....LDR R1,twoth|
000010f0  69 72 64 0d 06 04 22 a4  66 70 5f 6d 75 6c 28 77  |ird...".fp_mul(w|
00001100  72 6b 32 2c 78 2c 31 29  20 20 20 20 20 20 3b 20  |rk2,x,1)      ; |
00001110  78 2a 32 2f 33 0d 06 0e  24 a4 66 70 5f 73 75 62  |x*2/3...$.fp_sub|
00001120  28 30 2c 78 32 2c 79 32  29 20 20 20 20 20 20 20  |(0,x2,y2)       |
00001130  3b 20 78 2a 78 2d 79 2a  79 0d 06 18 29 a4 66 70  |; x*x-y*y...).fp|
00001140  5f 64 69 76 28 30 2c 30  2c 77 72 6b 31 29 20 20  |_div(0,0,wrk1)  |
00001150  20 20 20 20 3b 20 28 78  2a 78 2d 79 2a 79 29 2f  |    ; (x*x-y*y)/|
00001160  64 34 0d 06 22 2f a4 66  70 5f 61 64 64 28 78 2c  |d4.."/.fp_add(x,|
00001170  30 2c 77 72 6b 32 29 20  20 20 20 20 20 3b 20 78  |0,wrk2)      ; x|
00001180  3d 78 2a 32 2f 33 2b 28  78 32 2d 79 32 29 2f 64  |=x*2/3+(x2-y2)/d|
00001190  34 0d 06 2c 10 3b 20 63  61 6c 63 20 6e 65 77 20  |4..,.; calc new |
000011a0  79 0d 06 36 27 a4 66 70  5f 64 69 76 28 77 72 6b  |y..6'.fp_div(wrk|
000011b0  32 2c 78 79 2c 77 72 6b  31 29 20 20 3b 20 28 32  |2,xy,wrk1)  ; (2|
000011c0  2a 78 2a 79 29 2f 64 34  0d 06 40 13 4c 44 52 20  |*x*y)/d4..@.LDR |
000011d0  52 31 2c 74 77 6f 74 68  69 72 64 0d 06 4a 22 a4  |R1,twothird..J".|
000011e0  66 70 5f 6d 75 6c 28 30  2c 79 2c 31 29 20 20 20  |fp_mul(0,y,1)   |
000011f0  20 20 20 20 20 20 3b 20  79 2a 32 2f 33 0d 06 54  |      ; y*2/3..T|
00001200  2f a4 66 70 5f 73 75 62  28 79 2c 30 2c 77 72 6b  |/.fp_sub(y,0,wrk|
00001210  32 29 20 20 20 20 20 20  3b 20 79 3d 79 2a 32 2f  |2)      ; y=y*2/|
00001220  33 2d 28 32 2a 78 2a 79  29 2f 64 34 0d 06 5e 05  |3-(2*x*y)/d4..^.|
00001230  3b 0d 06 68 20 a4 66 70  5f 73 71 72 28 79 32 2c  |;..h .fp_sqr(y2,|
00001240  79 29 20 20 20 20 20 20  20 20 20 20 3b 20 79 2a  |y)          ; y*|
00001250  79 0d 06 72 16 3b 20 43  68 65 63 6b 20 66 6f 72  |y..r.; Check for|
00001260  20 72 6f 6f 74 3d 31 0d  06 7c 21 4d 4f 56 20 52  | root=1..|!MOV R|
00001270  31 2c 23 31 32 37 3c 3c  32 33 20 20 20 20 20 20  |1,#127<<23      |
00001280  20 20 20 3b 20 31 2e 30  0d 06 86 20 a4 66 70 5f  |   ; 1.0... .fp_|
00001290  73 75 62 28 30 2c 78 2c  31 29 20 20 20 20 20 20  |sub(0,x,1)      |
000012a0  20 20 20 3b 20 78 2d 31  0d 06 90 28 a4 66 70 5f  |   ; x-1...(.fp_|
000012b0  73 71 72 28 30 2c 30 29  20 20 20 20 20 20 20 20  |sqr(0,0)        |
000012c0  20 20 20 3b 20 28 78 2d  31 29 2a 28 78 2d 31 29  |   ; (x-1)*(x-1)|
000012d0  0d 06 9a 2b a4 66 70 5f  61 64 64 28 30 2c 30 2c  |...+.fp_add(0,0,|
000012e0  79 32 29 20 20 20 20 20  20 20 20 3b 20 28 78 2d  |y2)        ; (x-|
000012f0  31 29 2a 28 78 2d 31 29  2b 79 32 0d 06 a4 31 43  |1)*(x-1)+y2...1C|
00001300  4d 50 20 52 30 2c 65 20  20 20 20 20 20 20 20 20  |MP R0,e         |
00001310  20 20 20 20 20 20 20 3b  20 28 28 78 2d 31 29 2a  |       ; ((x-1)*|
00001320  28 78 2d 31 29 2b 79 32  29 3c 65 3f 0d 06 ae 11  |(x-1)+y2)<e?....|
00001330  4d 4f 56 4c 54 20 72 6f  6f 74 2c 23 31 0d 06 b8  |MOVLT root,#1...|
00001340  24 42 4c 54 20 6e 65 78  69 74 20 20 20 20 20 20  |$BLT nexit      |
00001350  20 20 20 20 20 20 20 20  20 3b 20 72 6f 6f 74 3d  |         ; root=|
00001360  31 0d 06 c2 16 3b 20 43  68 65 63 6b 20 66 6f 72  |1....; Check for|
00001370  20 72 6f 6f 74 3d 32 0d  06 cc 21 4d 4f 56 20 52  | root=2...!MOV R|
00001380  31 2c 23 31 32 36 3c 3c  32 33 20 20 20 20 20 20  |1,#126<<23      |
00001390  20 20 20 3b 20 30 2e 35  0d 06 d6 22 a4 66 70 5f  |   ; 0.5...".fp_|
000013a0  61 64 64 28 30 2c 78 2c  31 29 20 20 20 20 20 20  |add(0,x,1)      |
000013b0  20 20 20 3b 20 78 2b 30  2e 35 0d 06 e0 2f a4 66  |   ; x+0.5.../.f|
000013c0  70 5f 73 71 72 28 77 72  6b 31 2c 30 29 20 20 20  |p_sqr(wrk1,0)   |
000013d0  20 20 20 20 20 3b 20 78  72 3d 28 78 2b 30 2e 35  |     ; xr=(x+0.5|
000013e0  29 2a 28 78 2b 30 2e 35  29 0d 06 ea 16 4c 44 52  |)*(x+0.5)....LDR|
000013f0  20 77 72 6b 32 2c 6e 65  77 74 6f 6e 5f 72 32 0d  | wrk2,newton_r2.|
00001400  06 f4 28 a4 66 70 5f 73  75 62 28 30 2c 79 2c 77  |..(.fp_sub(0,y,w|
00001410  72 6b 32 29 20 20 20 20  20 20 3b 20 79 2d 30 2e  |rk2)      ; y-0.|
00001420  38 36 36 30 32 35 34 0d  06 fe 3b a4 66 70 5f 73  |8660254...;.fp_s|
00001430  71 72 28 30 2c 30 29 20  20 20 20 20 20 20 20 20  |qr(0,0)         |
00001440  20 20 3b 20 79 72 3d 28  79 2d 30 2e 38 36 36 30  |  ; yr=(y-0.8660|
00001450  32 35 34 29 2a 28 79 2d  30 2e 38 36 36 30 32 35  |254)*(y-0.866025|
00001460  34 29 0d 07 08 22 a4 66  70 5f 61 64 64 28 30 2c  |4)...".fp_add(0,|
00001470  77 72 6b 31 2c 30 29 20  20 20 20 20 20 3b 20 78  |wrk1,0)      ; x|
00001480  72 2b 79 72 0d 07 12 25  43 4d 50 20 52 30 2c 65  |r+yr...%CMP R0,e|
00001490  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000014a0  3b 20 52 6f 6f 74 20 32  3f 0d 07 1c 11 4d 4f 56  |; Root 2?....MOV|
000014b0  4c 54 20 72 6f 6f 74 2c  23 32 0d 07 26 0d 42 4c  |LT root,#2..&.BL|
000014c0  54 20 6e 65 78 69 74 0d  07 30 16 3b 20 43 68 65  |T nexit..0.; Che|
000014d0  63 6b 20 66 6f 72 20 72  6f 6f 74 3d 33 0d 07 3a  |ck for root=3..:|
000014e0  28 a4 66 70 5f 61 64 64  28 30 2c 79 2c 77 72 6b  |(.fp_add(0,y,wrk|
000014f0  32 29 20 20 20 20 20 20  3b 20 79 2b 30 2e 38 36  |2)      ; y+0.86|
00001500  36 30 32 35 34 0d 07 44  3b a4 66 70 5f 73 71 72  |60254..D;.fp_sqr|
00001510  28 30 2c 30 29 20 20 20  20 20 20 20 20 20 20 20  |(0,0)           |
00001520  3b 20 79 72 3d 28 79 2b  30 2e 38 36 36 30 32 35  |; yr=(y+0.866025|
00001530  34 29 2a 28 79 2b 30 2e  38 36 36 30 32 35 34 29  |4)*(y+0.8660254)|
00001540  0d 07 4e 22 a4 66 70 5f  61 64 64 28 30 2c 77 72  |..N".fp_add(0,wr|
00001550  6b 31 2c 30 29 20 20 20  20 20 20 3b 20 78 72 2b  |k1,0)      ; xr+|
00001560  79 72 0d 07 58 25 43 4d  50 20 52 30 2c 65 20 20  |yr..X%CMP R0,e  |
00001570  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00001580  52 6f 6f 74 20 33 3f 0d  07 62 11 4d 4f 56 4c 54  |Root 3?..b.MOVLT|
00001590  20 72 6f 6f 74 2c 23 33  0d 07 6c 0d 42 4c 54 20  | root,#3..l.BLT |
000015a0  6e 65 78 69 74 0d 07 76  05 3b 0d 07 80 17 53 55  |nexit..v.;....SU|
000015b0  42 53 20 64 65 70 74 68  2c 64 65 70 74 68 2c 23  |BS depth,depth,#|
000015c0  31 0d 07 8a 0d 42 4e 45  20 6e 6c 6f 6f 70 0d 07  |1....BNE nloop..|
000015d0  94 31 4c 44 52 20 64 65  70 74 68 2c 6e 69 74 65  |.1LDR depth,nite|
000015e0  72 20 20 20 20 20 20 20  20 20 3b 20 4e 6f 20 63  |r         ; No c|
000015f0  6f 6c 6f 75 72 20 69 66  20 61 74 20 6d 61 78 0d  |olour if at max.|
00001600  07 9e 0a 2e 6e 65 78 69  74 0d 07 a8 10 4c 44 52  |....nexit....LDR|
00001610  20 52 30 2c 6e 69 74 65  72 0d 07 b2 2b 53 55 42  | R0,niter...+SUB|
00001620  20 52 30 2c 52 30 2c 64  65 70 74 68 20 20 20 20  | R0,R0,depth    |
00001630  20 20 20 20 20 3b 20 72  65 74 75 72 6e 20 63 6f  |     ; return co|
00001640  6c 6f 75 72 0d 07 bc 30  41 44 44 20 52 30 2c 52  |lour...0ADD R0,R|
00001650  30 2c 23 31 36 20 20 20  20 20 20 20 20 20 20 20  |0,#16           |
00001660  3b 20 61 76 6f 69 64 20  64 61 72 6b 20 63 6f 6c  |; avoid dark col|
00001670  6f 75 72 73 0d 07 c6 22  4c 44 4d 46 44 20 52 31  |ours..."LDMFD R1|
00001680  33 21 2c 7b 50 43 7d 5e  20 20 20 20 20 20 20 20  |3!,{PC}^        |
00001690  3b 20 65 78 69 74 0d 07  d0 05 3b 0d 07 da 23 2e  |; exit....;...#.|
000016a0  74 77 6f 74 68 69 72 64  20 a4 66 70 28 22 44 46  |twothird .fp("DF|
000016b0  53 20 30 2e 36 36 36 36  36 36 36 36 22 29 0d 07  |S 0.66666666")..|
000016c0  e4 1f 2e 6e 65 77 74 6f  6e 5f 65 20 a4 66 70 28  |...newton_e .fp(|
000016d0  22 44 46 53 20 30 2e 30  30 32 35 22 29 0d 07 ee  |"DFS 0.0025")...|
000016e0  23 2e 6e 65 77 74 6f 6e  5f 72 32 20 a4 66 70 28  |#.newton_r2 .fp(|
000016f0  22 44 46 53 20 30 2e 38  36 36 30 32 35 34 22 29  |"DFS 0.8660254")|
00001700  0d 07 f8 1c 2e 66 70 5f  74 68 72 65 65 20 a4 66  |.....fp_three .f|
00001710  70 28 22 44 46 53 20 33  2e 30 22 29 0d 08 02 1f  |p("DFS 3.0")....|
00001720  3b 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |;---------------|
00001730  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 0d 08 0c 37 a4  |-----------...7.|
00001740  66 69 6e 74 65 72 66 61  63 65 20 20 20 20 20 20  |finterface      |
00001750  20 20 20 20 20 20 3b 20  4e 65 63 65 73 73 61 72  |      ; Necessar|
00001760  79 20 43 20 49 6e 74 65  72 66 61 63 65 20 63 6f  |y C Interface co|
00001770  64 65 0d 08 16 25 a4 66  70 65 61 73 6d 28 a3 29  |de...%.fpeasm(.)|
00001780  20 20 20 20 20 20 20 20  20 3b 20 46 50 45 20 72  |         ; FPE r|
00001790  6f 75 74 69 6e 65 73 0d  08 20 07 5d 3a ed 0d 08  |outines.. .]:...|
000017a0  2a 3a c8 99 20 22 4f 53  5f 46 69 6c 65 22 2c 31  |*:.. "OS_File",1|
000017b0  30 2c 22 3c 46 72 61 63  24 44 69 72 3e 2e 53 61  |0,"<Frac$Dir>.Sa|
000017c0  6d 70 4e 65 77 74 6f 6e  22 2c 26 46 46 41 2c 2c  |mpNewton",&FFA,,|
000017d0  63 6f 64 65 25 2c 4f 25  0d 08 34 05 e0 0d ff     |code%,O%..4....|
000017df