Home » Personal collection » Acorn DFS disks » dfs_box03_disk12_bcpl.scp » OPT

OPT

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 » Personal collection » Acorn DFS disks » dfs_box03_disk12_bcpl.scp
Filename: OPT
Read OK:
File size: 0386 bytes
Load address: 0000
Exec address: 0000
File contents
/* Section commented out in case it is not needed

SECTION "OPTION"

// contains GETBYTE,PACKSTRING,PUTBYTE,UNPACKSTRING
// these standard procedures are unnecessary for new code.
// The remainder are easily provided by the % operator.
// Modified 8/7/82 by E.Allen for BBC Micro


GET "LIBHDR"
GET "SYSHDR"
// if OPTION is a separate segment it is necessary to allocate
// Globals for the procedures required,  and declare or
// reference them here.

*/

// if "OPTION" is included as local procedures within a section 
// the next LET may need to be changed to AND.


LET GETBYTE(S, I) = S%I


AND PACKSTRING(V, S) = VALOF
    $( LET N = V!0 & 255
       LET I = N/2
       FOR P = 0 TO N DO S%P:=V!P
       IF (N&1)=0 DO S%(N+1) := 0
       RESULTIS I  $)


AND PUTBYTE(S, I, B) BE S%I := B


AND UNPACKSTRING(S, V) BE
         FOR I = 0 TO S%0 DO V!I := S%I

