Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199607.adf » Regulars » StarInfo/Thurlby/EasyDivARM

StarInfo/Thurlby/EasyDivARM

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 » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199607.adf » Regulars
Filename: StarInfo/Thurlby/EasyDivARM
Read OK:
File size: 063F bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >EasyDivARM
   20REM by DCA, based on a Basic program by Les Thurlby
   30REM (c) AU July 1996
   40:
   50MODE 0
   60PROCass
   61PRINT"Timing one million divisions..."
   62TIME=0
   63CALL test
   64PRINT"That took ";TIME/100;" seconds"''
   70REPEAT
   80 INPUT"Divide: "A%
   90 INPUT"By:     "B%
  100 IF B%=0 THEN
  110  PRINT"Division by zero!"
  120 ELSE
  130  CALL divide
  150  PRINT"Answer=";!quotient;", remainder ";!remainder
  151 ENDIF
  160UNTIL FALSE
  170:
  180DEF PROCass
  190DIM code% &400
  200sp=13:link=14:pc=15
  210FOR pass%=0 TO 2 STEP 2
  220P%=code%
  230[OPT pass%
  240.test
  250        STMFD   (sp)!,{link}
  260        MOV     r0,#1
  270.test_loop1
  280        MOV     r1,#1
  290.test_loop2
  300        STMFD   (sp)!,{r0-r1}
  301        BL      divide
  310        LDMFD   (sp)!,{r0-r1}
  320        ADD     r1,r1,#1
  330        CMP     r1,#1000
  340        BLE     test_loop2
  350        ADD     r0,r0,#1
  360        CMP     r0,#1000
  361        BLE     test_loop1
  390        LDMFD   (sp)!,{pc}
  450
  451        ; on entry r0=dividend, r1=divisor
  460        ; on exit, r0=quotient, r1=remainder (also stored)
  470.divide
  480        MOV     r3,#1
  490.div1
  500        CMP     r0,r1,ASL #1
  510        MOVGE   r1,r1,ASL #1
  520        MOVGE   r3,r3,ASL #1
  530        BGE     div1
  540        MOV     r2,#0
  550.div2   CMP     r0,r1
  560        SUBGE   r0,r0,r1
  570        ADDGE   r2,r2,r3
  580        MOV     r1,r1,ASR #1
  590        MOVS    r3,r3,ASR #1
  600        BNE     div2
  610        MOV     r1,r0
  620        MOV     r0,r2
  630        STR     r0,quotient
  640        STR     r1,remainder
  650        MOV     pc,link
  660        
  670.quotient
  680        DCD     0
  690.remainder
  700        DCD     0
  710]
  720NEXT pass%
  730ENDPROC

