Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199611.adf » Regulars » StarInfo/Turnbull/!BasicLib/Linker

StarInfo/Turnbull/!BasicLib/Linker

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_199611.adf » Regulars
Filename: StarInfo/Turnbull/!BasicLib/Linker
Read OK:
File size: 04A5 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM Linker utilities
   20ERROR255,"This is a library, not a program"
   30:
   40DEFPROClinkinit
   50DIM_L$(500),_L%(500)
   60_lused%=0
   70ENDPROC
   80:
   90DEFFN_find(L$)
  100LOCALH%,T%
  110H%=-1:FORT%=0TO_lused%-1
  120IF_L$(T%)=L$THENH%=T%:T%=_lused%
  130NEXT:=H%
  140:
  150DEFPROC_put(L$,P%)
  160LOCALH%:H%=FN_find(L$)
  170IFH%=-1THEN_L$(_lused%)=L$:_L%(_lused%)=P%:_lused%+=1:ENDPROC
  180IF_L%(H%)=P%THENENDPROC
  190ERROR255,"Duplicate label '"+L$+"'"
  200:
  210DEFFNlabel(L$)
  220PROC_put(L$,P%)
  230=T%
  240:
  250DEFFNaddr(L$)
  260LOCALH%:H%=FN_find(L$)
  270IFH%=-1THENERROR255,"Unknown label '"+L$+"' at "+STR$~P%
  280=_L%(H%)
  290:
  300DEFPROCimport(F$)
  310LOCALstart%,Q%
  320OSCLI("Load Link:"+F$+" "+STR$~P%)
  330start%=P%:P%+=!P%:Q%=P%
  340WHILE!Q%<>&80000000
  350PROC_put($(Q%+8),start%+Q%!4)
  360Q%+=!Q%:ENDWHILE
  370ENDPROC
  380:
  390DEFPROCexport(F$,start%,E$)
  400LOCALend%,L%,L$,temp%
  410!start%=P%-start%
  420end%=P%:E$+=",":WHILEE$<>""
  430L%=INSTR(E$,","):L$=LEFT$(E$,L%-1):E$=MID$(E$,L%+1)
  450H%=FN_find(L$)
  440IFH%=-1THENERROR255,"Unknown label '"+L$+"' for export"
  441IF_L%(H%)<start%OR_L%(H%)>=end%THENERROR255,"Label '"+L$+"' is not in range for export"
  460[OPT 2
  470.temp%
  480EQUD -1
  490EQUD _L%(H%)-start%
  500EQUS L$+CHR$13
  510ALIGN
  520]:!temp%=P%-temp%
  530ENDWHILE
  540!P%=&80000000:P%+=4
  550OSCLI("Save Link:"+F$+" "+STR$~start%+" "+STR$~P%)
  560OSCLI("SetType Link:"+F$+" DATA")
  570P%=end%
  580ENDPROC