00000000  2f 2a 20 53 65 63 74 69  6f 6e 20 63 6f 6d 6d 65  |/* Section comme|
00000010  6e 74 65 64 20 6f 75 74  20 69 6e 20 63 61 73 65  |nted out in case|
00000020  20 69 74 20 69 73 20 6e  6f 74 20 6e 65 65 64 65  | it is not neede|
00000030  64 0d 0a 0d 0a 53 45 43  54 49 4f 4e 20 22 4f 50  |d....SECTION "OP|
00000040  54 49 4f 4e 22 0d 0a 0d  0a 2f 2f 20 63 6f 6e 74  |TION"....// cont|
00000050  61 69 6e 73 20 47 45 54  42 59 54 45 2c 50 41 43  |ains GETBYTE,PAC|
00000060  4b 53 54 52 49 4e 47 2c  50 55 54 42 59 54 45 2c  |KSTRING,PUTBYTE,|
00000070  55 4e 50 41 43 4b 53 54  52 49 4e 47 0d 0a 2f 2f  |UNPACKSTRING..//|
00000080  20 74 68 65 73 65 20 73  74 61 6e 64 61 72 64 20  | these standard |
00000090  70 72 6f 63 65 64 75 72  65 73 20 61 72 65 20 75  |procedures are u|
000000a0  6e 6e 65 63 65 73 73 61  72 79 20 66 6f 72 20 6e  |nnecessary for n|
000000b0  65 77 20 63 6f 64 65 2e  0d 0a 2f 2f 20 54 68 65  |ew code...// The|
000000c0  20 72 65 6d 61 69 6e 64  65 72 20 61 72 65 20 65  | remainder are e|
000000d0  61 73 69 6c 79 20 70 72  6f 76 69 64 65 64 20 62  |asily provided b|
000000e0  79 20 74 68 65 20 25 20  6f 70 65 72 61 74 6f 72  |y the % operator|
000000f0  2e 0d 0a 2f 2f 20 4d 6f  64 69 66 69 65 64 20 38  |...// Modified 8|
00000100  2f 37 2f 38 32 20 62 79  20 45 2e 41 6c 6c 65 6e  |/7/82 by E.Allen|
00000110  20 66 6f 72 20 42 42 43  20 4d 69 63 72 6f 0d 0a  | for BBC Micro..|
00000120  0d 0a 0d 0a 47 45 54 20  22 4c 49 42 48 44 52 22  |....GET "LIBHDR"|
00000130  0d 0a 47 45 54 20 22 53  59 53 48 44 52 22 0d 0a  |..GET "SYSHDR"..|
00000140  2f 2f 20 69 66 20 4f 50  54 49 4f 4e 20 69 73 20  |// if OPTION is |
00000150  61 20 73 65 70 61 72 61  74 65 20 73 65 67 6d 65  |a separate segme|
00000160  6e 74 20 69 74 20 69 73  20 6e 65 63 65 73 73 61  |nt it is necessa|
00000170  72 79 20 74 6f 20 61 6c  6c 6f 63 61 74 65 0d 0a  |ry to allocate..|
00000180  2f 2f 20 47 6c 6f 62 61  6c 73 20 66 6f 72 20 74  |// Globals for t|
00000190  68 65 20 70 72 6f 63 65  64 75 72 65 73 20 72 65  |he procedures re|
000001a0  71 75 69 72 65 64 2c 20  20 61 6e 64 20 64 65 63  |quired,  and dec|
000001b0  6c 61 72 65 20 6f 72 0d  0a 2f 2f 20 72 65 66 65  |lare or..// refe|
000001c0  72 65 6e 63 65 20 74 68  65 6d 20 68 65 72 65 2e  |rence them here.|
000001d0  0d 0a 0d 0a 2a 2f 0d 0a  0d 0a 2f 2f 20 69 66 20  |....*/....// if |
000001e0  22 4f 50 54 49 4f 4e 22  20 69 73 20 69 6e 63 6c  |"OPTION" is incl|
000001f0  75 64 65 64 20 61 73 20  6c 6f 63 61 6c 20 70 72  |uded as local pr|
00000200  6f 63 65 64 75 72 65 73  20 77 69 74 68 69 6e 20  |ocedures within |
00000210  61 20 73 65 63 74 69 6f  6e 20 0d 0a 2f 2f 20 74  |a section ..// t|
00000220  68 65 20 6e 65 78 74 20  4c 45 54 20 6d 61 79 20  |he next LET may |
00000230  6e 65 65 64 20 74 6f 20  62 65 20 63 68 61 6e 67  |need to be chang|
00000240  65 64 20 74 6f 20 41 4e  44 2e 0d 0a 0d 0a 0d 0a  |ed to AND.......|
00000250  4c 45 54 20 47 45 54 42  59 54 45 28 53 2c 20 49  |LET GETBYTE(S, I|
00000260  29 20 3d 20 53 25 49 0d  0a 0d 0a 0d 0a 41 4e 44  |) = S%I......AND|
00000270  20 50 41 43 4b 53 54 52  49 4e 47 28 56 2c 20 53  | PACKSTRING(V, S|
00000280  29 20 3d 20 56 41 4c 4f  46 0d 0a 20 20 20 20 24  |) = VALOF..    $|
00000290  28 20 4c 45 54 20 4e 20  3d 20 56 21 30 20 26 20  |( LET N = V!0 & |
000002a0  32 35 35 0d 0a 20 20 20  20 20 20 20 4c 45 54 20  |255..       LET |
000002b0  49 20 3d 20 4e 2f 32 0d  0a 20 20 20 20 20 20 20  |I = N/2..       |
000002c0  46 4f 52 20 50 20 3d 20  30 20 54 4f 20 4e 20 44  |FOR P = 0 TO N D|
000002d0  4f 20 53 25 50 3a 3d 56  21 50 0d 0a 20 20 20 20  |O S%P:=V!P..    |
000002e0  20 20 20 49 46 20 28 4e  26 31 29 3d 30 20 44 4f  |   IF (N&1)=0 DO|
000002f0  20 53 25 28 4e 2b 31 29  20 3a 3d 20 30 0d 0a 20  | S%(N+1) := 0.. |
00000300  20 20 20 20 20 20 52 45  53 55 4c 54 49 53 20 49  |      RESULTIS I|
00000310  20 20 24 29 0d 0a 0d 0a  0d 0a 41 4e 44 20 50 55  |  $)......AND PU|
00000320  54 42 59 54 45 28 53 2c  20 49 2c 20 42 29 20 42  |TBYTE(S, I, B) B|
00000330  45 20 53 25 49 20 3a 3d  20 42 0d 0a 0d 0a 0d 0a  |E S%I := B......|
00000340  41 4e 44 20 55 4e 50 41  43 4b 53 54 52 49 4e 47  |AND UNPACKSTRING|
00000350  28 53 2c 20 56 29 20 42  45 0d 0a 20 20 20 20 20  |(S, V) BE..     |
00000360  20 20 20 20 46 4f 52 20  49 20 3d 20 30 20 54 4f  |    FOR I = 0 TO|
00000370  20 53 25 30 20 44 4f 20  56 21 49 20 3a 3d 20 53  | S%0 DO V!I := S|
00000380  25 49 0d 0a 0d 0a                                 |%I....|
00000386
OPT.m0
OPT.m1
OPT.m2
OPT.m4
OPT.m5