Subversion Repositories SvarDOS

Rev

Rev 1577 | Rev 1579 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1577 Rev 1578
Line 87... Line 87...
87
};
87
};
88
 
88
 
89
 
89
 
90
 
90
 
91
/*****************************************************************************
91
/*****************************************************************************
92
 * assembly "functions"                                                      *
92
 * assembly pragma "functions"                                               *
93
 *****************************************************************************/
93
 *****************************************************************************/
94
 
94
 
-
 
95
 
95
unsigned short dosalloc(unsigned short siz);
96
unsigned short dosalloc(unsigned short siz);
96
 
97
 
97
#pragma aux dosalloc = \
98
#pragma aux dosalloc = \
98
"mov ah, 0x48" \
99
"mov ah, 0x48" \
99
"int 0x21" \
100
"int 0x21" \
Line 113... Line 114...
113
"xor ax, ax" \
114
"xor ax, ax" \
114
"done:" \
115
"done:" \
115
parm [es] \
116
parm [es] \
116
value [ax];
117
value [ax];
117
 
118
 
-
 
119
 
118
unsigned short dosfclose(unsigned short handle);
120
unsigned short dosfclose(unsigned short handle);
119
 
121
 
120
#pragma aux dosfclose = \
122
#pragma aux dosfclose = \
121
"mov ah,0x3e" \
123
"mov ah,0x3e" \
122
"int 0x21" \
124
"int 0x21" \
Line 124... Line 126...
124
"xor ax, ax" \
126
"xor ax, ax" \
125
"done:" \
127
"done:" \
126
parm [bx] \
128
parm [bx] \
127
value [ax];
129
value [ax];
128
 
130
 
-
 
131
 
129
unsigned short dosfread(unsigned short handle, void *buf, unsigned short count, unsigned short *bytes);
132
unsigned short dosfread(unsigned short handle, void *buf, unsigned short count, unsigned short *bytes);
130
 
133
 
131
#pragma aux dosfread = \
134
#pragma aux dosfread = \
132
"mov ah, 0x3f" \
135
"mov ah, 0x3f" \
133
"int 0x21" \
136
"int 0x21" \
Line 136... Line 139...
136
"xor ax, ax" \
139
"xor ax, ax" \
137
"done:" \
140
"done:" \
138
parm [bx] [dx] [cx] [di] \
141
parm [bx] [dx] [cx] [di] \
139
value [ax]
142
value [ax]
140
 
143
 
-
 
144
 
141
unsigned short dos_resizeblock(unsigned short siz, unsigned short segn);
145
unsigned short dos_resizeblock(unsigned short siz, unsigned short segn);
142
 
146
 
143
#pragma aux dos_resizeblock = \
147
#pragma aux dos_resizeblock = \
144
"mov ah, 0x4a" \
148
"mov ah, 0x4a" \
145
"int 0x21" \
149
"int 0x21" \
Line 148... Line 152...
148
"done:" \
152
"done:" \
149
parm [bx] [es] \
153
parm [bx] [es] \
150
value [ax]
154
value [ax]
151
 
155
 
152
 
156
 
-
 
157
unsigned short dos_write(unsigned short handle, unsigned short count, unsigned short *bytes, const void far *buf);
-
 
158
/* NOTE: last parameter (far pointer buf) is passed on the stack */
-
 
159
#pragma aux dos_write = \
-
 
160
"push ds" \
-
 
161
"pop ax" \
-
 
162
"pop dx" \
-
 
163
"pop ds" \
-
 
164
"push ax" \
-
 
165
"mov ah, 0x40" \
-
 
166
"int 0x21" \
-
 
167
"pop ds" \
-
 
168
"jc done" \
-
 
169
"mov [di], ax" \
-
 
170
"xor ax, ax" \
-
 
171
"done:" \
-
 
172
parm [bx] [cx] [di] \
-
 
173
value [ax]
-
 
174
 
-
 
175
 
153
/*****************************************************************************
176
/*****************************************************************************
154
 * functions                                                                 *
177
 * functions                                                                 *
155
 *****************************************************************************/
178
 *****************************************************************************/
156
 
179
 
157
 
180
 
158
static unsigned short dos_write(unsigned short handle, const void far *buf, unsigned short count, unsigned short *bytes) {
-
 
159
  unsigned short res = 0;
-
 
160
  unsigned short resax = 0;
-
 
161
  unsigned short buf_seg = FP_SEG(buf);
-
 
162
  unsigned short buf_off = FP_OFF(buf);
-
 
163
 
-
 
164
  _asm {
-
 
165
    push bx
-
 
166
    push cx
-
 
167
    push dx
-
 
168
 
-
 
169
    mov ah, 0x40
-
 
170
    mov bx, handle
-
 
171
    mov cx, count
-
 
172
    mov dx, buf_off
-
 
173
    push ds
-
 
174
    mov ds, buf_seg
-
 
175
 
-
 
176
    int 0x21
-
 
177
    pop ds
-
 
178
    jnc done
-
 
179
    mov res, ax
-
 
180
 
-
 
181
    done:
-
 
182
    mov resax, ax
-
 
183
 
-
 
184
    pop dx
-
 
185
    pop cx
-
 
186
    pop bx
-
 
187
  }
-
 
188
 
-
 
189
  *bytes = resax;
-
 
190
  return(res);
-
 
191
}
-
 
192
 
-
 
193
 
-
 
194
static size_t strlen(const char *s) {
181
static size_t strlen(const char *s) {
195
  const char *ptr = s;
182
  const char *ptr = s;
196
  while (*ptr != 0) ptr++;
183
  while (*ptr != 0) ptr++;
197
  return(ptr - s);
184
  return(ptr - s);
198
}
185
}
Line 390... Line 377...
390
  }
377
  }
391
 
378
 
392
  while (l) {
379
  while (l) {
393
    /* do not write the last empty line, it is only useful for edition */
380
    /* do not write the last empty line, it is only useful for edition */
394
    if (l->len != 0) {
381
    if (l->len != 0) {
395
      errflag |= dos_write(fd, l->payload, l->len, &bytes);
382
      errflag |= dos_write(fd, l->len, &bytes, l->payload);
396
    } else if (l->next == NULL) {
383
    } else if (l->next == NULL) {
397
      break;
384
      break;
398
    }
385
    }
399
    errflag |= dos_write(fd, eolbuf, eollen, &bytes);
386
    errflag |= dos_write(fd, eollen, &bytes, eolbuf);
400
    l = l->next;
387
    l = l->next;
401
  }
388
  }
402
 
389
 
403
  errflag |= dosfclose(fd);
390
  errflag |= dosfclose(fd);
404
 
391