Home » CEEFAX disks » telesoftware5.adl » 07-02-88/B\OSB13

07-02-88/B\OSB13

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 » CEEFAX disks » telesoftware5.adl
Filename: 07-02-88/B\OSB13
Read OK:
File size: 07B0 bytes
Load address: 0800
Exec address: 8023
Duplicates

There is 1 duplicate copy of this file in the archive:

File contents
   10REM OSbits Module B/osb13
   20REM Multibyte multiplication
   30REM Version 3.1 8.3.87
   40 
   50*KEY1MO.3|M|NL.|M
   60 
   70DIM code% 120
   80 
   90FOR pass% = 0 TO 2 STEP 2
  100P% = code%
  110 
  120[OPT pass%
  130 
  140.multi_byte_mult
  150 
  160\  Assumes that numbers to be multiplied are put into
  170\  multiplicand and multiplier.  ppws is used for
  180\  partial produce. Result is put into multiplier
  190 
  200LDA #0
  210STA ppws              \ Clear partial product workspace
  220STA ppws+1
  230STA ppws+2
  240STA ppws+3
  250 
  260LDX #32               \ Carry out 32 times for 32 bit arithmetic
  270 
  280LSR multiplier+3      \ Rotate multiplier right
  290ROR multiplier+2
  300ROR multiplier+1
  310ROR multiplier
  320 
  330.mbm_loop
  340 
  350BCC no_add_mbm        \ Is next bit of multiplier set?
  360CLC
  370LDA multiplicand      \ Add multiplicand
  380ADC ppws
  390STA ppws
  400LDA multiplicand+1
  410ADC ppws+1
  420STA ppws+1
  430LDA multiplicand+2
  440ADC ppws+2
  450STA ppws+2
  460LDA multiplicand+3
  470ADC ppws+3
  480STA ppws+3
  490 
  500.no_add_mbm
  510 
  520LSR ppws+3            \ Rotate (shift) ppws & multiplier right
  530ROR ppws+2
  540ROR ppws+1
  550ROR ppws
  560ROR multiplier+3
  570ROR multiplier+2
  580ROR multiplier+1
  590ROR multiplier
  600DEX                   \ Counting down from 32 to zero
  610BNE mbm_loop
  620 
  630RTS
  640 
  650.multiplicand  OPT    FNEQUD(0)
  660.ppws          OPT    FNEQUD(0)
  670.multiplier    OPT    FNEQUD(0)
  680 
  690]
  700NEXT
  710@%=&A0A
  720REPEAT:INPUT "Enter numbers to be multiplied "A%,B%
  730!multiplicand = A%
  740!multiplier = B%
  750PRINT ;A%;" multiplied by ";B%;" = ";A%*B%;" [BASIC]"
  760CALL code%
  770PRINT ;A%;" multiplied by ";B%;" = ";!multiplier;" [code]"
  780PRINT "ppws contains &";~!ppws;" : multiplier contains &";~!multiplier
  790IF A%*B%>2147483647 OR A%*B%<-2147483648 THEN PRINT"Product is bigger than 4 bytes"
  800PRINT
  810UNTIL0
  890 
  900**** EQUate a Double word (4 bytes) ****
  910DEF FNEQUD(N%)
  920LOCAL X%
  930!P%=N%
  940FOR X%=0 TO 3
  950IF (pass% AND 3) = 3 THEN PRINT ~P%?X%;
  960NEXT
  970IF (pass% AND 3) = 3 THEN PRINT
  980P%=P%+4
  990=pass%