� >EasyDivARM
5� by DCA, based on a Basic program by Les Thurlby
� (c) AU July 1996
(:
2� 0
<�ass
=&�"Timing one million divisions..."
>�=0
?
� test
@$�"That took ";�/100;" seconds"''
F�
P �"Divide: "A%
Z �"By:     "B%
d
 � B%=0 �
n  �"Division by zero!"
x �
�  � divide
�4  �"Answer=";!quotient;", remainder ";!remainder
� �
�� �
�:
�
� �ass
�� code% &400
�sp=13:link=14:pc=15
�� pass%=0 � 2 � 2
�P%=code%
�[OPT pass%
�	.test
�         STMFD   (sp)!,{link}
        MOV     r0,#1
.test_loop1
        MOV     r1,#1
".test_loop2
,!        STMFD   (sp)!,{r0-r1}
-        BL      divide
6!        LDMFD   (sp)!,{r0-r1}
@        ADD     r1,r1,#1
J        CMP     r1,#1000
T        BLE     test_loop2
^        ADD     r0,r0,#1
h        CMP     r0,#1000
i        BLE     test_loop1
�        LDMFD   (sp)!,{pc}
�
�.        ; on entry r0=dividend, r1=divisor
�>        ; on exit, r0=quotient, r1=remainder (also stored)
�.divide
�        MOV     r3,#1
�	.div1
�         CMP     r0,r1,ASL #1
�         MOVGE   r1,r1,ASL #1
         MOVGE   r3,r3,ASL #1
        BGE     div1
        MOV     r2,#0
&.div2   CMP     r0,r1
0        SUBGE   r0,r0,r1
:        ADDGE   r2,r2,r3
D         MOV     r1,r1,ASR #1
N         MOVS    r3,r3,ASR #1
X        BNE     div2
b        MOV     r1,r0
l        MOV     r0,r2
v        STR     r0,quotient
�         STR     r1,remainder
�        MOV     pc,link
�        
�
.quotient
�        DCD     0
�.remainder
�        DCD     0
�]
�� pass%
��
�
00000000  0d 00 0a 11 f4 20 3e 45  61 73 79 44 69 76 41 52  |..... >EasyDivAR|
00000010  4d 0d 00 14 35 f4 20 62  79 20 44 43 41 2c 20 62  |M...5. by DCA, b|
00000020  61 73 65 64 20 6f 6e 20  61 20 42 61 73 69 63 20  |ased on a Basic |
00000030  70 72 6f 67 72 61 6d 20  62 79 20 4c 65 73 20 54  |program by Les T|
00000040  68 75 72 6c 62 79 0d 00  1e 16 f4 20 28 63 29 20  |hurlby..... (c) |
00000050  41 55 20 4a 75 6c 79 20  31 39 39 36 0d 00 28 05  |AU July 1996..(.|
00000060  3a 0d 00 32 07 eb 20 30  0d 00 3c 08 f2 61 73 73  |:..2.. 0..<..ass|
00000070  0d 00 3d 26 f1 22 54 69  6d 69 6e 67 20 6f 6e 65  |..=&."Timing one|
00000080  20 6d 69 6c 6c 69 6f 6e  20 64 69 76 69 73 69 6f  | million divisio|
00000090  6e 73 2e 2e 2e 22 0d 00  3e 07 d1 3d 30 0d 00 3f  |ns..."..>..=0..?|
000000a0  0a d6 20 74 65 73 74 0d  00 40 24 f1 22 54 68 61  |.. test..@$."Tha|
000000b0  74 20 74 6f 6f 6b 20 22  3b 91 2f 31 30 30 3b 22  |t took ";./100;"|
000000c0  20 73 65 63 6f 6e 64 73  22 27 27 0d 00 46 05 f5  | seconds"''..F..|
000000d0  0d 00 50 12 20 e8 22 44  69 76 69 64 65 3a 20 22  |..P. ."Divide: "|
000000e0  41 25 0d 00 5a 12 20 e8  22 42 79 3a 20 20 20 20  |A%..Z. ."By:    |
000000f0  20 22 42 25 0d 00 64 0d  20 e7 20 42 25 3d 30 20  | "B%..d. . B%=0 |
00000100  8c 0d 00 6e 1a 20 20 f1  22 44 69 76 69 73 69 6f  |...n.  ."Divisio|
00000110  6e 20 62 79 20 7a 65 72  6f 21 22 0d 00 78 06 20  |n by zero!"..x. |
00000120  cc 0d 00 82 0e 20 20 d6  20 64 69 76 69 64 65 0d  |.....  . divide.|
00000130  00 96 34 20 20 f1 22 41  6e 73 77 65 72 3d 22 3b  |..4  ."Answer=";|
00000140  21 71 75 6f 74 69 65 6e  74 3b 22 2c 20 72 65 6d  |!quotient;", rem|
00000150  61 69 6e 64 65 72 20 22  3b 21 72 65 6d 61 69 6e  |ainder ";!remain|
00000160  64 65 72 0d 00 97 06 20  cd 0d 00 a0 07 fd 20 a3  |der.... ...... .|
00000170  0d 00 aa 05 3a 0d 00 b4  0a dd 20 f2 61 73 73 0d  |....:..... .ass.|
00000180  00 be 10 de 20 63 6f 64  65 25 20 26 34 30 30 0d  |.... code% &400.|
00000190  00 c8 17 73 70 3d 31 33  3a 6c 69 6e 6b 3d 31 34  |...sp=13:link=14|
000001a0  3a 70 63 3d 31 35 0d 00  d2 15 e3 20 70 61 73 73  |:pc=15..... pass|
000001b0  25 3d 30 20 b8 20 32 20  88 20 32 0d 00 dc 0c 50  |%=0 . 2 . 2....P|
000001c0  25 3d 63 6f 64 65 25 0d  00 e6 0e 5b 4f 50 54 20  |%=code%....[OPT |
000001d0  70 61 73 73 25 0d 00 f0  09 2e 74 65 73 74 0d 00  |pass%.....test..|
000001e0  fa 20 20 20 20 20 20 20  20 20 53 54 4d 46 44 20  |.         STMFD |
000001f0  20 20 28 73 70 29 21 2c  7b 6c 69 6e 6b 7d 0d 01  |  (sp)!,{link}..|
00000200  04 19 20 20 20 20 20 20  20 20 4d 4f 56 20 20 20  |..        MOV   |
00000210  20 20 72 30 2c 23 31 0d  01 0e 0f 2e 74 65 73 74  |  r0,#1.....test|
00000220  5f 6c 6f 6f 70 31 0d 01  18 19 20 20 20 20 20 20  |_loop1....      |
00000230  20 20 4d 4f 56 20 20 20  20 20 72 31 2c 23 31 0d  |  MOV     r1,#1.|
00000240  01 22 0f 2e 74 65 73 74  5f 6c 6f 6f 70 32 0d 01  |."..test_loop2..|
00000250  2c 21 20 20 20 20 20 20  20 20 53 54 4d 46 44 20  |,!        STMFD |
00000260  20 20 28 73 70 29 21 2c  7b 72 30 2d 72 31 7d 0d  |  (sp)!,{r0-r1}.|
00000270  01 2d 1a 20 20 20 20 20  20 20 20 42 4c 20 20 20  |.-.        BL   |
00000280  20 20 20 64 69 76 69 64  65 0d 01 36 21 20 20 20  |   divide..6!   |
00000290  20 20 20 20 20 4c 44 4d  46 44 20 20 20 28 73 70  |     LDMFD   (sp|
000002a0  29 21 2c 7b 72 30 2d 72  31 7d 0d 01 40 1c 20 20  |)!,{r0-r1}..@.  |
000002b0  20 20 20 20 20 20 41 44  44 20 20 20 20 20 72 31  |      ADD     r1|
000002c0  2c 72 31 2c 23 31 0d 01  4a 1c 20 20 20 20 20 20  |,r1,#1..J.      |
000002d0  20 20 43 4d 50 20 20 20  20 20 72 31 2c 23 31 30  |  CMP     r1,#10|
000002e0  30 30 0d 01 54 1e 20 20  20 20 20 20 20 20 42 4c  |00..T.        BL|
000002f0  45 20 20 20 20 20 74 65  73 74 5f 6c 6f 6f 70 32  |E     test_loop2|
00000300  0d 01 5e 1c 20 20 20 20  20 20 20 20 41 44 44 20  |..^.        ADD |
00000310  20 20 20 20 72 30 2c 72  30 2c 23 31 0d 01 68 1c  |    r0,r0,#1..h.|
00000320  20 20 20 20 20 20 20 20  43 4d 50 20 20 20 20 20  |        CMP     |
00000330  72 30 2c 23 31 30 30 30  0d 01 69 1e 20 20 20 20  |r0,#1000..i.    |
00000340  20 20 20 20 42 4c 45 20  20 20 20 20 74 65 73 74  |    BLE     test|
00000350  5f 6c 6f 6f 70 31 0d 01  86 1e 20 20 20 20 20 20  |_loop1....      |
00000360  20 20 4c 44 4d 46 44 20  20 20 28 73 70 29 21 2c  |  LDMFD   (sp)!,|
00000370  7b 70 63 7d 0d 01 c2 04  0d 01 c3 2e 20 20 20 20  |{pc}........    |
00000380  20 20 20 20 3b 20 6f 6e  20 65 6e 74 72 79 20 72  |    ; on entry r|
00000390  30 3d 64 69 76 69 64 65  6e 64 2c 20 72 31 3d 64  |0=dividend, r1=d|
000003a0  69 76 69 73 6f 72 0d 01  cc 3e 20 20 20 20 20 20  |ivisor...>      |
000003b0  20 20 3b 20 6f 6e 20 65  78 69 74 2c 20 72 30 3d  |  ; on exit, r0=|
000003c0  71 75 6f 74 69 65 6e 74  2c 20 72 31 3d 72 65 6d  |quotient, r1=rem|
000003d0  61 69 6e 64 65 72 20 28  61 6c 73 6f 20 73 74 6f  |ainder (also sto|
000003e0  72 65 64 29 0d 01 d6 0b  2e 64 69 76 69 64 65 0d  |red).....divide.|
000003f0  01 e0 19 20 20 20 20 20  20 20 20 4d 4f 56 20 20  |...        MOV  |
00000400  20 20 20 72 33 2c 23 31  0d 01 ea 09 2e 64 69 76  |   r3,#1.....div|
00000410  31 0d 01 f4 20 20 20 20  20 20 20 20 20 43 4d 50  |1...         CMP|
00000420  20 20 20 20 20 72 30 2c  72 31 2c 41 53 4c 20 23  |     r0,r1,ASL #|
00000430  31 0d 01 fe 20 20 20 20  20 20 20 20 20 4d 4f 56  |1...         MOV|
00000440  47 45 20 20 20 72 31 2c  72 31 2c 41 53 4c 20 23  |GE   r1,r1,ASL #|
00000450  31 0d 02 08 20 20 20 20  20 20 20 20 20 4d 4f 56  |1...         MOV|
00000460  47 45 20 20 20 72 33 2c  72 33 2c 41 53 4c 20 23  |GE   r3,r3,ASL #|
00000470  31 0d 02 12 18 20 20 20  20 20 20 20 20 42 47 45  |1....        BGE|
00000480  20 20 20 20 20 64 69 76  31 0d 02 1c 19 20 20 20  |     div1....   |
00000490  20 20 20 20 20 4d 4f 56  20 20 20 20 20 72 32 2c  |     MOV     r2,|
000004a0  23 30 0d 02 26 19 2e 64  69 76 32 20 20 20 43 4d  |#0..&..div2   CM|
000004b0  50 20 20 20 20 20 72 30  2c 72 31 0d 02 30 1c 20  |P     r0,r1..0. |
000004c0  20 20 20 20 20 20 20 53  55 42 47 45 20 20 20 72  |       SUBGE   r|
000004d0  30 2c 72 30 2c 72 31 0d  02 3a 1c 20 20 20 20 20  |0,r0,r1..:.     |
000004e0  20 20 20 41 44 44 47 45  20 20 20 72 32 2c 72 32  |   ADDGE   r2,r2|
000004f0  2c 72 33 0d 02 44 20 20  20 20 20 20 20 20 20 4d  |,r3..D         M|
00000500  4f 56 20 20 20 20 20 72  31 2c 72 31 2c 41 53 52  |OV     r1,r1,ASR|
00000510  20 23 31 0d 02 4e 20 20  20 20 20 20 20 20 20 4d  | #1..N         M|
00000520  4f 56 53 20 20 20 20 72  33 2c 72 33 2c 41 53 52  |OVS    r3,r3,ASR|
00000530  20 23 31 0d 02 58 18 20  20 20 20 20 20 20 20 42  | #1..X.        B|
00000540  4e 45 20 20 20 20 20 64  69 76 32 0d 02 62 19 20  |NE     div2..b. |
00000550  20 20 20 20 20 20 20 4d  4f 56 20 20 20 20 20 72  |       MOV     r|
00000560  31 2c 72 30 0d 02 6c 19  20 20 20 20 20 20 20 20  |1,r0..l.        |
00000570  4d 4f 56 20 20 20 20 20  72 30 2c 72 32 0d 02 76  |MOV     r0,r2..v|
00000580  1f 20 20 20 20 20 20 20  20 53 54 52 20 20 20 20  |.        STR    |
00000590  20 72 30 2c 71 75 6f 74  69 65 6e 74 0d 02 80 20  | r0,quotient... |
000005a0  20 20 20 20 20 20 20 20  53 54 52 20 20 20 20 20  |        STR     |
000005b0  72 31 2c 72 65 6d 61 69  6e 64 65 72 0d 02 8a 1b  |r1,remainder....|
000005c0  20 20 20 20 20 20 20 20  4d 4f 56 20 20 20 20 20  |        MOV     |
000005d0  70 63 2c 6c 69 6e 6b 0d  02 94 0c 20 20 20 20 20  |pc,link....     |
000005e0  20 20 20 0d 02 9e 0d 2e  71 75 6f 74 69 65 6e 74  |   .....quotient|
000005f0  0d 02 a8 15 20 20 20 20  20 20 20 20 44 43 44 20  |....        DCD |
00000600  20 20 20 20 30 0d 02 b2  0e 2e 72 65 6d 61 69 6e  |    0.....remain|
00000610  64 65 72 0d 02 bc 15 20  20 20 20 20 20 20 20 44  |der....        D|
00000620  43 44 20 20 20 20 20 30  0d 02 c6 05 5d 0d 02 d0  |CD     0....]...|
00000630  0b ed 20 70 61 73 73 25  0d 02 da 05 e1 0d ff     |.. pass%.......|
0000063f