annotate level2/modules/kernel/flink.asm @ 1948:7010c08050b7

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