� Linker utilities
+�255,"This is a library, not a program"
:
(��linkinit
2�_L$(500),_L%(500)
<
_lused%=0
F�
P:
Zݤ_find(L$)
d
�H%,T%
nH%=-1:�T%=0�_lused%-1
x �_L$(T%)=L$�H%=T%:T%=_lused%
�	�:=H%
�:
���_put(L$,P%)
��H%:H%=�_find(L$)
�7�H%=-1�_L$(_lused%)=L$:_L%(_lused%)=P%:_lused%+=1:�
��_L%(H%)=P%��
�#�255,"Duplicate label '"+L$+"'"
�:
�ݤlabel(L$)
��_put(L$,P%)
�=T%
�:
�ݤaddr(L$)
�H%:H%=�_find(L$)
1�H%=-1��255,"Unknown label '"+L$+"' at "+�~P%
=_L%(H%)
":
,��import(F$)
6�start%,Q%
@�("Load Link:"+F$+" "+�~P%)
Jstart%=P%:P%+=!P%:Q%=P%
Tȕ!Q%<>&80000000
^�_put($(Q%+8),start%+Q%!4)
h
Q%+=!Q%:�
r�
|:
���export(F$,start%,E$)
��end%,L%,L$,temp%
�!start%=P%-start%
�end%=P%:E$+=",":ȕE$<>""
�)L%=�E$,","):L$=�E$,L%-1):E$=�E$,L%+1)
�H%=�_find(L$)
�3�H%=-1��255,"Unknown label '"+L$+"' for export"
�R�_L%(H%)<start%�_L%(H%)>=end%��255,"Label '"+L$+"' is not in range for export"
�
[OPT 2
�
.temp%
�EQUD -1
�EQUD _L%(H%)-start%
�EQUS L$+�13
�	ALIGN
]:!temp%=P%-temp%
�
!P%=&80000000:P%+=4
&,�("Save Link:"+F$+" "+�~start%+" "+�~P%)
0!�("SetType Link:"+F$+" DATA")
:P%=end%
D�
�
00000000  0d 00 0a 16 f4 20 4c 69  6e 6b 65 72 20 75 74 69  |..... Linker uti|
00000010  6c 69 74 69 65 73 0d 00  14 2b 85 32 35 35 2c 22  |lities...+.255,"|
00000020  54 68 69 73 20 69 73 20  61 20 6c 69 62 72 61 72  |This is a librar|
00000030  79 2c 20 6e 6f 74 20 61  20 70 72 6f 67 72 61 6d  |y, not a program|
00000040  22 0d 00 1e 05 3a 0d 00  28 0e dd f2 6c 69 6e 6b  |"....:..(...link|
00000050  69 6e 69 74 0d 00 32 16  de 5f 4c 24 28 35 30 30  |init..2.._L$(500|
00000060  29 2c 5f 4c 25 28 35 30  30 29 0d 00 3c 0d 5f 6c  |),_L%(500)..<._l|
00000070  75 73 65 64 25 3d 30 0d  00 46 05 e1 0d 00 50 05  |used%=0..F....P.|
00000080  3a 0d 00 5a 0f dd a4 5f  66 69 6e 64 28 4c 24 29  |:..Z..._find(L$)|
00000090  0d 00 64 0a ea 48 25 2c  54 25 0d 00 6e 19 48 25  |..d..H%,T%..n.H%|
000000a0  3d 2d 31 3a e3 54 25 3d  30 b8 5f 6c 75 73 65 64  |=-1:.T%=0._lused|
000000b0  25 2d 31 0d 00 78 20 e7  5f 4c 24 28 54 25 29 3d  |%-1..x ._L$(T%)=|
000000c0  4c 24 8c 48 25 3d 54 25  3a 54 25 3d 5f 6c 75 73  |L$.H%=T%:T%=_lus|
000000d0  65 64 25 0d 00 82 09 ed  3a 3d 48 25 0d 00 8c 05  |ed%.....:=H%....|
000000e0  3a 0d 00 96 11 dd f2 5f  70 75 74 28 4c 24 2c 50  |:......_put(L$,P|
000000f0  25 29 0d 00 a0 15 ea 48  25 3a 48 25 3d a4 5f 66  |%).....H%:H%=._f|
00000100  69 6e 64 28 4c 24 29 0d  00 aa 37 e7 48 25 3d 2d  |ind(L$)...7.H%=-|
00000110  31 8c 5f 4c 24 28 5f 6c  75 73 65 64 25 29 3d 4c  |1._L$(_lused%)=L|
00000120  24 3a 5f 4c 25 28 5f 6c  75 73 65 64 25 29 3d 50  |$:_L%(_lused%)=P|
00000130  25 3a 5f 6c 75 73 65 64  25 2b 3d 31 3a e1 0d 00  |%:_lused%+=1:...|
00000140  b4 11 e7 5f 4c 25 28 48  25 29 3d 50 25 8c e1 0d  |..._L%(H%)=P%...|
00000150  00 be 23 85 32 35 35 2c  22 44 75 70 6c 69 63 61  |..#.255,"Duplica|
00000160  74 65 20 6c 61 62 65 6c  20 27 22 2b 4c 24 2b 22  |te label '"+L$+"|
00000170  27 22 0d 00 c8 05 3a 0d  00 d2 0f dd a4 6c 61 62  |'"....:......lab|
00000180  65 6c 28 4c 24 29 0d 00  dc 10 f2 5f 70 75 74 28  |el(L$)....._put(|
00000190  4c 24 2c 50 25 29 0d 00  e6 07 3d 54 25 0d 00 f0  |L$,P%)....=T%...|
000001a0  05 3a 0d 00 fa 0e dd a4  61 64 64 72 28 4c 24 29  |.:......addr(L$)|
000001b0  0d 01 04 15 ea 48 25 3a  48 25 3d a4 5f 66 69 6e  |.....H%:H%=._fin|
000001c0  64 28 4c 24 29 0d 01 0e  31 e7 48 25 3d 2d 31 8c  |d(L$)...1.H%=-1.|
000001d0  85 32 35 35 2c 22 55 6e  6b 6e 6f 77 6e 20 6c 61  |.255,"Unknown la|
000001e0  62 65 6c 20 27 22 2b 4c  24 2b 22 27 20 61 74 20  |bel '"+L$+"' at |
000001f0  22 2b c3 7e 50 25 0d 01  18 0c 3d 5f 4c 25 28 48  |"+.~P%....=_L%(H|
00000200  25 29 0d 01 22 05 3a 0d  01 2c 10 dd f2 69 6d 70  |%)..".:..,...imp|
00000210  6f 72 74 28 46 24 29 0d  01 36 0e ea 73 74 61 72  |ort(F$)..6..star|
00000220  74 25 2c 51 25 0d 01 40  1f ff 28 22 4c 6f 61 64  |t%,Q%..@..("Load|
00000230  20 4c 69 6e 6b 3a 22 2b  46 24 2b 22 20 22 2b c3  | Link:"+F$+" "+.|
00000240  7e 50 25 29 0d 01 4a 1b  73 74 61 72 74 25 3d 50  |~P%)..J.start%=P|
00000250  25 3a 50 25 2b 3d 21 50  25 3a 51 25 3d 50 25 0d  |%:P%+=!P%:Q%=P%.|
00000260  01 54 14 c8 95 21 51 25  3c 3e 26 38 30 30 30 30  |.T...!Q%<>&80000|
00000270  30 30 30 0d 01 5e 1e f2  5f 70 75 74 28 24 28 51  |000..^.._put($(Q|
00000280  25 2b 38 29 2c 73 74 61  72 74 25 2b 51 25 21 34  |%+8),start%+Q%!4|
00000290  29 0d 01 68 0d 51 25 2b  3d 21 51 25 3a ce 0d 01  |)..h.Q%+=!Q%:...|
000002a0  72 05 e1 0d 01 7c 05 3a  0d 01 86 1a dd f2 65 78  |r....|.:......ex|
000002b0  70 6f 72 74 28 46 24 2c  73 74 61 72 74 25 2c 45  |port(F$,start%,E|
000002c0  24 29 0d 01 90 15 ea 65  6e 64 25 2c 4c 25 2c 4c  |$).....end%,L%,L|
000002d0  24 2c 74 65 6d 70 25 0d  01 9a 15 21 73 74 61 72  |$,temp%....!star|
000002e0  74 25 3d 50 25 2d 73 74  61 72 74 25 0d 01 a4 1c  |t%=P%-start%....|
000002f0  65 6e 64 25 3d 50 25 3a  45 24 2b 3d 22 2c 22 3a  |end%=P%:E$+=",":|
00000300  c8 95 45 24 3c 3e 22 22  0d 01 ae 29 4c 25 3d a7  |..E$<>""...)L%=.|
00000310  45 24 2c 22 2c 22 29 3a  4c 24 3d c0 45 24 2c 4c  |E$,","):L$=.E$,L|
00000320  25 2d 31 29 3a 45 24 3d  c1 45 24 2c 4c 25 2b 31  |%-1):E$=.E$,L%+1|
00000330  29 0d 01 c2 11 48 25 3d  a4 5f 66 69 6e 64 28 4c  |)....H%=._find(L|
00000340  24 29 0d 01 b8 33 e7 48  25 3d 2d 31 8c 85 32 35  |$)...3.H%=-1..25|
00000350  35 2c 22 55 6e 6b 6e 6f  77 6e 20 6c 61 62 65 6c  |5,"Unknown label|
00000360  20 27 22 2b 4c 24 2b 22  27 20 66 6f 72 20 65 78  | '"+L$+"' for ex|
00000370  70 6f 72 74 22 0d 01 b9  52 e7 5f 4c 25 28 48 25  |port"...R._L%(H%|
00000380  29 3c 73 74 61 72 74 25  84 5f 4c 25 28 48 25 29  |)<start%._L%(H%)|
00000390  3e 3d 65 6e 64 25 8c 85  32 35 35 2c 22 4c 61 62  |>=end%..255,"Lab|
000003a0  65 6c 20 27 22 2b 4c 24  2b 22 27 20 69 73 20 6e  |el '"+L$+"' is n|
000003b0  6f 74 20 69 6e 20 72 61  6e 67 65 20 66 6f 72 20  |ot in range for |
000003c0  65 78 70 6f 72 74 22 0d  01 cc 0a 5b 4f 50 54 20  |export"....[OPT |
000003d0  32 0d 01 d6 0a 2e 74 65  6d 70 25 0d 01 e0 0b 45  |2.....temp%....E|
000003e0  51 55 44 20 2d 31 0d 01  ea 17 45 51 55 44 20 5f  |QUD -1....EQUD _|
000003f0  4c 25 28 48 25 29 2d 73  74 61 72 74 25 0d 01 f4  |L%(H%)-start%...|
00000400  0f 45 51 55 53 20 4c 24  2b bd 31 33 0d 01 fe 09  |.EQUS L$+.13....|
00000410  41 4c 49 47 4e 0d 02 08  15 5d 3a 21 74 65 6d 70  |ALIGN....]:!temp|
00000420  25 3d 50 25 2d 74 65 6d  70 25 0d 02 12 05 ce 0d  |%=P%-temp%......|
00000430  02 1c 17 21 50 25 3d 26  38 30 30 30 30 30 30 30  |...!P%=&80000000|
00000440  3a 50 25 2b 3d 34 0d 02  26 2c ff 28 22 53 61 76  |:P%+=4..&,.("Sav|
00000450  65 20 4c 69 6e 6b 3a 22  2b 46 24 2b 22 20 22 2b  |e Link:"+F$+" "+|
00000460  c3 7e 73 74 61 72 74 25  2b 22 20 22 2b c3 7e 50  |.~start%+" "+.~P|
00000470  25 29 0d 02 30 21 ff 28  22 53 65 74 54 79 70 65  |%)..0!.("SetType|
00000480  20 4c 69 6e 6b 3a 22 2b  46 24 2b 22 20 44 41 54  | Link:"+F$+" DAT|
00000490  41 22 29 0d 02 3a 0b 50  25 3d 65 6e 64 25 0d 02  |A")..:.P%=end%..|
000004a0  44 05 e1 0d ff                                    |D....|
000004a5