Home » Archimedes archive » Acorn Computing » 1994 09.adf » 9409 » TechForum/DivMod07
TechForum/DivMod07
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 Computing » 1994 09.adf » 9409 |
Filename: | TechForum/DivMod07 |
Read OK: | ✔ |
File size: | 0683 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10REM >DivMod7 20: 30MODE 0 40DIM mod 1024 50a=0:b=1:c=2:d=3 60FOR pass%=0 TO 3 STEP 3 70P%=mod 80[ OPT pass% 90 ADDS a,b,b ;remove iff b always +'ve 100 RSBCS b,b,#0 ;remove iff b always +'ve 110 ADC d,d,d ;remove iff b always +'ve 120 ADD a,b,b,LSR #3 130 ADD a,a,a,LSR #6 140 ADD a,a,a,LSR #12 150 ADD a,a,a,LSR #24 160 MOV a,a,LSR #3 170 RSB c,a,a,ASL #3 180 SUB c,b,c 190 CMP c,#7 200 ADDGE a,a,#1 ;remove if don't need quotient 210 SUBGE c,c,#7 ;remove if don't need remainder 220 MOVS d,d,ASR #1 ;remove iff b always +'ve 230 RSBCS a,a,#0 ;remove iff b always +'ve or don't need quotient 240 RSBCS c,c,#0 ;remove iff b always +'ve or don't need remainder 250 RSBCS b,b,#0 ;remove iff don't need to preserve sign of b or b always +'ve 260 STR c, m% 270 MOV pc,R14 280.m% EQUD 0 290] 300NEXT 310B%=0 320REPEAT 330 B%=-B% 340 C%=USR(mod) 350 D%=B%DIV7: E%=B%MOD7 360 IF C%<>D% OR !m%<>E% PRINT"******************************************************************":VDU 7 370 PRINT B%,C%,!m%;" ", D%,E% 380 IF C%<>D% OR !m%<>E% PRINT"******************************************************************":VDU 7 390 B%=-B% 400 C%=USR(mod) 410 D%=B%DIV7: E%=B%MOD7 420 IF C%<>D% OR !m%<>E% PRINT"******************************************************************":VDU 7 430 PRINT B%,C%,!m%;" ", D%,E% 440 IF C%<>D% OR !m%<>E% PRINT"******************************************************************":VDU 7 450 B%+=1 460UNTIL FALSE 470END
� >DivMod7 : � 0 (� mod 1024 2a=0:b=1:c=2:d=3 <� pass%=0 � 3 � 3 F P%=mod P[ OPT pass% Z= ADDS a,b,b ;remove iff b always +'ve d= RSBCS b,b,#0 ;remove iff b always +'ve n= ADC d,d,d ;remove iff b always +'ve x ADD a,b,b,LSR #3 � ADD a,a,a,LSR #6 �! ADD a,a,a,LSR #12 �! ADD a,a,a,LSR #24 � MOV a,a,LSR #3 � RSB c,a,a,ASL #3 � SUB c,b,c � CMP c,#7 �B ADDGE a,a,#1 ;remove if don't need quotient �C SUBGE c,c,#7 ;remove if don't need remainder �= MOVS d,d,ASR #1 ;remove iff b always +'ve �T RSBCS a,a,#0 ;remove iff b always +'ve or don't need quotient �U RSBCS c,c,#0 ;remove iff b always +'ve or don't need remainder �a RSBCS b,b,#0 ;remove iff don't need to preserve sign of b or b always +'ve STR c, m% MOV pc,R14 .m% EQUD 0 "] ,� 6B%=0 @� J B%=-B% T C%=�(mod) ^ D%=B%�7: E%=B%�7 hb � C%<>D% � !m%<>E% �"******************************************************************":� 7 r � B%,C%,!m%;" ", D%,E% |b � C%<>D% � !m%<>E% �"******************************************************************":� 7 � B%=-B% � C%=�(mod) � D%=B%�7: E%=B%�7 �b � C%<>D% � !m%<>E% �"******************************************************************":� 7 � � B%,C%,!m%;" ", D%,E% �b � C%<>D% � !m%<>E% �"******************************************************************":� 7 � B%+=1 �� � �� �
00000000 0d 00 0a 0e f4 20 3e 44 69 76 4d 6f 64 37 0d 00 |..... >DivMod7..| 00000010 14 05 3a 0d 00 1e 07 eb 20 30 0d 00 28 0e de 20 |..:..... 0..(.. | 00000020 6d 6f 64 20 31 30 32 34 0d 00 32 13 61 3d 30 3a |mod 1024..2.a=0:| 00000030 62 3d 31 3a 63 3d 32 3a 64 3d 33 0d 00 3c 15 e3 |b=1:c=2:d=3..<..| 00000040 20 70 61 73 73 25 3d 30 20 b8 20 33 20 88 20 33 | pass%=0 . 3 . 3| 00000050 0d 00 46 0a 50 25 3d 6d 6f 64 0d 00 50 19 5b 20 |..F.P%=mod..P.[ | 00000060 20 20 20 20 20 20 4f 50 54 20 20 20 20 20 70 61 | OPT pa| 00000070 73 73 25 0d 00 5a 3d 20 20 20 20 20 20 20 20 41 |ss%..Z= A| 00000080 44 44 53 20 20 20 20 61 2c 62 2c 62 20 20 20 20 |DDS a,b,b | 00000090 20 20 20 20 20 20 20 3b 72 65 6d 6f 76 65 20 69 | ;remove i| 000000a0 66 66 20 62 20 61 6c 77 61 79 73 20 2b 27 76 65 |ff b always +'ve| 000000b0 0d 00 64 3d 20 20 20 20 20 20 20 20 52 53 42 43 |..d= RSBC| 000000c0 53 20 20 20 62 2c 62 2c 23 30 20 20 20 20 20 20 |S b,b,#0 | 000000d0 20 20 20 20 3b 72 65 6d 6f 76 65 20 69 66 66 20 | ;remove iff | 000000e0 62 20 61 6c 77 61 79 73 20 2b 27 76 65 0d 00 6e |b always +'ve..n| 000000f0 3d 20 20 20 20 20 20 20 20 41 44 43 20 20 20 20 |= ADC | 00000100 20 64 2c 64 2c 64 20 20 20 20 20 20 20 20 20 20 | d,d,d | 00000110 20 3b 72 65 6d 6f 76 65 20 69 66 66 20 62 20 61 | ;remove iff b a| 00000120 6c 77 61 79 73 20 2b 27 76 65 0d 00 78 20 20 20 |lways +'ve..x | 00000130 20 20 20 20 20 20 41 44 44 20 20 20 20 20 61 2c | ADD a,| 00000140 62 2c 62 2c 4c 53 52 20 23 33 0d 00 82 20 20 20 |b,b,LSR #3... | 00000150 20 20 20 20 20 20 41 44 44 20 20 20 20 20 61 2c | ADD a,| 00000160 61 2c 61 2c 4c 53 52 20 23 36 0d 00 8c 21 20 20 |a,a,LSR #6...! | 00000170 20 20 20 20 20 20 41 44 44 20 20 20 20 20 61 2c | ADD a,| 00000180 61 2c 61 2c 4c 53 52 20 23 31 32 0d 00 96 21 20 |a,a,LSR #12...! | 00000190 20 20 20 20 20 20 20 41 44 44 20 20 20 20 20 61 | ADD a| 000001a0 2c 61 2c 61 2c 4c 53 52 20 23 32 34 0d 00 a0 1e |,a,a,LSR #24....| 000001b0 20 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 20 | MOV | 000001c0 61 2c 61 2c 4c 53 52 20 23 33 0d 00 aa 20 20 20 |a,a,LSR #3... | 000001d0 20 20 20 20 20 20 52 53 42 20 20 20 20 20 63 2c | RSB c,| 000001e0 61 2c 61 2c 41 53 4c 20 23 33 0d 00 b4 19 20 20 |a,a,ASL #3.... | 000001f0 20 20 20 20 20 20 53 55 42 20 20 20 20 20 63 2c | SUB c,| 00000200 62 2c 63 0d 00 be 18 20 20 20 20 20 20 20 20 43 |b,c.... C| 00000210 4d 50 20 20 20 20 20 63 2c 23 37 0d 00 c8 42 20 |MP c,#7...B | 00000220 20 20 20 20 20 20 20 41 44 44 47 45 20 20 20 61 | ADDGE a| 00000230 2c 61 2c 23 31 20 20 20 20 20 20 20 20 20 20 3b |,a,#1 ;| 00000240 72 65 6d 6f 76 65 20 69 66 20 64 6f 6e 27 74 20 |remove if don't | 00000250 6e 65 65 64 20 71 75 6f 74 69 65 6e 74 0d 00 d2 |need quotient...| 00000260 43 20 20 20 20 20 20 20 20 53 55 42 47 45 20 20 |C SUBGE | 00000270 20 63 2c 63 2c 23 37 20 20 20 20 20 20 20 20 20 | c,c,#7 | 00000280 20 3b 72 65 6d 6f 76 65 20 69 66 20 64 6f 6e 27 | ;remove if don'| 00000290 74 20 6e 65 65 64 20 72 65 6d 61 69 6e 64 65 72 |t need remainder| 000002a0 0d 00 dc 3d 20 20 20 20 20 20 20 20 4d 4f 56 53 |...= MOVS| 000002b0 20 20 20 20 64 2c 64 2c 41 53 52 20 23 31 20 20 | d,d,ASR #1 | 000002c0 20 20 20 20 3b 72 65 6d 6f 76 65 20 69 66 66 20 | ;remove iff | 000002d0 62 20 61 6c 77 61 79 73 20 2b 27 76 65 0d 00 e6 |b always +'ve...| 000002e0 54 20 20 20 20 20 20 20 20 52 53 42 43 53 20 20 |T RSBCS | 000002f0 20 61 2c 61 2c 23 30 20 20 20 20 20 20 20 20 20 | a,a,#0 | 00000300 20 3b 72 65 6d 6f 76 65 20 69 66 66 20 62 20 61 | ;remove iff b a| 00000310 6c 77 61 79 73 20 2b 27 76 65 20 6f 72 20 64 6f |lways +'ve or do| 00000320 6e 27 74 20 6e 65 65 64 20 71 75 6f 74 69 65 6e |n't need quotien| 00000330 74 0d 00 f0 55 20 20 20 20 20 20 20 20 52 53 42 |t...U RSB| 00000340 43 53 20 20 20 63 2c 63 2c 23 30 20 20 20 20 20 |CS c,c,#0 | 00000350 20 20 20 20 20 3b 72 65 6d 6f 76 65 20 69 66 66 | ;remove iff| 00000360 20 62 20 61 6c 77 61 79 73 20 2b 27 76 65 20 6f | b always +'ve o| 00000370 72 20 64 6f 6e 27 74 20 6e 65 65 64 20 72 65 6d |r don't need rem| 00000380 61 69 6e 64 65 72 0d 00 fa 61 20 20 20 20 20 20 |ainder...a | 00000390 20 20 52 53 42 43 53 20 20 20 62 2c 62 2c 23 30 | RSBCS b,b,#0| 000003a0 20 20 20 20 20 20 20 20 20 20 3b 72 65 6d 6f 76 | ;remov| 000003b0 65 20 69 66 66 20 64 6f 6e 27 74 20 6e 65 65 64 |e iff don't need| 000003c0 20 74 6f 20 70 72 65 73 65 72 76 65 20 73 69 67 | to preserve sig| 000003d0 6e 20 6f 66 20 62 20 6f 72 20 62 20 61 6c 77 61 |n of b or b alwa| 000003e0 79 73 20 2b 27 76 65 0d 01 04 19 20 20 20 20 20 |ys +'ve.... | 000003f0 20 20 20 53 54 52 20 20 20 20 20 63 2c 20 6d 25 | STR c, m%| 00000400 0d 01 0e 1a 20 20 20 20 20 20 20 20 4d 4f 56 20 |.... MOV | 00000410 20 20 20 20 70 63 2c 52 31 34 0d 01 18 15 2e 6d | pc,R14.....m| 00000420 25 20 20 20 20 20 45 51 55 44 20 20 20 20 30 0d |% EQUD 0.| 00000430 01 22 05 5d 0d 01 2c 05 ed 0d 01 36 08 42 25 3d |.".]..,....6.B%=| 00000440 30 0d 01 40 05 f5 0d 01 4a 0c 20 20 42 25 3d 2d |0..@....J. B%=-| 00000450 42 25 0d 01 54 0f 20 20 43 25 3d ba 28 6d 6f 64 |B%..T. C%=.(mod| 00000460 29 0d 01 5e 16 20 20 44 25 3d 42 25 81 37 3a 20 |)..^. D%=B%.7: | 00000470 45 25 3d 42 25 83 37 0d 01 68 62 20 20 e7 20 43 |E%=B%.7..hb . C| 00000480 25 3c 3e 44 25 20 84 20 21 6d 25 3c 3e 45 25 20 |%<>D% . !m%<>E% | 00000490 f1 22 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |."**************| 000004a0 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 000004d0 2a 2a 2a 2a 22 3a ef 20 37 0d 01 72 1d 20 20 f1 |****":. 7..r. .| 000004e0 20 42 25 2c 43 25 2c 21 6d 25 3b 22 20 20 22 2c | B%,C%,!m%;" ",| 000004f0 20 44 25 2c 45 25 0d 01 7c 62 20 20 e7 20 43 25 | D%,E%..|b . C%| 00000500 3c 3e 44 25 20 84 20 21 6d 25 3c 3e 45 25 20 f1 |<>D% . !m%<>E% .| 00000510 22 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |"***************| 00000520 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000550 2a 2a 2a 22 3a ef 20 37 0d 01 86 0c 20 20 42 25 |***":. 7.... B%| 00000560 3d 2d 42 25 0d 01 90 0f 20 20 43 25 3d ba 28 6d |=-B%.... C%=.(m| 00000570 6f 64 29 0d 01 9a 16 20 20 44 25 3d 42 25 81 37 |od).... D%=B%.7| 00000580 3a 20 45 25 3d 42 25 83 37 0d 01 a4 62 20 20 e7 |: E%=B%.7...b .| 00000590 20 43 25 3c 3e 44 25 20 84 20 21 6d 25 3c 3e 45 | C%<>D% . !m%<>E| 000005a0 25 20 f1 22 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |% ."************| 000005b0 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 000005e0 2a 2a 2a 2a 2a 2a 22 3a ef 20 37 0d 01 ae 1d 20 |******":. 7.... | 000005f0 20 f1 20 42 25 2c 43 25 2c 21 6d 25 3b 22 20 20 | . B%,C%,!m%;" | 00000600 22 2c 20 44 25 2c 45 25 0d 01 b8 62 20 20 e7 20 |", D%,E%...b . | 00000610 43 25 3c 3e 44 25 20 84 20 21 6d 25 3c 3e 45 25 |C%<>D% . !m%<>E%| 00000620 20 f1 22 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a | ."*************| 00000630 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000660 2a 2a 2a 2a 2a 22 3a ef 20 37 0d 01 c2 0b 20 20 |*****":. 7.... | 00000670 42 25 2b 3d 31 0d 01 cc 07 fd 20 a3 0d 01 d6 05 |B%+=1..... .....| 00000680 e0 0d ff |...| 00000683