� OSbits Module B/osb13
� Multibyte multiplication
� Version 3.1 8.3.87
( 
2*KEY1MO.3|M|NL.|M
< 
F� code% 120
P 
Z� pass% = 0 � 2 � 2
dP% = code%
n 
x[OPT pass%
� 
�.multi_byte_mult
� 
�9\  Assumes that numbers to be multiplied are put into
�5\  multiplicand and multiplier.  ppws is used for
�5\  partial produce. Result is put into multiplier
� 
�
LDA #0
�;STA ppws              \ Clear partial product workspace
�STA ppws+1
�STA ppws+2
�STA ppws+3
� 
DLDX #32               \ Carry out 32 times for 32 bit arithmetic
 
3LSR multiplier+3      \ Rotate multiplier right
"ROR multiplier+2
,ROR multiplier+1
6ROR multiplier
@ 
J
.mbm_loop
T 
^:BCC no_add_mbm        \ Is next bit of multiplier set?
hCLC
r,LDA multiplicand      \ Add multiplicand
|ADC ppws
�STA ppws
�LDA multiplicand+1
�ADC ppws+1
�STA ppws+1
�LDA multiplicand+2
�ADC ppws+2
�STA ppws+2
�LDA multiplicand+3
�ADC ppws+3
�STA ppws+3
� 
�.no_add_mbm
� 
BLSR ppws+3            \ Rotate (shift) ppws & multiplier right
ROR ppws+2
ROR ppws+1
&ROR ppws
0ROR multiplier+3
:ROR multiplier+2
DROR multiplier+1
NROR multiplier
X9DEX                   \ Counting down from 32 to zero
bBNE mbm_loop
l 
vRTS
� 
�".multiplicand  OPT    �EQUD(0)
�".ppws          OPT    �EQUD(0)
�".multiplier    OPT    �EQUD(0)
� 
�]
��
�@%=&A0A
�.�:� "Enter numbers to be multiplied "A%,B%
�!multiplicand = A%
�!multiplier = B%
�5� ;A%;" multiplied by ";B%;" = ";A%*B%;" [BASIC]"
�� code%
:� ;A%;" multiplied by ";B%;" = ";!multiplier;" [code]"
F� "ppws contains &";~!ppws;" : multiplier contains &";~!multiplier
N� A%*B%>2147483647 � A%*B%<-2147483648 � �"Product is bigger than 4 bytes"
 �
*�0
z 
�,**** EQUate a Double word (4 bytes) ****
�� �EQUD(N%)
�� X%
�
!P%=N%
�� X%=0 � 3
�!� (pass% � 3) = 3 � � ~P%?X%;
��
�� (pass% � 3) = 3 � �
�P%=P%+4
�
=pass%
�
00000000  0d 00 0a 1b f4 20 4f 53  62 69 74 73 20 4d 6f 64  |..... OSbits Mod|
00000010  75 6c 65 20 42 2f 6f 73  62 31 33 0d 00 14 1e f4  |ule B/osb13.....|
00000020  20 4d 75 6c 74 69 62 79  74 65 20 6d 75 6c 74 69  | Multibyte multi|
00000030  70 6c 69 63 61 74 69 6f  6e 0d 00 1e 18 f4 20 56  |plication..... V|
00000040  65 72 73 69 6f 6e 20 33  2e 31 20 38 2e 33 2e 38  |ersion 3.1 8.3.8|
00000050  37 0d 00 28 05 20 0d 00  32 15 2a 4b 45 59 31 4d  |7..(. ..2.*KEY1M|
00000060  4f 2e 33 7c 4d 7c 4e 4c  2e 7c 4d 0d 00 3c 05 20  |O.3|M|NL.|M..<. |
00000070  0d 00 46 0f de 20 63 6f  64 65 25 20 31 32 30 0d  |..F.. code% 120.|
00000080  00 50 05 20 0d 00 5a 17  e3 20 70 61 73 73 25 20  |.P. ..Z.. pass% |
00000090  3d 20 30 20 b8 20 32 20  88 20 32 0d 00 64 0e 50  |= 0 . 2 . 2..d.P|
000000a0  25 20 3d 20 63 6f 64 65  25 0d 00 6e 05 20 0d 00  |% = code%..n. ..|
000000b0  78 0e 5b 4f 50 54 20 70  61 73 73 25 0d 00 82 05  |x.[OPT pass%....|
000000c0  20 0d 00 8c 14 2e 6d 75  6c 74 69 5f 62 79 74 65  | .....multi_byte|
000000d0  5f 6d 75 6c 74 0d 00 96  05 20 0d 00 a0 39 5c 20  |_mult.... ...9\ |
000000e0  20 41 73 73 75 6d 65 73  20 74 68 61 74 20 6e 75  | Assumes that nu|
000000f0  6d 62 65 72 73 20 74 6f  20 62 65 20 6d 75 6c 74  |mbers to be mult|
00000100  69 70 6c 69 65 64 20 61  72 65 20 70 75 74 20 69  |iplied are put i|
00000110  6e 74 6f 0d 00 aa 35 5c  20 20 6d 75 6c 74 69 70  |nto...5\  multip|
00000120  6c 69 63 61 6e 64 20 61  6e 64 20 6d 75 6c 74 69  |licand and multi|
00000130  70 6c 69 65 72 2e 20 20  70 70 77 73 20 69 73 20  |plier.  ppws is |
00000140  75 73 65 64 20 66 6f 72  0d 00 b4 35 5c 20 20 70  |used for...5\  p|
00000150  61 72 74 69 61 6c 20 70  72 6f 64 75 63 65 2e 20  |artial produce. |
00000160  52 65 73 75 6c 74 20 69  73 20 70 75 74 20 69 6e  |Result is put in|
00000170  74 6f 20 6d 75 6c 74 69  70 6c 69 65 72 0d 00 be  |to multiplier...|
00000180  05 20 0d 00 c8 0a 4c 44  41 20 23 30 0d 00 d2 3b  |. ....LDA #0...;|
00000190  53 54 41 20 70 70 77 73  20 20 20 20 20 20 20 20  |STA ppws        |
000001a0  20 20 20 20 20 20 5c 20  43 6c 65 61 72 20 70 61  |      \ Clear pa|
000001b0  72 74 69 61 6c 20 70 72  6f 64 75 63 74 20 77 6f  |rtial product wo|
000001c0  72 6b 73 70 61 63 65 0d  00 dc 0e 53 54 41 20 70  |rkspace....STA p|
000001d0  70 77 73 2b 31 0d 00 e6  0e 53 54 41 20 70 70 77  |pws+1....STA ppw|
000001e0  73 2b 32 0d 00 f0 0e 53  54 41 20 70 70 77 73 2b  |s+2....STA ppws+|
000001f0  33 0d 00 fa 05 20 0d 01  04 44 4c 44 58 20 23 33  |3.... ...DLDX #3|
00000200  32 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |2               |
00000210  5c 20 43 61 72 72 79 20  6f 75 74 20 33 32 20 74  |\ Carry out 32 t|
00000220  69 6d 65 73 20 66 6f 72  20 33 32 20 62 69 74 20  |imes for 32 bit |
00000230  61 72 69 74 68 6d 65 74  69 63 0d 01 0e 05 20 0d  |arithmetic.... .|
00000240  01 18 33 4c 53 52 20 6d  75 6c 74 69 70 6c 69 65  |..3LSR multiplie|
00000250  72 2b 33 20 20 20 20 20  20 5c 20 52 6f 74 61 74  |r+3      \ Rotat|
00000260  65 20 6d 75 6c 74 69 70  6c 69 65 72 20 72 69 67  |e multiplier rig|
00000270  68 74 0d 01 22 14 52 4f  52 20 6d 75 6c 74 69 70  |ht..".ROR multip|
00000280  6c 69 65 72 2b 32 0d 01  2c 14 52 4f 52 20 6d 75  |lier+2..,.ROR mu|
00000290  6c 74 69 70 6c 69 65 72  2b 31 0d 01 36 12 52 4f  |ltiplier+1..6.RO|
000002a0  52 20 6d 75 6c 74 69 70  6c 69 65 72 0d 01 40 05  |R multiplier..@.|
000002b0  20 0d 01 4a 0d 2e 6d 62  6d 5f 6c 6f 6f 70 0d 01  | ..J..mbm_loop..|
000002c0  54 05 20 0d 01 5e 3a 42  43 43 20 6e 6f 5f 61 64  |T. ..^:BCC no_ad|
000002d0  64 5f 6d 62 6d 20 20 20  20 20 20 20 20 5c 20 49  |d_mbm        \ I|
000002e0  73 20 6e 65 78 74 20 62  69 74 20 6f 66 20 6d 75  |s next bit of mu|
000002f0  6c 74 69 70 6c 69 65 72  20 73 65 74 3f 0d 01 68  |ltiplier set?..h|
00000300  07 43 4c 43 0d 01 72 2c  4c 44 41 20 6d 75 6c 74  |.CLC..r,LDA mult|
00000310  69 70 6c 69 63 61 6e 64  20 20 20 20 20 20 5c 20  |iplicand      \ |
00000320  41 64 64 20 6d 75 6c 74  69 70 6c 69 63 61 6e 64  |Add multiplicand|
00000330  0d 01 7c 0c 41 44 43 20  70 70 77 73 0d 01 86 0c  |..|.ADC ppws....|
00000340  53 54 41 20 70 70 77 73  0d 01 90 16 4c 44 41 20  |STA ppws....LDA |
00000350  6d 75 6c 74 69 70 6c 69  63 61 6e 64 2b 31 0d 01  |multiplicand+1..|
00000360  9a 0e 41 44 43 20 70 70  77 73 2b 31 0d 01 a4 0e  |..ADC ppws+1....|
00000370  53 54 41 20 70 70 77 73  2b 31 0d 01 ae 16 4c 44  |STA ppws+1....LD|
00000380  41 20 6d 75 6c 74 69 70  6c 69 63 61 6e 64 2b 32  |A multiplicand+2|
00000390  0d 01 b8 0e 41 44 43 20  70 70 77 73 2b 32 0d 01  |....ADC ppws+2..|
000003a0  c2 0e 53 54 41 20 70 70  77 73 2b 32 0d 01 cc 16  |..STA ppws+2....|
000003b0  4c 44 41 20 6d 75 6c 74  69 70 6c 69 63 61 6e 64  |LDA multiplicand|
000003c0  2b 33 0d 01 d6 0e 41 44  43 20 70 70 77 73 2b 33  |+3....ADC ppws+3|
000003d0  0d 01 e0 0e 53 54 41 20  70 70 77 73 2b 33 0d 01  |....STA ppws+3..|
000003e0  ea 05 20 0d 01 f4 0f 2e  6e 6f 5f 61 64 64 5f 6d  |.. .....no_add_m|
000003f0  62 6d 0d 01 fe 05 20 0d  02 08 42 4c 53 52 20 70  |bm.... ...BLSR p|
00000400  70 77 73 2b 33 20 20 20  20 20 20 20 20 20 20 20  |pws+3           |
00000410  20 5c 20 52 6f 74 61 74  65 20 28 73 68 69 66 74  | \ Rotate (shift|
00000420  29 20 70 70 77 73 20 26  20 6d 75 6c 74 69 70 6c  |) ppws & multipl|
00000430  69 65 72 20 72 69 67 68  74 0d 02 12 0e 52 4f 52  |ier right....ROR|
00000440  20 70 70 77 73 2b 32 0d  02 1c 0e 52 4f 52 20 70  | ppws+2....ROR p|
00000450  70 77 73 2b 31 0d 02 26  0c 52 4f 52 20 70 70 77  |pws+1..&.ROR ppw|
00000460  73 0d 02 30 14 52 4f 52  20 6d 75 6c 74 69 70 6c  |s..0.ROR multipl|
00000470  69 65 72 2b 33 0d 02 3a  14 52 4f 52 20 6d 75 6c  |ier+3..:.ROR mul|
00000480  74 69 70 6c 69 65 72 2b  32 0d 02 44 14 52 4f 52  |tiplier+2..D.ROR|
00000490  20 6d 75 6c 74 69 70 6c  69 65 72 2b 31 0d 02 4e  | multiplier+1..N|
000004a0  12 52 4f 52 20 6d 75 6c  74 69 70 6c 69 65 72 0d  |.ROR multiplier.|
000004b0  02 58 39 44 45 58 20 20  20 20 20 20 20 20 20 20  |.X9DEX          |
000004c0  20 20 20 20 20 20 20 20  20 5c 20 43 6f 75 6e 74  |         \ Count|
000004d0  69 6e 67 20 64 6f 77 6e  20 66 72 6f 6d 20 33 32  |ing down from 32|
000004e0  20 74 6f 20 7a 65 72 6f  0d 02 62 10 42 4e 45 20  | to zero..b.BNE |
000004f0  6d 62 6d 5f 6c 6f 6f 70  0d 02 6c 05 20 0d 02 76  |mbm_loop..l. ..v|
00000500  07 52 54 53 0d 02 80 05  20 0d 02 8a 22 2e 6d 75  |.RTS.... ...".mu|
00000510  6c 74 69 70 6c 69 63 61  6e 64 20 20 4f 50 54 20  |ltiplicand  OPT |
00000520  20 20 20 a4 45 51 55 44  28 30 29 0d 02 94 22 2e  |   .EQUD(0)...".|
00000530  70 70 77 73 20 20 20 20  20 20 20 20 20 20 4f 50  |ppws          OP|
00000540  54 20 20 20 20 a4 45 51  55 44 28 30 29 0d 02 9e  |T    .EQUD(0)...|
00000550  22 2e 6d 75 6c 74 69 70  6c 69 65 72 20 20 20 20  |".multiplier    |
00000560  4f 50 54 20 20 20 20 a4  45 51 55 44 28 30 29 0d  |OPT    .EQUD(0).|
00000570  02 a8 05 20 0d 02 b2 05  5d 0d 02 bc 05 ed 0d 02  |... ....].......|
00000580  c6 0b 40 25 3d 26 41 30  41 0d 02 d0 2e f5 3a e8  |..@%=&A0A.....:.|
00000590  20 22 45 6e 74 65 72 20  6e 75 6d 62 65 72 73 20  | "Enter numbers |
000005a0  74 6f 20 62 65 20 6d 75  6c 74 69 70 6c 69 65 64  |to be multiplied|
000005b0  20 22 41 25 2c 42 25 0d  02 da 16 21 6d 75 6c 74  | "A%,B%....!mult|
000005c0  69 70 6c 69 63 61 6e 64  20 3d 20 41 25 0d 02 e4  |iplicand = A%...|
000005d0  14 21 6d 75 6c 74 69 70  6c 69 65 72 20 3d 20 42  |.!multiplier = B|
000005e0  25 0d 02 ee 35 f1 20 3b  41 25 3b 22 20 6d 75 6c  |%...5. ;A%;" mul|
000005f0  74 69 70 6c 69 65 64 20  62 79 20 22 3b 42 25 3b  |tiplied by ";B%;|
00000600  22 20 3d 20 22 3b 41 25  2a 42 25 3b 22 20 5b 42  |" = ";A%*B%;" [B|
00000610  41 53 49 43 5d 22 0d 02  f8 0b d6 20 63 6f 64 65  |ASIC]"..... code|
00000620  25 0d 03 02 3a f1 20 3b  41 25 3b 22 20 6d 75 6c  |%...:. ;A%;" mul|
00000630  74 69 70 6c 69 65 64 20  62 79 20 22 3b 42 25 3b  |tiplied by ";B%;|
00000640  22 20 3d 20 22 3b 21 6d  75 6c 74 69 70 6c 69 65  |" = ";!multiplie|
00000650  72 3b 22 20 5b 63 6f 64  65 5d 22 0d 03 0c 46 f1  |r;" [code]"...F.|
00000660  20 22 70 70 77 73 20 63  6f 6e 74 61 69 6e 73 20  | "ppws contains |
00000670  26 22 3b 7e 21 70 70 77  73 3b 22 20 3a 20 6d 75  |&";~!ppws;" : mu|
00000680  6c 74 69 70 6c 69 65 72  20 63 6f 6e 74 61 69 6e  |ltiplier contain|
00000690  73 20 26 22 3b 7e 21 6d  75 6c 74 69 70 6c 69 65  |s &";~!multiplie|
000006a0  72 0d 03 16 4e e7 20 41  25 2a 42 25 3e 32 31 34  |r...N. A%*B%>214|
000006b0  37 34 38 33 36 34 37 20  84 20 41 25 2a 42 25 3c  |7483647 . A%*B%<|
000006c0  2d 32 31 34 37 34 38 33  36 34 38 20 8c 20 f1 22  |-2147483648 . ."|
000006d0  50 72 6f 64 75 63 74 20  69 73 20 62 69 67 67 65  |Product is bigge|
000006e0  72 20 74 68 61 6e 20 34  20 62 79 74 65 73 22 0d  |r than 4 bytes".|
000006f0  03 20 05 f1 0d 03 2a 06  fd 30 0d 03 7a 05 20 0d  |. ....*..0..z. .|
00000700  03 84 2c 2a 2a 2a 2a 20  45 51 55 61 74 65 20 61  |..,**** EQUate a|
00000710  20 44 6f 75 62 6c 65 20  77 6f 72 64 20 28 34 20  | Double word (4 |
00000720  62 79 74 65 73 29 20 2a  2a 2a 2a 0d 03 8e 0f dd  |bytes) ****.....|
00000730  20 a4 45 51 55 44 28 4e  25 29 0d 03 98 08 ea 20  | .EQUD(N%)..... |
00000740  58 25 0d 03 a2 0a 21 50  25 3d 4e 25 0d 03 ac 0e  |X%....!P%=N%....|
00000750  e3 20 58 25 3d 30 20 b8  20 33 0d 03 b6 21 e7 20  |. X%=0 . 3...!. |
00000760  28 70 61 73 73 25 20 80  20 33 29 20 3d 20 33 20  |(pass% . 3) = 3 |
00000770  8c 20 f1 20 7e 50 25 3f  58 25 3b 0d 03 c0 05 ed  |. . ~P%?X%;.....|
00000780  0d 03 ca 19 e7 20 28 70  61 73 73 25 20 80 20 33  |..... (pass% . 3|
00000790  29 20 3d 20 33 20 8c 20  f1 0d 03 d4 0b 50 25 3d  |) = 3 . .....P%=|
000007a0  50 25 2b 34 0d 03 de 0a  3d 70 61 73 73 25 0d ff  |P%+4....=pass%..|
000007b0
07-02-88/B\OSB13.m0
07-02-88/B\OSB13.m1
07-02-88/B\OSB13.m2
07-02-88/B\OSB13.m4
07-02-88/B\OSB13.m5