Home » Archimedes archive » Archimedes World » AW-1995-05-Disc1.adf » AWMay95_1 » InTheMag/AcornAns/Inspire/DivMod03
InTheMag/AcornAns/Inspire/DivMod03
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 » Archimedes World » AW-1995-05-Disc1.adf » AWMay95_1 |
Filename: | InTheMag/AcornAns/Inspire/DivMod03 |
Read OK: | ✔ |
File size: | 0682 bytes |
Load address: | 0000 |
Exec address: | 0000 |
Duplicates
There are 2 duplicate copies of this file in the archive:
- Archimedes archive » Acorn Computing » 1994 09.adf » 9409 » TechForum/DivMod03
- Archimedes archive » Archimedes World » AW-1996-03-Disc 2.adf » !AcornAns_AcornAns » September/FastDiv/Inspire/DivMod03
- Archimedes archive » Archimedes World » AW-1995-05-Disc1.adf » AWMay95_1 » InTheMag/AcornAns/Inspire/DivMod03
File contents
10REM >DivMod3 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 #2 130 ADD a,a,a,LSR #4 140 ADD a,a,a,LSR #8 150 ADD a,a,a,LSR #16 160 MOV a,a,LSR #2 170 ADD c,a,a,ASL #1 180 SUB c,b,c 190 CMP c,#3 200 ADDGE a,a,#1 ;remove if don't need quotient 210 SUBGE c,c,#3 ;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%DIV3: E%=B%MOD3 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%DIV3: E%=B%MOD3 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
� >DivMod3 : � 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 #2 � ADD a,a,a,LSR #4 � ADD a,a,a,LSR #8 �! ADD a,a,a,LSR #16 � MOV a,a,LSR #2 � ADD c,a,a,ASL #1 � SUB c,b,c � CMP c,#3 �B ADDGE a,a,#1 ;remove if don't need quotient �C SUBGE c,c,#3 ;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%�3: E%=B%�3 hb � C%<>D% � !m%<>E% �"******************************************************************":� 7 r � B%,C%,!m%;" ", D%,E% |b � C%<>D% � !m%<>E% �"******************************************************************":� 7 � B%=-B% � C%=�(mod) � D%=B%�3: E%=B%�3 �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 33 0d 00 |..... >DivMod3..| 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 32 0d 00 82 20 20 20 |b,b,LSR #2... | 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 34 0d 00 8c 20 20 20 |a,a,LSR #4... | 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 38 0d 00 96 21 20 20 |a,a,LSR #8...! | 00000190 20 20 20 20 20 20 41 44 44 20 20 20 20 20 61 2c | ADD a,| 000001a0 61 2c 61 2c 4c 53 52 20 23 31 36 0d 00 a0 1e 20 |a,a,LSR #16.... | 000001b0 20 20 20 20 20 20 20 4d 4f 56 20 20 20 20 20 61 | MOV a| 000001c0 2c 61 2c 4c 53 52 20 23 32 0d 00 aa 20 20 20 20 |,a,LSR #2... | 000001d0 20 20 20 20 20 41 44 44 20 20 20 20 20 63 2c 61 | ADD c,a| 000001e0 2c 61 2c 41 53 4c 20 23 31 0d 00 b4 19 20 20 20 |,a,ASL #1.... | 000001f0 20 20 20 20 20 53 55 42 20 20 20 20 20 63 2c 62 | SUB c,b| 00000200 2c 63 0d 00 be 18 20 20 20 20 20 20 20 20 43 4d |,c.... CM| 00000210 50 20 20 20 20 20 63 2c 23 33 0d 00 c8 42 20 20 |P c,#3...B | 00000220 20 20 20 20 20 20 41 44 44 47 45 20 20 20 61 2c | ADDGE a,| 00000230 61 2c 23 31 20 20 20 20 20 20 20 20 20 20 3b 72 |a,#1 ;r| 00000240 65 6d 6f 76 65 20 69 66 20 64 6f 6e 27 74 20 6e |emove if don't n| 00000250 65 65 64 20 71 75 6f 74 69 65 6e 74 0d 00 d2 43 |eed quotient...C| 00000260 20 20 20 20 20 20 20 20 53 55 42 47 45 20 20 20 | SUBGE | 00000270 63 2c 63 2c 23 33 20 20 20 20 20 20 20 20 20 20 |c,c,#3 | 00000280 3b 72 65 6d 6f 76 65 20 69 66 20 64 6f 6e 27 74 |;remove if don't| 00000290 20 6e 65 65 64 20 72 65 6d 61 69 6e 64 65 72 0d | need remainder.| 000002a0 00 dc 3d 20 20 20 20 20 20 20 20 4d 4f 56 53 20 |..= MOVS | 000002b0 20 20 20 64 2c 64 2c 41 53 52 20 23 31 20 20 20 | d,d,ASR #1 | 000002c0 20 20 20 3b 72 65 6d 6f 76 65 20 69 66 66 20 62 | ;remove iff b| 000002d0 20 61 6c 77 61 79 73 20 2b 27 76 65 0d 00 e6 54 | always +'ve...T| 000002e0 20 20 20 20 20 20 20 20 52 53 42 43 53 20 20 20 | RSBCS | 000002f0 61 2c 61 2c 23 30 20 20 20 20 20 20 20 20 20 20 |a,a,#0 | 00000300 3b 72 65 6d 6f 76 65 20 69 66 66 20 62 20 61 6c |;remove iff b al| 00000310 77 61 79 73 20 2b 27 76 65 20 6f 72 20 64 6f 6e |ways +'ve or don| 00000320 27 74 20 6e 65 65 64 20 71 75 6f 74 69 65 6e 74 |'t need quotient| 00000330 0d 00 f0 55 20 20 20 20 20 20 20 20 52 53 42 43 |...U RSBC| 00000340 53 20 20 20 63 2c 63 2c 23 30 20 20 20 20 20 20 |S c,c,#0 | 00000350 20 20 20 20 3b 72 65 6d 6f 76 65 20 69 66 66 20 | ;remove iff | 00000360 62 20 61 6c 77 61 79 73 20 2b 27 76 65 20 6f 72 |b always +'ve or| 00000370 20 64 6f 6e 27 74 20 6e 65 65 64 20 72 65 6d 61 | don't need rema| 00000380 69 6e 64 65 72 0d 00 fa 61 20 20 20 20 20 20 20 |inder...a | 00000390 20 52 53 42 43 53 20 20 20 62 2c 62 2c 23 30 20 | RSBCS b,b,#0 | 000003a0 20 20 20 20 20 20 20 20 20 3b 72 65 6d 6f 76 65 | ;remove| 000003b0 20 69 66 66 20 64 6f 6e 27 74 20 6e 65 65 64 20 | iff don't need | 000003c0 74 6f 20 70 72 65 73 65 72 76 65 20 73 69 67 6e |to preserve sign| 000003d0 20 6f 66 20 62 20 6f 72 20 62 20 61 6c 77 61 79 | of b or b alway| 000003e0 73 20 2b 27 76 65 0d 01 04 19 20 20 20 20 20 20 |s +'ve.... | 000003f0 20 20 53 54 52 20 20 20 20 20 63 2c 20 6d 25 0d | STR c, m%.| 00000400 01 0e 1a 20 20 20 20 20 20 20 20 4d 4f 56 20 20 |... MOV | 00000410 20 20 20 70 63 2c 52 31 34 0d 01 18 15 2e 6d 25 | pc,R14.....m%| 00000420 20 20 20 20 20 45 51 55 44 20 20 20 20 30 0d 01 | EQUD 0..| 00000430 22 05 5d 0d 01 2c 05 ed 0d 01 36 08 42 25 3d 30 |".]..,....6.B%=0| 00000440 0d 01 40 05 f5 0d 01 4a 0c 20 20 42 25 3d 2d 42 |..@....J. B%=-B| 00000450 25 0d 01 54 0f 20 20 43 25 3d ba 28 6d 6f 64 29 |%..T. C%=.(mod)| 00000460 0d 01 5e 16 20 20 44 25 3d 42 25 81 33 3a 20 45 |..^. D%=B%.3: E| 00000470 25 3d 42 25 83 33 0d 01 68 62 20 20 e7 20 43 25 |%=B%.3..hb . C%| 00000480 3c 3e 44 25 20 84 20 21 6d 25 3c 3e 45 25 20 f1 |<>D% . !m%<>E% .| 00000490 22 2a 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 22 3a ef 20 37 0d 01 72 1d 20 20 f1 20 |***":. 7..r. . | 000004e0 42 25 2c 43 25 2c 21 6d 25 3b 22 20 20 22 2c 20 |B%,C%,!m%;" ", | 000004f0 44 25 2c 45 25 0d 01 7c 62 20 20 e7 20 43 25 3c |D%,E%..|b . C%<| 00000500 3e 44 25 20 84 20 21 6d 25 3c 3e 45 25 20 f1 22 |>D% . !m%<>E% ."| 00000510 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000550 2a 2a 22 3a ef 20 37 0d 01 86 0c 20 20 42 25 3d |**":. 7.... B%=| 00000560 2d 42 25 0d 01 90 0f 20 20 43 25 3d ba 28 6d 6f |-B%.... C%=.(mo| 00000570 64 29 0d 01 9a 16 20 20 44 25 3d 42 25 81 33 3a |d).... D%=B%.3:| 00000580 20 45 25 3d 42 25 83 33 0d 01 a4 62 20 20 e7 20 | E%=B%.3...b . | 00000590 43 25 3c 3e 44 25 20 84 20 21 6d 25 3c 3e 45 25 |C%<>D% . !m%<>E%| 000005a0 20 f1 22 2a 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 22 3a ef 20 37 0d 01 ae 1d 20 20 |*****":. 7.... | 000005f0 f1 20 42 25 2c 43 25 2c 21 6d 25 3b 22 20 20 22 |. B%,C%,!m%;" "| 00000600 2c 20 44 25 2c 45 25 0d 01 b8 62 20 20 e7 20 43 |, D%,E%...b . C| 00000610 25 3c 3e 44 25 20 84 20 21 6d 25 3c 3e 45 25 20 |%<>D% . !m%<>E% | 00000620 f1 22 2a 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 22 3a ef 20 37 0d 01 c2 0b 20 20 42 |****":. 7.... B| 00000670 25 2b 3d 31 0d 01 cc 07 fd 20 a3 0d 01 d6 05 e0 |%+=1..... ......| 00000680 0d ff |..| 00000682