-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathhdssutil
216 lines (216 loc) · 3.76 KB
/
hdssutil
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
;*********************************
;* B0TOB0: TRANSFER BYTES FROM *
;* ONE BUF TO OTHER. *
;* REG: IN: .A= # BYTES *
;* .Y= SOURCE BUF # *
;* .X= DESTIN BUF # *
;*********************************
;
B0TOB0
PHA
LDA #0
STA TEMP
STA TEMP+2
LDA BUFIND,Y
STA TEMP+1
LDA BUFIND,X
STA TEMP+3
PLA
TAY
DEY
B02
LDA (TEMP)Y
STA (TEMP+2)Y
DEY
BPL B02
RTS
;
;*********************************
;* CLRBUF: CLEAR BUFFER GIVEN *
;* REG: IN: .A= BUFFER # *
;* OUT: .Y,.A =0 *
;*********************************
;
CLRBUF
TAY
LDA BUFIND,Y
STA TEMP+1
LDY #0
STY TEMP
LDA #255 ;<HD>
CB10
STA (TEMP),Y
INY
BNE CB10
RTS
;
;
;*********************************
;* SSSET: SET SS PNTR TO 0 *
;* REG: OUT: .A= SS NUMBER *
;*********************************
;
SSSET
LDA #0
JSR SSDIR
LDY #2
LDA (DIRBUF)Y ;GET CURNT SS #
RTS
;
;*********************************
;* SSDIR: SET DIRBUF WITH CURRENT*
;* SS POINTER. *
;* REGS: IN: .A= LOW BYTE *
;*********************************
;
SSDIR
STA DIRBUF
LDX LINDX
LDA SS,X
TAX
LDA BUFIND,X
STA DIRBUF+1
RTS
;
;*********************************
;* SETSSP: SET DIRBUF & BUFTAB *
;* WITH CURRENT SS PTR. *
;* REGS: IN: .A= LOW BYTE *
;*********************************
;
SETSSP
PHA
JSR SSDIR
PHA
TXA
ASL A
TAX
PLA
STA BUFTAB+1,X
PLA
STA BUFTAB,X
RTS
;
;*********************************
;* SSPOS: POSITION SS & BUFTAB *
;* TO SSNUM SSIND. *
;* FLAG: .V=0: OK *
;* .V=1: OUT OF RANGE *
;*********************************
;
SSPOS
JSR SSTEST
BMI SSP10 ;OUT OF RANGE
BVC SSP20 ;ER0:OK, IN RANGE
;
LDX LINDX ;ER1: POSSIBLY IN RANGE
LDA SS,X
JSR IBRD ;READ SS IN
JSR SSTEST ;TEST AGAIN
BPL SSP20
SSP10
JSR SSEND ;NOT IN RANGE,SET END
BIT ER1
RTS
SSP20
LDA SSIND ;OK, SET PTR W/ INDEX
JSR SETSSP
BIT ER0
RTS
;
;*********************************
;* IBRD: INDIRECT BLOCK READ & *
;* IBWT: WRITE. *
;* REGS: IN: .A= BUF # FOR R/W *
;* .X= LINDX *
;* (DIRBUF)Y POINTS TO *
;* T&S TO BE R/W. *
;*********************************
;
IBRD
STA JOBNUM
LDA #READ
BNE IBOP
IBWT
STA JOBNUM
LDA #WRITE
IBOP
PHA
LDA FILTYP,X
AND #1
STA DRVNUM
PLA
ORA DRVNUM
STA CMD
;
LDA (DIRBUF)Y
STA TRACK
INY
LDA (DIRBUF)Y
STA SECTOR
LDA JOBNUM
JSR SETH
LDX JOBNUM
JMP DOIT2
;
;
;*
;*****************************
;*
;* GSSPNT
;*
;*****************************
;*
GSSPNT LDX LINDX
LDA SS,X
JMP GP1
;
;
;*****************************************
; CALCULATE # SECTORS NEEDED
; ON ENTRANCE: R3= # WHOLE GROUPS
; T4= # WHOLE SIDE SECTORS
; T3= # DATA SECTORS
;
;*****************************************
SSCALC
JSR ZERRES ;ZERO RESULT
JSR ZERACC ;ZERO ACCUMULATOR
LDY R3 ;GROUP #
LABEL
DEY ;MULT GROUP BY 726
BMI LABEL1 ;BR IF MULT DONE
LDX #>726 ;HIGH AMOUNT
LDA #<726 ;LOW AMOUNT
JSR ADDLIT ;ADD IT TO RESULT
JMP LABEL ;GO TILL DONE
LABEL1
LDY T4 ;SIDE SECTORS
LABEL2
DEY ;COUNT # OF FULL SIDE SECTORS
BMI LABEL3 ;BR WHEN DONE
LDX #0 ;# SS + 1 FOR SS ITSELF
LDA #NSSP+1 ;*
JSR ADDLIT ;ADD TO RESULT
JMP LABEL2 ;GO TILL DONE
LABEL3
LDA T3 ;ADD # DATA SECTORS *2
LSR A ;DIVIDE BY 2
LDX #0 ;HIGH BYTE
JMP ADDLIT ;ADD IT IN AND RETURN
;
; SSCALC SUBROUTINES
;
ZERACC
LDX #0 ;ZERO THE ACCUMULATOR
STX ACCUM+1 ;*
STX ACCUM+2 ;*
STX ACCUM+3 ;*
RTS ;EXIT
;
;
ADDLIT ;ADD 16 BIT VAL TO ACCUM
STX ACCUM+2 ;HIGH BYTE
STA ACCUM+1 ;LOW BYTE
JMP ADDRES ;ADD TO THE RESULT
.END