-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRman03.asm
276 lines (227 loc) · 5.34 KB
/
Rman03.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
;.OPT
;RMAN03;RNDMAN > Rman03
;.TTL
;Fileserver file RMAN03
.RMAN03
;*** RDCHNT ***
;Checks the cache descriptor hint in a
;RANDTB entry.
;Entry: HNDPTR points to HANDTB entry
;RTEPTR points to RANDTB entry
;Exit: A = RC: zero => hint used, GENPTR set
;non-zero=> must call STRMAN instead
;GENPTR points to cache buffer (iff RC=0)
.RDCHNT
{
LDY #RTDESC;GENPTR := Cache descriptor hint
LDA (RTEPTR),Y;from RANDTB entry
STA GENPTR
INY
LDA (RTEPTR),Y
STA GENPTR + 1
;Hint is invalid if it is zero (as it
;is when file first opened)
ORA GENPTR;OR both bytes of hint
BEQ RDCHNZ;Hint no good (zero)
;Must now check that the hint still points
;to the cache descriptor we want. (If it
;is not zero, it will always point to
;SOME cache descriptor).
;The descriptor is valid only if it has the
;right disc number and SIN, and if its start
;block is the one we want.
;*** Assumptions:
;*** 1) Blocksize = 256 bytes (=> easy
;*** calculation of block number
;*** 2) Cache buffers contain only one
;*** disc block
;Compare SINs first (more likely to
;be different than disc number).
LDY #HTSIN
LDA (HNDPTR),Y
LDY #CESIN
CMP (GENPTR),Y;Compare LS bytes
BNE RDCHNZ;Different
LDY #HTSIN + 1
LDA (HNDPTR),Y
LDY #CESIN + 1
CMP (GENPTR),Y;Compare CS bytes
BNE RDCHNZ;Different
LDY #HTSIN + 2
LDA (HNDPTR),Y
LDY #CESIN + 2
CMP (GENPTR),Y;Compare MS bytes
BNE RDCHNZ;Different
;SIN OK - check disc no.
LDY #HTDISC;Compar disc nos.
LDA (HNDPTR),Y
LDY #CEDISC
CMP (GENPTR),Y;Compare LS bytes
BNE RDCHNZ;Different - hint no good
LDY #HTDISC + 1
LDA (HNDPTR),Y
LDY #CEDISC + 1
CMP (GENPTR),Y;Compare MS bytes
BNE RDCHNZ;Different
;Disc no. OK - Check block no.
;(should be equal to top 2 bytes of
;sequential file pointer).
LDY #CEBKNO
LDA (GENPTR),Y;LS byte of block no.
LDY #RTCSFP + 1
CMP (RTEPTR),Y;Comp with CS byte of SFP
BNE RDCHNZ;Different
LDY #CEBKNO + 1
LDA (GENPTR),Y;MS byte of block no.
LDY #RTCSFP + 2
CMP (RTEPTR),Y;Comp with MS byte of SFP
BNE RDCHNZ;Different
;The hint is OK.
;Copy buffer address to GENPTR (which
;currently points to cache descriptor).
LDY #CESTA
LDA (GENPTR),Y;LS byte of buff addr
PHA ;Save for now
INY
LDA (GENPTR),Y;MS byte of buff addr
STA GENPTR + 1;GENPTR := buff addr
PLA
STA GENPTR;LS byte
LDA #0;Success - hint used
RTS
.RDCHNZ
LDA #&FF;Hint no good
RTS
}
;************ RDCLAF ************
;RDCLAF: Close all files for the calling machine
;Entry: ARGB = Ptr to user info (LS)
;ARGC = Ptr to user info (MS)
;Exit: ARGA = Return code
.RDCLAF
{
JSR INITRD;Set GENPTR & MCNUMB & RDUPTR (extra copy of user ptr.)
JSR INITHD;Set HNDPTR and X
.RDCLFA
LDY #HTMCNO
LDA (HNDPTR),Y;Get mc no. from HANDTB entry
CMP MCNUMB;Same as client machine?
BNE RDCLFB;LS bytes differ
INY
LDA (HNDPTR),Y;CS byte
CMP MCNUMB + 1
BNE RDCLFB;CS bytes differ
INY
LDA (HNDPTR),Y;MS byte
CMP MCNUMB + 2
BNE RDCLFB;MS bytes differ
;Entry is for this machine.
;See if the object is a file.
LDY #HTACC
LDA (HNDPTR),Y;Object type & access
AND #TYPE
CMP #TYPDIR;Is it a directory? ;MM NOT NECESSARY
BEQ RDCLFB;Jump if yes
;Entry is for a file for this mc.
LDA RDUPTR
STA GENPTR
LDA RDUPTR + 1
STA GENPTR + 1;Set pointer to user info (corrupted over CLRHTE)
TXA ;Save X ;;MM WHY?
PHA
JSR CLRHTE;Close the file
TAX
PLA ;tidy stack
TXA ;return error code
BNE RDCLFX;**** 17/3/83 ****
.RDCLFB
JSR INCHND;Inc pointer
BNE RDCLFA;Look at next entry
LDA #0;Return code
.RDCLFX
JMP RDEXIT;Return
}
;************ RDSUBO ************
;RDSUBO: Set up for PUTBYTES/GETBYTES operation
;Entry: ARGB = LS ptr to user info
;ARGC = MS " " " "
;ARGD = file handle
;ARGE = Seq. no. received
;ARGF = Flag: 0 => use given offset
;NOT 0 => use SFP in RANDTB
;ARGG = LS total no. of bytes
;ARGH = CS " " " "
;ARGI = MS " " " "
;ARGJ = LS Offset in file
;ARGK = CS (only if flag=0)
;ARGL = MS "
;
; Side effect:
; OLDSZE is set to old HWM
; OLDSZE+3 is zero if area of disc has
; to be zeroed on a write
;
.RDSUBO
{
LDA #1
STA OLDSZE +3
JSR INITRD
LDY #ARGD
LDA (ARGPTR),Y;A := handle
JSR FNDHND;HNDPTR := HANDTB entry
BNE RDSUBZ;Not found - exit
JSR SETRPT;RTEPTR := RANDTB entry
BNE RDSUBZ;Not found
JSR RDCSEQ;Check seq no and set SFP accordingly
LDY #ARGF
LDA (ARGPTR),Y;A := flag
BNE RDSUBA;Offset not supplied
;Offset supplied : set SFP to offset
LDY #RTHWM;GET CURRENT HWM
LDA (RTEPTR),Y
STA OLDSZE
INY
LDA (RTEPTR),Y
STA OLDSZE + 1
INY
LDA (RTEPTR),Y
STA OLDSZE + 2
LDA #0;ZERO FLAG
STA OLDSZE + 3
LDY #ARGJ;CHECK IF NEW SIZE LARGER THAN OLD
LDA OLDSZE
CMP (ARGPTR),Y
INY
LDA OLDSZE + 1
SBC (ARGPTR),Y
INY
LDA OLDSZE + 2
SBC (ARGPTR),Y
BCC RDSSI
INC OLDSZE + 3
.RDSSI
LDY #ARGJ
LDA (ARGPTR),Y;Offset (LS)
LDY #RTCSFP
STA (RTEPTR),Y;LS byte
LDY #ARGK
LDA (ARGPTR),Y
LDY #RTCSFP + 1
STA (RTEPTR),Y;CS byte
LDY #ARGL
LDA (ARGPTR),Y
LDY #RTCSFP + 2
STA (RTEPTR),Y;MS byte
.RDSUBA
JSR RDCKSP;Check SFP inside file
BEQ RDSUBZ
PHA
JSR RDBACK;restore SFP to old SFP
PLA
;LDA #0;rc
.RDSUBZ
JMP RDEXIT
}
;.LNK
;RMAN04
;