Home » Archimedes archive » Acorn User » AU 1998-04 A.adf » Regulars » StarInfo/Reysenbach/MTest
StarInfo/Reysenbach/MTest
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 » Acorn User » AU 1998-04 A.adf » Regulars |
Filename: | StarInfo/Reysenbach/MTest |
Read OK: | ✔ |
File size: | 0DA5 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10 REM >MTEST2 20 REM checks if 2^P-1 is a so called Mersenne prime number 30 REM by A Reysenbach 40 : 50 MODE 28 60 size%=29 :REM adjust size% HERE 70 room%=4+3*(size%<<10) 80 a=0:b=1:c=2 90 d=3:e=4:f=5:g=6 100 exp=7:num=8:w=9 110 x=10:y=11:z=12 120 DIM test 420 + room% 130 FOR pass=0 TO 2 STEP 2 140 P%=test 150[ 160 OPT pass 170 ADR d,block 180 ADD x,d,#size%<<11 190 ADD num,x,#size%<<10 200 SUB b,exp,#1 210 MOV w,b,LSR #4 220 MOV w,w,LSL #2 230 ADD f,w,#4 240 SUB c,num,f 250 MOV z,#0 260.zeroes 270 STR z,[c,f] 280 SUBS f,f,#4 290 BGE zeroes 300 MOV c,#3 310 STR c,[num] 320.square 330 SUB g,num,w 340 MOV e,x 350 MOV f,w 360.init 370 LDR c,[g,f] 380 MUL d,c,c 390 MOV c,d,LSR #16 400 BIC d,d,c,LSL #16 410 STR d,[e],#-4 420 SUBS f,f,#4 430 STR c,[e],#-4 440 BGE init 450 MOV g,#4 460 MOV y,#0 470.fetch 480 CMP g,w,LSL #1 490 BGE spread 500 MOV a,#0 510 SUBS c,g,w 520 MOVLE e,num 530 SUBGT e,num,c 540 SUBLE f,num,g 550 SUBGT f,num,w 560.accum 570 LDR c,[e],#-4 580 LDR d,[f],#4 590 MUL c,d,c 600 ADDS a,a,c 610 ADC z,z,#0 620 CMP e,f 630 BGT accum 640 LDR c,[x,-g] 650 ADDS a,a,a 660 ADC z,z,z 670 ADD c,c,y 680 ADDS a,a,c 690 ADC z,z,#0 700 MOV c,a,LSR #16 710 ADD y,c,z,LSL #16 720 BIC c,a,c,LSL #16 730 STR c,[x,-g] 740 ADD g,g,#4 750 MOV z,#0 760 B fetch 770.spread 780 LDR c,[x,-g] 790 ADD y,y,c 800 MOVS c,y,LSR #16 810 BICGT y,y,c,LSL #16 820 STR y,[x,-g] 830 ADDGT g,g,#4 840 LDRGT y,[x,-g] 850 ADDGT y,y,c 860 STRGT y,[x,-g] 870 LDR d,[x,-w] 880 AND y,exp,#%1111 890 MOV e,d,LSR y 900 BIC a,d,e,LSL y 910 MOV d,d,LSR y 920 STR a,[x,-w] 930 MOV f,w 940 SUB e,x,w 950 SUB g,e,w 960 SUB g,g,#4 970 SUB c,num,w 980.modul 990 LDR a,[g,f] 1000 MOV a,a,LSL #16 1010 ADD d,d,a,LSR y 1020 LDR a,[e,f] 1030 ADD a,d,a 1040 MOV d,a,LSR #16 1050 BIC a,a,d,LSL #16 1060 STR a,[c,f] 1070 SUBS f,f,#4 1080 BGE modul 1090 LDR a,[num,-w] 1100 MOV f,a,LSR y 1110.final 1120 BIC a,a,f,LSL y 1130 STR a,[num,-w] 1140 SUBS b,b,#1 1150 ADDEQ f,f,#4 1160 MOV d,num 1170.carry 1180 LDR a,[d],#-4 1190 ADD a,a,f 1200 MOVS f,a,LSR #16 1210 BIC a,a,f,LSL #16 1220 STR a,[d,#4] 1230 BGT carry 1240 CMP b,#0 1250 BGT square 1260 LDR a,[num,-w] 1270 MOVS f,a,LSR y 1280 BGT final 1290 LDR a,[num] 1300 MOV pc,r14 1310.block 1320 FN_work(room%) 1330] 1340 NEXT pass 1350 CLS:@%=1 1360 max%=(size%<<12)-31 1370 PRINT "initialising ......" 1380 DIM Q%(max%) 1390 FOR X%=3 TO SQR(max%) STEP 2 1400 IF Q%(X%)=0 FOR Y%=X%*X% TO max% STEP X%<<1:Q%(Y%)=1:NEXT 1410 NEXT 1420 TIME=0:H%=2203:CALL test:t=TIME/100:CLS 1430 REPEAT 1440 PRINT''''''''"2^EXP -1 (EXP= a prime "; 1450 PRINT"number between 3 and ";max%;")";:INPUT" ";H% 1460 H%=ABS(H%):IF H%<3 H%=3 1470 IF H%>max% PRINT'"adjust variable 'size%'":END 1480 r%=((H%/2203)^3)*t:Q$="Y" 1490 IF r%>5 THEN 1500 IFQ%(H%)=1ORH%MOD2=0PRINT'"(by the way, ";H%;" is NOT a prime number)" 1510 PRINT'"calculation may take about "; 1520 IF r%DIV86400>13 r%=r%-(r%MOD86400) 1530 IF r%>86399 PRINT r%DIV86400;" days ";:r%=(r%MOD86400)-(r%MOD3600) 1540 IF r%>3599 PRINT r%DIV3600;" hrs ";:r%=(r%MOD3600)-(r%MOD60) 1550 IF r%>59 PRINT r%DIV60;" min ";:r%=r%MOD60 1560 IF r%>0 PRINT r%;" sec"; 1570 INPUT'''''"perform calculation Y/N ";Q$ 1580 ENDIF 1590 CLS 1600 IF Q$="Y" OR Q$="y" THEN 1610 PRINT'"2^";H%;"-1 is "; 1620 Z%=USR(test) 1630 IF Z%<>1 PRINT"composite"ELSE PRINT"a 'Mersenne-prime'" 1640 ENDIF 1650 UNTIL FALSE 1660 END 1670 : 1680 DEF FN_work(bytes%) 1690 P%+=bytes% 1700 =pass
� >MTEST2 ; � checks if 2^P-1 is a so called Mersenne prime number � by A Reysenbach ( : 2 � 28 <3 size%=29 :� adjust size% HERE F room%=4+3*(size%<<10) P a=0:b=1:c=2 Z d=3:e=4:f=5:g=6 d exp=7:num=8:w=9 n x=10:y=11:z=12 x � test 420 + room% � � pass=0 � 2 � 2 � P%=test �[ � OPT pass � ADR d,block � ADD x,d,#size%<<11 � ADD num,x,#size%<<10 � SUB b,exp,#1 � MOV w,b,LSR #4 � MOV w,w,LSL #2 � ADD f,w,#4 � SUB c,num,f � MOV z,#0 .zeroes STR z,[c,f] SUBS f,f,#4 " BGE zeroes , MOV c,#3 6 STR c,[num] @.square J SUB g,num,w T MOV e,x ^ MOV f,w h .init r LDR c,[g,f] | MUL d,c,c � MOV c,d,LSR #16 � BIC d,d,c,LSL #16 � STR d,[e],#-4 � SUBS f,f,#4 � STR c,[e],#-4 � BGE init � MOV g,#4 � MOV y,#0 � .fetch � CMP g,w,LSL #1 � BGE spread � MOV a,#0 � SUBS c,g,w MOVLE e,num SUBGT e,num,c SUBLE f,num,g & SUBGT f,num,w 0 .accum : LDR c,[e],#-4 D LDR d,[f],#4 N MUL c,d,c X ADDS a,a,c b ADC z,z,#0 l CMP e,f v BGT accum � LDR c,[x,-g] � ADDS a,a,a � ADC z,z,z � ADD c,c,y � ADDS a,a,c � ADC z,z,#0 � MOV c,a,LSR #16 � ADD y,c,z,LSL #16 � BIC c,a,c,LSL #16 � STR c,[x,-g] � ADD g,g,#4 � MOV z,#0 � B fetch .spread LDR c,[x,-g] ADD y,y,c MOVS c,y,LSR #16 * BICGT y,y,c,LSL #16 4 STR y,[x,-g] > ADDGT g,g,#4 H LDRGT y,[x,-g] R ADDGT y,y,c \ STRGT y,[x,-g] f LDR d,[x,-w] p � y,exp,#%1111 z MOV e,d,LSR y � BIC a,d,e,LSL y � MOV d,d,LSR y � STR a,[x,-w] � MOV f,w � SUB e,x,w � SUB g,e,w � SUB g,g,#4 � SUB c,num,w � .modul � LDR a,[g,f] � MOV a,a,LSL #16 � ADD d,d,a,LSR y � LDR a,[e,f] ADD a,d,a MOV d,a,LSR #16 BIC a,a,d,LSL #16 $ STR a,[c,f] . SUBS f,f,#4 8 BGE modul B LDR a,[num,-w] L MOV f,a,LSR y V .final ` BIC a,a,f,LSL y j STR a,[num,-w] t SUBS b,b,#1 ~ ADDEQ f,f,#4 � MOV d,num � .carry � LDR a,[d],#-4 � ADD a,a,f � MOVS f,a,LSR #16 � BIC a,a,f,LSL #16 � STR a,[d,#4] � BGT carry � CMP b,#0 � BGT square � LDR a,[num,-w] � MOVS f,a,LSR y BGT final LDR a,[num] MOV pc,r14 .block ( �_work(room%) 2] < � pass F �:@%=1 P max%=(size%<<12)-31 Z � "initialising ......" d � Q%(max%) n � X%=3 � �(max%) � 2 x5 � Q%(X%)=0 � Y%=X%*X% � max% � X%<<1:Q%(Y%)=1:� � � �! �=0:H%=2203:� test:t=�/100:� � � �) �''''''''"2^EXP -1 (EXP= a prime "; �0 �"number between 3 and ";max%;")";:�" ";H% � H%=�(H%):� H%<3 H%=3 �- � H%>max% �'"adjust variable 'size%'":� � r%=((H%/2203)^3)*t:Q$="Y" � � r%>5 � �E �Q%(H%)=1�H%�2=0�'"(by the way, ";H%;" is NOT a prime number)" �' �'"calculation may take about "; �% � r%�86400>13 r%=r%-(r%�86400) �> � r%>86399 � r%�86400;" days ";:r%=(r%�86400)-(r%�3600) 8 � r%>3599 � r%�3600;" hrs ";:r%=(r%�3600)-(r%�60) ( � r%>59 � r%�60;" min ";:r%=r%�60 � r%>0 � r%;" sec"; "* �'''''"perform calculation Y/N ";Q$ , � 6 � @ � Q$="Y" � Q$="y" � J �'"2^";H%;"-1 is "; T Z%=�(test) ^2 � Z%<>1 �"composite"� �"a 'Mersenne-prime'" h � r � � | � � : � � �_work(bytes%) � P%+=bytes% � =pass �
00000000 0d 00 0a 0e 20 f4 20 3e 4d 54 45 53 54 32 0d 00 |.... . >MTEST2..| 00000010 14 3b 20 f4 20 63 68 65 63 6b 73 20 69 66 20 32 |.; . checks if 2| 00000020 5e 50 2d 31 20 69 73 20 61 20 73 6f 20 63 61 6c |^P-1 is a so cal| 00000030 6c 65 64 20 4d 65 72 73 65 6e 6e 65 20 70 72 69 |led Mersenne pri| 00000040 6d 65 20 6e 75 6d 62 65 72 0d 00 1e 16 20 f4 20 |me number.... . | 00000050 62 79 20 41 20 52 65 79 73 65 6e 62 61 63 68 0d |by A Reysenbach.| 00000060 00 28 06 20 3a 0d 00 32 09 20 eb 20 32 38 0d 00 |.(. :..2. . 28..| 00000070 3c 33 20 73 69 7a 65 25 3d 32 39 20 20 20 20 20 |<3 size%=29 | 00000080 20 20 20 20 20 20 20 20 20 20 20 20 20 3a f4 20 | :. | 00000090 61 64 6a 75 73 74 20 73 69 7a 65 25 20 48 45 52 |adjust size% HER| 000000a0 45 0d 00 46 1a 20 72 6f 6f 6d 25 3d 34 2b 33 2a |E..F. room%=4+3*| 000000b0 28 73 69 7a 65 25 3c 3c 31 30 29 0d 00 50 10 20 |(size%<<10)..P. | 000000c0 61 3d 30 3a 62 3d 31 3a 63 3d 32 0d 00 5a 14 20 |a=0:b=1:c=2..Z. | 000000d0 64 3d 33 3a 65 3d 34 3a 66 3d 35 3a 67 3d 36 0d |d=3:e=4:f=5:g=6.| 000000e0 00 64 14 20 65 78 70 3d 37 3a 6e 75 6d 3d 38 3a |.d. exp=7:num=8:| 000000f0 77 3d 39 0d 00 6e 13 20 78 3d 31 30 3a 79 3d 31 |w=9..n. x=10:y=1| 00000100 31 3a 7a 3d 31 32 0d 00 78 17 20 de 20 74 65 73 |1:z=12..x. . tes| 00000110 74 20 34 32 30 20 2b 20 72 6f 6f 6d 25 0d 00 82 |t 420 + room%...| 00000120 15 20 e3 20 70 61 73 73 3d 30 20 b8 20 32 20 88 |. . pass=0 . 2 .| 00000130 20 32 0d 00 8c 0c 20 50 25 3d 74 65 73 74 0d 00 | 2.... P%=test..| 00000140 96 05 5b 0d 00 a0 10 20 4f 50 54 20 20 20 20 70 |..[.... OPT p| 00000150 61 73 73 0d 00 aa 13 20 41 44 52 20 20 20 20 64 |ass.... ADR d| 00000160 2c 62 6c 6f 63 6b 0d 00 b4 1a 20 41 44 44 20 20 |,block.... ADD | 00000170 20 20 78 2c 64 2c 23 73 69 7a 65 25 3c 3c 31 31 | x,d,#size%<<11| 00000180 0d 00 be 1c 20 41 44 44 20 20 20 20 6e 75 6d 2c |.... ADD num,| 00000190 78 2c 23 73 69 7a 65 25 3c 3c 31 30 0d 00 c8 14 |x,#size%<<10....| 000001a0 20 53 55 42 20 20 20 20 62 2c 65 78 70 2c 23 31 | SUB b,exp,#1| 000001b0 0d 00 d2 16 20 4d 4f 56 20 20 20 20 77 2c 62 2c |.... MOV w,b,| 000001c0 4c 53 52 20 23 34 0d 00 dc 16 20 4d 4f 56 20 20 |LSR #4.... MOV | 000001d0 20 20 77 2c 77 2c 4c 53 4c 20 23 32 0d 00 e6 12 | w,w,LSL #2....| 000001e0 20 41 44 44 20 20 20 20 66 2c 77 2c 23 34 0d 00 | ADD f,w,#4..| 000001f0 f0 13 20 53 55 42 20 20 20 20 63 2c 6e 75 6d 2c |.. SUB c,num,| 00000200 66 0d 00 fa 10 20 4d 4f 56 20 20 20 20 7a 2c 23 |f.... MOV z,#| 00000210 30 0d 01 04 0b 2e 7a 65 72 6f 65 73 0d 01 0e 13 |0.....zeroes....| 00000220 20 53 54 52 20 20 20 20 7a 2c 5b 63 2c 66 5d 0d | STR z,[c,f].| 00000230 01 18 12 20 53 55 42 53 20 20 20 66 2c 66 2c 23 |... SUBS f,f,#| 00000240 34 0d 01 22 12 20 42 47 45 20 20 20 20 7a 65 72 |4..". BGE zer| 00000250 6f 65 73 0d 01 2c 10 20 4d 4f 56 20 20 20 20 63 |oes..,. MOV c| 00000260 2c 23 33 0d 01 36 13 20 53 54 52 20 20 20 20 63 |,#3..6. STR c| 00000270 2c 5b 6e 75 6d 5d 0d 01 40 0b 2e 73 71 75 61 72 |,[num]..@..squar| 00000280 65 0d 01 4a 13 20 53 55 42 20 20 20 20 67 2c 6e |e..J. SUB g,n| 00000290 75 6d 2c 77 0d 01 54 0f 20 4d 4f 56 20 20 20 20 |um,w..T. MOV | 000002a0 65 2c 78 0d 01 5e 0f 20 4d 4f 56 20 20 20 20 66 |e,x..^. MOV f| 000002b0 2c 77 0d 01 68 09 2e 69 6e 69 74 0d 01 72 13 20 |,w..h..init..r. | 000002c0 4c 44 52 20 20 20 20 63 2c 5b 67 2c 66 5d 0d 01 |LDR c,[g,f]..| 000002d0 7c 11 20 4d 55 4c 20 20 20 20 64 2c 63 2c 63 0d ||. MUL d,c,c.| 000002e0 01 86 17 20 4d 4f 56 20 20 20 20 63 2c 64 2c 4c |... MOV c,d,L| 000002f0 53 52 20 23 31 36 0d 01 90 19 20 42 49 43 20 20 |SR #16.... BIC | 00000300 20 20 64 2c 64 2c 63 2c 4c 53 4c 20 23 31 36 0d | d,d,c,LSL #16.| 00000310 01 9a 15 20 53 54 52 20 20 20 20 64 2c 5b 65 5d |... STR d,[e]| 00000320 2c 23 2d 34 0d 01 a4 12 20 53 55 42 53 20 20 20 |,#-4.... SUBS | 00000330 66 2c 66 2c 23 34 0d 01 ae 15 20 53 54 52 20 20 |f,f,#4.... STR | 00000340 20 20 63 2c 5b 65 5d 2c 23 2d 34 0d 01 b8 10 20 | c,[e],#-4.... | 00000350 42 47 45 20 20 20 20 69 6e 69 74 0d 01 c2 10 20 |BGE init.... | 00000360 4d 4f 56 20 20 20 20 67 2c 23 34 0d 01 cc 10 20 |MOV g,#4.... | 00000370 4d 4f 56 20 20 20 20 79 2c 23 30 0d 01 d6 0a 2e |MOV y,#0.....| 00000380 66 65 74 63 68 0d 01 e0 16 20 43 4d 50 20 20 20 |fetch.... CMP | 00000390 20 67 2c 77 2c 4c 53 4c 20 23 31 0d 01 ea 12 20 | g,w,LSL #1.... | 000003a0 42 47 45 20 20 20 20 73 70 72 65 61 64 0d 01 f4 |BGE spread...| 000003b0 10 20 4d 4f 56 20 20 20 20 61 2c 23 30 0d 01 fe |. MOV a,#0...| 000003c0 11 20 53 55 42 53 20 20 20 63 2c 67 2c 77 0d 02 |. SUBS c,g,w..| 000003d0 08 11 20 4d 4f 56 4c 45 20 20 65 2c 6e 75 6d 0d |.. MOVLE e,num.| 000003e0 02 12 13 20 53 55 42 47 54 20 20 65 2c 6e 75 6d |... SUBGT e,num| 000003f0 2c 63 0d 02 1c 13 20 53 55 42 4c 45 20 20 66 2c |,c.... SUBLE f,| 00000400 6e 75 6d 2c 67 0d 02 26 13 20 53 55 42 47 54 20 |num,g..&. SUBGT | 00000410 20 66 2c 6e 75 6d 2c 77 0d 02 30 0a 2e 61 63 63 | f,num,w..0..acc| 00000420 75 6d 0d 02 3a 15 20 4c 44 52 20 20 20 20 63 2c |um..:. LDR c,| 00000430 5b 65 5d 2c 23 2d 34 0d 02 44 14 20 4c 44 52 20 |[e],#-4..D. LDR | 00000440 20 20 20 64 2c 5b 66 5d 2c 23 34 0d 02 4e 11 20 | d,[f],#4..N. | 00000450 4d 55 4c 20 20 20 20 63 2c 64 2c 63 0d 02 58 11 |MUL c,d,c..X.| 00000460 20 41 44 44 53 20 20 20 61 2c 61 2c 63 0d 02 62 | ADDS a,a,c..b| 00000470 12 20 41 44 43 20 20 20 20 7a 2c 7a 2c 23 30 0d |. ADC z,z,#0.| 00000480 02 6c 0f 20 43 4d 50 20 20 20 20 65 2c 66 0d 02 |.l. CMP e,f..| 00000490 76 11 20 42 47 54 20 20 20 20 61 63 63 75 6d 0d |v. BGT accum.| 000004a0 02 80 14 20 4c 44 52 20 20 20 20 63 2c 5b 78 2c |... LDR c,[x,| 000004b0 2d 67 5d 0d 02 8a 11 20 41 44 44 53 20 20 20 61 |-g].... ADDS a| 000004c0 2c 61 2c 61 0d 02 94 11 20 41 44 43 20 20 20 20 |,a,a.... ADC | 000004d0 7a 2c 7a 2c 7a 0d 02 9e 11 20 41 44 44 20 20 20 |z,z,z.... ADD | 000004e0 20 63 2c 63 2c 79 0d 02 a8 11 20 41 44 44 53 20 | c,c,y.... ADDS | 000004f0 20 20 61 2c 61 2c 63 0d 02 b2 12 20 41 44 43 20 | a,a,c.... ADC | 00000500 20 20 20 7a 2c 7a 2c 23 30 0d 02 bc 17 20 4d 4f | z,z,#0.... MO| 00000510 56 20 20 20 20 63 2c 61 2c 4c 53 52 20 23 31 36 |V c,a,LSR #16| 00000520 0d 02 c6 19 20 41 44 44 20 20 20 20 79 2c 63 2c |.... ADD y,c,| 00000530 7a 2c 4c 53 4c 20 23 31 36 0d 02 d0 19 20 42 49 |z,LSL #16.... BI| 00000540 43 20 20 20 20 63 2c 61 2c 63 2c 4c 53 4c 20 23 |C c,a,c,LSL #| 00000550 31 36 0d 02 da 14 20 53 54 52 20 20 20 20 63 2c |16.... STR c,| 00000560 5b 78 2c 2d 67 5d 0d 02 e4 12 20 41 44 44 20 20 |[x,-g].... ADD | 00000570 20 20 67 2c 67 2c 23 34 0d 02 ee 10 20 4d 4f 56 | g,g,#4.... MOV| 00000580 20 20 20 20 7a 2c 23 30 0d 02 f8 11 20 42 20 20 | z,#0.... B | 00000590 20 20 20 20 66 65 74 63 68 0d 03 02 0b 2e 73 70 | fetch.....sp| 000005a0 72 65 61 64 0d 03 0c 14 20 4c 44 52 20 20 20 20 |read.... LDR | 000005b0 63 2c 5b 78 2c 2d 67 5d 0d 03 16 11 20 41 44 44 |c,[x,-g].... ADD| 000005c0 20 20 20 20 79 2c 79 2c 63 0d 03 20 17 20 4d 4f | y,y,c.. . MO| 000005d0 56 53 20 20 20 63 2c 79 2c 4c 53 52 20 23 31 36 |VS c,y,LSR #16| 000005e0 0d 03 2a 19 20 42 49 43 47 54 20 20 79 2c 79 2c |..*. BICGT y,y,| 000005f0 63 2c 4c 53 4c 20 23 31 36 0d 03 34 14 20 53 54 |c,LSL #16..4. ST| 00000600 52 20 20 20 20 79 2c 5b 78 2c 2d 67 5d 0d 03 3e |R y,[x,-g]..>| 00000610 12 20 41 44 44 47 54 20 20 67 2c 67 2c 23 34 0d |. ADDGT g,g,#4.| 00000620 03 48 14 20 4c 44 52 47 54 20 20 79 2c 5b 78 2c |.H. LDRGT y,[x,| 00000630 2d 67 5d 0d 03 52 11 20 41 44 44 47 54 20 20 79 |-g]..R. ADDGT y| 00000640 2c 79 2c 63 0d 03 5c 14 20 53 54 52 47 54 20 20 |,y,c..\. STRGT | 00000650 79 2c 5b 78 2c 2d 67 5d 0d 03 66 14 20 4c 44 52 |y,[x,-g]..f. LDR| 00000660 20 20 20 20 64 2c 5b 78 2c 2d 77 5d 0d 03 70 16 | d,[x,-w]..p.| 00000670 20 80 20 20 20 20 79 2c 65 78 70 2c 23 25 31 31 | . y,exp,#%11| 00000680 31 31 0d 03 7a 15 20 4d 4f 56 20 20 20 20 65 2c |11..z. MOV e,| 00000690 64 2c 4c 53 52 20 79 0d 03 84 17 20 42 49 43 20 |d,LSR y.... BIC | 000006a0 20 20 20 61 2c 64 2c 65 2c 4c 53 4c 20 79 0d 03 | a,d,e,LSL y..| 000006b0 8e 15 20 4d 4f 56 20 20 20 20 64 2c 64 2c 4c 53 |.. MOV d,d,LS| 000006c0 52 20 79 0d 03 98 14 20 53 54 52 20 20 20 20 61 |R y.... STR a| 000006d0 2c 5b 78 2c 2d 77 5d 0d 03 a2 0f 20 4d 4f 56 20 |,[x,-w].... MOV | 000006e0 20 20 20 66 2c 77 0d 03 ac 11 20 53 55 42 20 20 | f,w.... SUB | 000006f0 20 20 65 2c 78 2c 77 0d 03 b6 11 20 53 55 42 20 | e,x,w.... SUB | 00000700 20 20 20 67 2c 65 2c 77 0d 03 c0 12 20 53 55 42 | g,e,w.... SUB| 00000710 20 20 20 20 67 2c 67 2c 23 34 0d 03 ca 13 20 53 | g,g,#4.... S| 00000720 55 42 20 20 20 20 63 2c 6e 75 6d 2c 77 0d 03 d4 |UB c,num,w...| 00000730 0a 2e 6d 6f 64 75 6c 0d 03 de 13 20 4c 44 52 20 |..modul.... LDR | 00000740 20 20 20 61 2c 5b 67 2c 66 5d 0d 03 e8 17 20 4d | a,[g,f].... M| 00000750 4f 56 20 20 20 20 61 2c 61 2c 4c 53 4c 20 23 31 |OV a,a,LSL #1| 00000760 36 0d 03 f2 17 20 41 44 44 20 20 20 20 64 2c 64 |6.... ADD d,d| 00000770 2c 61 2c 4c 53 52 20 79 0d 03 fc 13 20 4c 44 52 |,a,LSR y.... LDR| 00000780 20 20 20 20 61 2c 5b 65 2c 66 5d 0d 04 06 11 20 | a,[e,f].... | 00000790 41 44 44 20 20 20 20 61 2c 64 2c 61 0d 04 10 17 |ADD a,d,a....| 000007a0 20 4d 4f 56 20 20 20 20 64 2c 61 2c 4c 53 52 20 | MOV d,a,LSR | 000007b0 23 31 36 0d 04 1a 19 20 42 49 43 20 20 20 20 61 |#16.... BIC a| 000007c0 2c 61 2c 64 2c 4c 53 4c 20 23 31 36 0d 04 24 13 |,a,d,LSL #16..$.| 000007d0 20 53 54 52 20 20 20 20 61 2c 5b 63 2c 66 5d 0d | STR a,[c,f].| 000007e0 04 2e 12 20 53 55 42 53 20 20 20 66 2c 66 2c 23 |... SUBS f,f,#| 000007f0 34 0d 04 38 11 20 42 47 45 20 20 20 20 6d 6f 64 |4..8. BGE mod| 00000800 75 6c 0d 04 42 16 20 4c 44 52 20 20 20 20 61 2c |ul..B. LDR a,| 00000810 5b 6e 75 6d 2c 2d 77 5d 0d 04 4c 15 20 4d 4f 56 |[num,-w]..L. MOV| 00000820 20 20 20 20 66 2c 61 2c 4c 53 52 20 79 0d 04 56 | f,a,LSR y..V| 00000830 0a 2e 66 69 6e 61 6c 0d 04 60 17 20 42 49 43 20 |..final..`. BIC | 00000840 20 20 20 61 2c 61 2c 66 2c 4c 53 4c 20 79 0d 04 | a,a,f,LSL y..| 00000850 6a 16 20 53 54 52 20 20 20 20 61 2c 5b 6e 75 6d |j. STR a,[num| 00000860 2c 2d 77 5d 0d 04 74 12 20 53 55 42 53 20 20 20 |,-w]..t. SUBS | 00000870 62 2c 62 2c 23 31 0d 04 7e 12 20 41 44 44 45 51 |b,b,#1..~. ADDEQ| 00000880 20 20 66 2c 66 2c 23 34 0d 04 88 11 20 4d 4f 56 | f,f,#4.... MOV| 00000890 20 20 20 20 64 2c 6e 75 6d 0d 04 92 0a 2e 63 61 | d,num.....ca| 000008a0 72 72 79 0d 04 9c 15 20 4c 44 52 20 20 20 20 61 |rry.... LDR a| 000008b0 2c 5b 64 5d 2c 23 2d 34 0d 04 a6 11 20 41 44 44 |,[d],#-4.... ADD| 000008c0 20 20 20 20 61 2c 61 2c 66 0d 04 b0 17 20 4d 4f | a,a,f.... MO| 000008d0 56 53 20 20 20 66 2c 61 2c 4c 53 52 20 23 31 36 |VS f,a,LSR #16| 000008e0 0d 04 ba 19 20 42 49 43 20 20 20 20 61 2c 61 2c |.... BIC a,a,| 000008f0 66 2c 4c 53 4c 20 23 31 36 0d 04 c4 14 20 53 54 |f,LSL #16.... ST| 00000900 52 20 20 20 20 61 2c 5b 64 2c 23 34 5d 0d 04 ce |R a,[d,#4]...| 00000910 11 20 42 47 54 20 20 20 20 63 61 72 72 79 0d 04 |. BGT carry..| 00000920 d8 10 20 43 4d 50 20 20 20 20 62 2c 23 30 0d 04 |.. CMP b,#0..| 00000930 e2 12 20 42 47 54 20 20 20 20 73 71 75 61 72 65 |.. BGT square| 00000940 0d 04 ec 16 20 4c 44 52 20 20 20 20 61 2c 5b 6e |.... LDR a,[n| 00000950 75 6d 2c 2d 77 5d 0d 04 f6 15 20 4d 4f 56 53 20 |um,-w].... MOVS | 00000960 20 20 66 2c 61 2c 4c 53 52 20 79 0d 05 00 11 20 | f,a,LSR y.... | 00000970 42 47 54 20 20 20 20 66 69 6e 61 6c 0d 05 0a 13 |BGT final....| 00000980 20 4c 44 52 20 20 20 20 61 2c 5b 6e 75 6d 5d 0d | LDR a,[num].| 00000990 05 14 12 20 4d 4f 56 20 20 20 20 70 63 2c 72 31 |... MOV pc,r1| 000009a0 34 0d 05 1e 0a 2e 62 6c 6f 63 6b 0d 05 28 12 20 |4.....block..(. | 000009b0 a4 5f 77 6f 72 6b 28 72 6f 6f 6d 25 29 0d 05 32 |._work(room%)..2| 000009c0 05 5d 0d 05 3c 0b 20 ed 20 70 61 73 73 0d 05 46 |.]..<. . pass..F| 000009d0 0b 20 db 3a 40 25 3d 31 0d 05 50 18 20 6d 61 78 |. .:@%=1..P. max| 000009e0 25 3d 28 73 69 7a 65 25 3c 3c 31 32 29 2d 33 31 |%=(size%<<12)-31| 000009f0 0d 05 5a 1c 20 f1 20 22 69 6e 69 74 69 61 6c 69 |..Z. . "initiali| 00000a00 73 69 6e 67 20 2e 2e 2e 2e 2e 2e 22 0d 05 64 0f |sing ......"..d.| 00000a10 20 de 20 51 25 28 6d 61 78 25 29 0d 05 6e 19 20 | . Q%(max%)..n. | 00000a20 e3 20 58 25 3d 33 20 b8 20 b6 28 6d 61 78 25 29 |. X%=3 . .(max%)| 00000a30 20 88 20 32 0d 05 78 35 20 20 e7 20 51 25 28 58 | . 2..x5 . Q%(X| 00000a40 25 29 3d 30 20 e3 20 59 25 3d 58 25 2a 58 25 20 |%)=0 . Y%=X%*X% | 00000a50 b8 20 6d 61 78 25 20 88 20 58 25 3c 3c 31 3a 51 |. max% . X%<<1:Q| 00000a60 25 28 59 25 29 3d 31 3a ed 0d 05 82 06 20 ed 0d |%(Y%)=1:..... ..| 00000a70 05 8c 21 20 d1 3d 30 3a 48 25 3d 32 32 30 33 3a |..! .=0:H%=2203:| 00000a80 d6 20 74 65 73 74 3a 74 3d 91 2f 31 30 30 3a db |. test:t=./100:.| 00000a90 0d 05 96 06 20 f5 0d 05 a0 29 20 20 f1 27 27 27 |.... ....) .'''| 00000aa0 27 27 27 27 27 22 32 5e 45 58 50 20 2d 31 20 28 |'''''"2^EXP -1 (| 00000ab0 45 58 50 3d 20 61 20 70 72 69 6d 65 20 22 3b 0d |EXP= a prime ";.| 00000ac0 05 aa 30 20 20 f1 22 6e 75 6d 62 65 72 20 62 65 |..0 ."number be| 00000ad0 74 77 65 65 6e 20 33 20 61 6e 64 20 22 3b 6d 61 |tween 3 and ";ma| 00000ae0 78 25 3b 22 29 22 3b 3a e8 22 20 22 3b 48 25 0d |x%;")";:." ";H%.| 00000af0 05 b4 1a 20 20 48 25 3d 94 28 48 25 29 3a e7 20 |... H%=.(H%):. | 00000b00 48 25 3c 33 20 48 25 3d 33 0d 05 be 2d 20 20 e7 |H%<3 H%=3...- .| 00000b10 20 48 25 3e 6d 61 78 25 20 f1 27 22 61 64 6a 75 | H%>max% .'"adju| 00000b20 73 74 20 76 61 72 69 61 62 6c 65 20 27 73 69 7a |st variable 'siz| 00000b30 65 25 27 22 3a e0 0d 05 c8 1f 20 20 72 25 3d 28 |e%'":..... r%=(| 00000b40 28 48 25 2f 32 32 30 33 29 5e 33 29 2a 74 3a 51 |(H%/2203)^3)*t:Q| 00000b50 24 3d 22 59 22 0d 05 d2 0e 20 20 e7 20 72 25 3e |$="Y".... . r%>| 00000b60 35 20 8c 0d 05 dc 45 20 20 20 e7 51 25 28 48 25 |5 ....E .Q%(H%| 00000b70 29 3d 31 84 48 25 83 32 3d 30 f1 27 22 28 62 79 |)=1.H%.2=0.'"(by| 00000b80 20 74 68 65 20 77 61 79 2c 20 22 3b 48 25 3b 22 | the way, ";H%;"| 00000b90 20 69 73 20 4e 4f 54 20 61 20 70 72 69 6d 65 20 | is NOT a prime | 00000ba0 6e 75 6d 62 65 72 29 22 0d 05 e6 27 20 20 20 f1 |number)"...' .| 00000bb0 27 22 63 61 6c 63 75 6c 61 74 69 6f 6e 20 6d 61 |'"calculation ma| 00000bc0 79 20 74 61 6b 65 20 61 62 6f 75 74 20 22 3b 0d |y take about ";.| 00000bd0 05 f0 25 20 20 20 e7 20 72 25 81 38 36 34 30 30 |..% . r%.86400| 00000be0 3e 31 33 20 72 25 3d 72 25 2d 28 72 25 83 38 36 |>13 r%=r%-(r%.86| 00000bf0 34 30 30 29 0d 05 fa 3e 20 20 20 e7 20 72 25 3e |400)...> . r%>| 00000c00 38 36 33 39 39 20 f1 20 72 25 81 38 36 34 30 30 |86399 . r%.86400| 00000c10 3b 22 20 64 61 79 73 20 22 3b 3a 72 25 3d 28 72 |;" days ";:r%=(r| 00000c20 25 83 38 36 34 30 30 29 2d 28 72 25 83 33 36 30 |%.86400)-(r%.360| 00000c30 30 29 0d 06 04 38 20 20 20 e7 20 72 25 3e 33 35 |0)...8 . r%>35| 00000c40 39 39 20 f1 20 72 25 81 33 36 30 30 3b 22 20 68 |99 . r%.3600;" h| 00000c50 72 73 20 22 3b 3a 72 25 3d 28 72 25 83 33 36 30 |rs ";:r%=(r%.360| 00000c60 30 29 2d 28 72 25 83 36 30 29 0d 06 0e 28 20 20 |0)-(r%.60)...( | 00000c70 20 e7 20 72 25 3e 35 39 20 f1 20 72 25 81 36 30 | . r%>59 . r%.60| 00000c80 3b 22 20 6d 69 6e 20 22 3b 3a 72 25 3d 72 25 83 |;" min ";:r%=r%.| 00000c90 36 30 0d 06 18 1a 20 20 20 e7 20 72 25 3e 30 20 |60.... . r%>0 | 00000ca0 f1 20 72 25 3b 22 20 73 65 63 22 3b 0d 06 22 2a |. r%;" sec";.."*| 00000cb0 20 20 20 e8 27 27 27 27 27 22 70 65 72 66 6f 72 | .'''''"perfor| 00000cc0 6d 20 63 61 6c 63 75 6c 61 74 69 6f 6e 20 59 2f |m calculation Y/| 00000cd0 4e 20 22 3b 51 24 0d 06 2c 07 20 20 cd 0d 06 36 |N ";Q$..,. ...6| 00000ce0 07 20 20 db 0d 06 40 19 20 20 e7 20 51 24 3d 22 |. ...@. . Q$="| 00000cf0 59 22 20 84 20 51 24 3d 22 79 22 20 8c 0d 06 4a |Y" . Q$="y" ...J| 00000d00 1a 20 20 20 f1 27 22 32 5e 22 3b 48 25 3b 22 2d |. .'"2^";H%;"-| 00000d10 31 20 69 73 20 22 3b 0d 06 54 11 20 20 20 5a 25 |1 is ";..T. Z%| 00000d20 3d ba 28 74 65 73 74 29 0d 06 5e 32 20 20 20 e7 |=.(test)..^2 .| 00000d30 20 5a 25 3c 3e 31 20 f1 22 63 6f 6d 70 6f 73 69 | Z%<>1 ."composi| 00000d40 74 65 22 8b 20 f1 22 61 20 27 4d 65 72 73 65 6e |te". ."a 'Mersen| 00000d50 6e 65 2d 70 72 69 6d 65 27 22 0d 06 68 07 20 20 |ne-prime'"..h. | 00000d60 cd 0d 06 72 08 20 fd 20 a3 0d 06 7c 06 20 e0 0d |...r. . ...|. ..| 00000d70 06 86 06 20 3a 0d 06 90 15 20 dd 20 a4 5f 77 6f |... :.... . ._wo| 00000d80 72 6b 28 62 79 74 65 73 25 29 0d 06 9a 0f 20 50 |rk(bytes%).... P| 00000d90 25 2b 3d 62 79 74 65 73 25 0d 06 a4 0a 20 3d 70 |%+=bytes%.... =p| 00000da0 61 73 73 0d ff |ass..| 00000da5