996
|
1
|
|
2 lib2.i contains general-purpose library routines that are not included
|
|
3 in the standard library.
|
|
4
|
|
5 The first section, with entry at lines (2000), (2010) and (2020),
|
|
6 was written for the Life program. Line (2000) is the entry point
|
|
7 for a decrement routine setting .1 <- .1 minus #1. This is very
|
|
8 similar to the increment routine (1020) in the system library,
|
|
9 which I also use. Line (2010) is the decrement and branch on zero
|
|
10 operation. It decrements .1, then if .1 is not zero returns to the
|
|
11 calling point, but if .1 is zero pops an additional entry off the
|
|
12 RESUME stack and returns to that point instead. Line (2020) is an
|
|
13 alternative entry point to the (1020) routine which performs an add
|
|
14 bit operation. It sets .1 <- .1 plus .2, where .2 is already known
|
|
15 to be either #0 or #1.
|
|
16
|
|
17 For the pi and primes programs I added the (2030) routine, which
|
|
18 performs a 16-bit division with remainder. It is faster than the
|
|
19 (1040) routine for two reasons: First, it is a true 16-bit version,
|
|
20 whereas the (1040) routine just shifts over its operands and then
|
|
21 calls the 32-bit division routine (1550). Second, the (1550) routine
|
|
22 generates a remainder as part of the computation, but then simply
|
|
23 throws it away. I needed the remainder, so I have my (2030) routine
|
|
24 return it in .4 and the quotient in .3. In other respects this is
|
|
25 just a 16-bit translation of the (1550) routine.
|
|
26
|
|
27 (2040) and (2049) are entry points to an exponentiation routine that
|
|
28 raises .1 to the .2 power and returns the answer in :1. If entered
|
|
29 through (2040) the routine dies with an error on overflow. If entered
|
|
30 through (2049) then .4 is set to #2 if there is an overflow, otherwise
|
|
31 .4 is set to #1. There is a more detailed description of how this
|
|
32 routine works on the web page.
|
|
33
|
|
34 Louis Howell
|
|
35 May 27, 1996
|