1387
|
1 IFGT Level-1
|
|
2
|
1345
|
3 **************************************************
|
|
4 * System Call: F$SLink
|
|
5 *
|
|
6 * Function: System Link
|
|
7 *
|
|
8 * Input: A = Module type
|
|
9 * X = Module name string pointer
|
|
10 * Y = Name string DAT image pointer
|
|
11 *
|
|
12 * Output: A = Module type
|
|
13 * B = Module revision
|
|
14 * X = Updated name string pointer
|
|
15 * Y = Module entry point
|
|
16 * U = Module pointer
|
|
17 *
|
|
18 * Error: CC = C bit set; B = error code
|
|
19 *
|
1145
|
20 FSLink ldy R$Y,u get DAT image pointer of name
|
|
21 bra L0398 skip ahead
|
|
22
|
1345
|
23
|
|
24 **************************************************
|
|
25 * System Call: F$ELink
|
|
26 *
|
|
27 * Function: Link using module directory entry
|
|
28 *
|
|
29 * Input: B = Module type
|
|
30 * X = Pointer to module directory entry
|
|
31 *
|
|
32 * Output: None
|
|
33 *
|
|
34 * Error: CC = C bit set; B = error code
|
|
35 *
|
1145
|
36 FELink pshs u preserve register stack pointer
|
|
37 ldb R$B,u get module type
|
|
38 ldx R$X,u get pointer to module directory entry
|
|
39 bra L03AF skip ahead
|
|
40
|
1387
|
41 ENDC
|
1145
|
42
|
|
43 **************************************************
|
|
44 * System Call: F$Link
|
|
45 *
|
|
46 * Function: Link to a memory module
|
|
47 *
|
|
48 * Input: X = Address of module name
|
|
49 * A = Type/Language byte
|
|
50 *
|
|
51 * Output: X = Advanced past module name
|
|
52 * Y = Module entry point address
|
|
53 * U = Module header address
|
|
54 * A = Module type/language byte
|
|
55 * B = Module attributes/revision byte
|
|
56 *
|
|
57 * Error: CC = C bit set; B = error code
|
|
58 *
|
1387
|
59 FLink equ *
|
|
60 IFGT Level-1
|
|
61 ldx <D.Proc get pointer to DAT image
|
1145
|
62 leay P$DATImg,x point to process DAT image
|
1387
|
63 ENDC
|
1145
|
64 L0398 pshs u preserve register stack pointer
|
|
65 ldx R$X,u get pointer to path name
|
|
66 lda R$A,u get module type
|
|
67 lbsr L068D search module directory
|
1387
|
68 bcs LinkErr not there, exit with error
|
1145
|
69 leay ,u point to module directory entry
|
|
70 ldu ,s get register stack pointer
|
|
71 stx R$X,u save updated module name pointer
|
|
72 std R$D,u save type/language
|
|
73 leax ,y point to directory entry
|
|
74 L03AF bitb #ReEnt is it re-entrant?
|
|
75 bne L03BB yes, skip ahead
|
|
76 ldd MD$Link,x is module busy?
|
|
77 beq L03BB no, go link it
|
|
78 ldb #E$ModBsy return module busy error
|
1387
|
79 bra LinkErr return
|
1145
|
80 L03BB ldd MD$MPtr,x get module pointer
|
|
81 pshs d,x preserve that & directory pointer
|
|
82 ldy MD$MPDAT,x get module DAT image pointer
|
|
83 ldd MD$MBSiz,x get block size
|
|
84 addd #$1FFF round it up
|
|
85 tfr a,b
|
|
86 lsrb
|
|
87 lsrb
|
|
88 lsrb
|
|
89 lsrb
|
|
90 lsrb
|
|
91 * adda #$02
|
|
92 lsra
|
|
93 inca instead of adda #2, above
|
|
94 lsra
|
|
95 lsra
|
|
96 lsra
|
|
97 lsra
|
|
98 pshs a
|
|
99 leau ,y point to module DAT image
|
|
100 bsr L0422 is it already linked in process space?
|
|
101 bcc L03EB yes, skip ahead
|
|
102 lda ,s
|
|
103 lbsr L0A33 find free low block in process DAT image
|
|
104 bcc L03E8 found some, skip ahead
|
|
105 leas 5,s purge stack
|
1387
|
106 bra LinkErr return error
|
1145
|
107
|
|
108 L03E8 lbsr L0A8C copy memory blocks into process DAT image
|
1387
|
109 L03EB ldb #P$Links point to memory block link counts
|
|
110 abx smaller and faster than leax P$Links,x
|
|
111 sta ,s save block # on stack
|
1145
|
112 lsla account for 2 bytes/entry
|
1387
|
113 leau a,x point to block # we want
|
|
114 ldd ,u get link count for that block
|
1145
|
115 IFNE H6309
|
1387
|
116 incd bump up by 1
|
1145
|
117 ELSE
|
|
118 addd #$0001
|
|
119 ENDC
|
|
120 beq L03FC If wraps to 0, leave at $FFFF
|
|
121 std ,u Otherwise, store new link count
|
|
122 L03FC ldu $03,s
|
|
123 ldd MD$Link,u
|
|
124 IFNE H6309
|
|
125 incd
|
|
126 ELSE
|
|
127 addd #$0001
|
|
128 ENDC
|
|
129 beq L0406
|
|
130 std MD$Link,u
|
|
131 L0406 puls b,x,y,u
|
|
132 lbsr CmpLBlk
|
|
133 stx R$U,u
|
|
134 ldx MD$MPtr,y
|
|
135 ldy ,y
|
|
136 ldd #M$Exec get offset to execution address
|
|
137 lbsr L0B02 get execution offset
|
|
138 addd R$U,u add it to start of module
|
|
139 std R$Y,u set execution entry point
|
|
140 clrb No error & return
|
|
141 rts
|
|
142
|
1387
|
143 LinkErr orcc #Carry Error & return
|
1145
|
144 puls u,pc
|
|
145
|
|
146 L0422 ldx <D.Proc get pointer to current process
|
|
147 leay P$DATImg,x point to process DAT image
|
|
148 clra
|
|
149 pshs d,x,y
|
|
150 subb #DAT.BlCt
|
|
151 negb
|
|
152 lslb
|
|
153 leay b,y
|
|
154 IFNE H6309
|
|
155 L0430 ldw ,s Get counter
|
|
156 ELSE
|
|
157 L0430 ldx ,s
|
|
158 ENDC
|
|
159 pshs u,y
|
|
160 L0434 ldd ,y++
|
|
161 cmpd ,u++
|
|
162 bne L0449
|
|
163 IFNE H6309
|
|
164 decw Dec counter
|
|
165 ELSE
|
|
166 leax -1,x
|
|
167 ENDC
|
|
168 bne L0434 If not done, keep going
|
|
169 puls d,u
|
|
170 subd 4,s
|
|
171 lsrb
|
|
172 stb ,s
|
|
173 clrb
|
|
174 puls d,x,y,pc Restore regs & return
|
|
175
|
|
176 L0449 puls u,y
|
|
177 leay -2,y
|
|
178 cmpy 4,s
|
|
179 bcc L0430
|
|
180 puls d,x,y,pc
|