Subversion Repositories SvarDOS

Rev

Rev 2243 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2243 Rev 2246
Line 112... Line 112...
112
parm [es ax] \
112
parm [es ax] \
113
modify [ax]
113
modify [ax]
114
 
114
 
115
 
115
 
116
 
116
 
-
 
117
static unsigned long mul16(unsigned short a, unsigned short b);
-
 
118
#pragma aux mul16 = \
-
 
119
"mul bx" \
-
 
120
parm [ax] [bx] \
-
 
121
value [dx ax]
-
 
122
 
-
 
123
 
-
 
124
 
-
 
125
/* multiplies two 32 bits number together using 16bit math to avoid
-
 
126
 * linkage against Watcom libc.
-
 
127
 * AB * CD = (A*C << 32) + ((B*C + A*D) << 16) + B*D */
-
 
128
static unsigned long mul32(unsigned long ab, unsigned long cd) {
-
 
129
  unsigned short a = ab >> 16l;
-
 
130
  unsigned short b = ab & 0xffff;
-
 
131
  unsigned short c = cd >> 16l;
-
 
132
  unsigned short d = cd & 0xffff;
-
 
133
  unsigned long res;
-
 
134
 
-
 
135
  res = mul16(b, c);
-
 
136
  res += mul16(a, d);
-
 
137
  res <<= 16;
-
 
138
  res += mul16(b, d);
-
 
139
  return(res);
-
 
140
}
-
 
141
 
-
 
142
 
117
/* fills freebytes with free bytes for drv (A=0, B=1, etc)
143
/* fills freebytes with free bytes for drv (A=0, B=1, etc)
118
 * returns DOS ERR code on failure */
144
 * returns DOS ERR code on failure */
119
static unsigned short cmd_dir_df(unsigned long *freebytes, unsigned char drv) {
145
static unsigned short cmd_dir_df(unsigned long *freebytes, unsigned char drv) {
120
  unsigned short res = 0;
146
  unsigned short res = 0;
121
  unsigned short sects_per_clust = 0, avail_clusts = 0, bytes_per_sect = 0;
147
  unsigned short sects_per_clust = 0, avail_clusts = 0, bytes_per_sect = 0;
Line 147... Line 173...
147
    pop bx
173
    pop bx
148
    pop ax
174
    pop ax
149
  }
175
  }
150
 
176
 
151
  /* multiple steps to avoid uint16 overflow */
177
  /* multiple steps to avoid uint16 overflow */
152
  *freebytes = sects_per_clust;
178
  *freebytes = mul32(sects_per_clust, avail_clusts);
153
  *freebytes *= avail_clusts;
-
 
154
  *freebytes *= bytes_per_sect;
179
  *freebytes = mul32(*freebytes, bytes_per_sect);
155
 
180
 
156
  return(res);
181
  return(res);
157
}
182
}
158
 
183
 
159
 
184