Subversion Repositories Kolibri OS

Rev

Rev 174 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 182
Line 2... Line 2...
2
; Copyright (c) 1999-2005, Tomasz Grysztar
2
; Copyright (c) 1999-2005, Tomasz Grysztar
3
; All rights reserved.
3
; All rights reserved.
4
;
4
;
5
; MenuetOS system.inc by VT
5
; MenuetOS system.inc by VT
Line -... Line 6...
-
 
6
 
-
 
7
struc FILEIO
-
 
8
{   .cmd            dd ?
-
 
9
    .offset         dd ?
-
 
10
                    dd ?
-
 
11
    .count          dd ?
-
 
12
    .buff           dd ?
-
 
13
                    db ?
-
 
14
    .name           dd ?
-
 
15
};
-
 
16
 
-
 
17
struc FILEINFO
-
 
18
{   .attr           dd ?
-
 
19
    .flags          dd ?
-
 
20
    .cr_time        dd ?
-
 
21
    .cr_date        dd ?
-
 
22
    .acc_time       dd ?
-
 
23
    .acc_date       dd ?
-
 
24
    .mod_time       dd ?
-
 
25
    .mod_date       dd ?
-
 
26
    .size           dd ?
-
 
27
}
-
 
28
 
-
 
29
 
6
 
30
 
7
file_info_open:  dd 0,0,0xffffff,0x20000,0xf0000
31
;file_info_open:  dd 0,0,0xffffff,0x20000,0xf0000
8
fullpath_open:  ;  db '/RD/1/EXAMPLE.ASM'
32
fullpath_open:  ;  db '/RD/1/EXAMPLE.ASM'
Line 9... Line 33...
9
		    times MAX_PATH db 0
33
		    times MAX_PATH db 0
10
 
34
 
11
 
35
 
Line 12... Line 36...
12
file_info_write: dd 1,0,0,0,0xf0000
36
;file_info_write: dd 1,0,0,0,0xf0000
13
fullpath_write:; db '/RD/1/EXAMPLE'
37
fullpath_write:; db '/RD/1/EXAMPLE'
Line 61... Line 85...
61
	rep	movsb
85
	rep	movsb
62
  .finish:
86
  .finish:
63
;       stc
87
;       stc
64
	ret
88
	ret
Line -... Line 89...
-
 
89
 
-
 
90
 
-
 
91
create:
-
 
92
	call  make_fullpaths
-
 
93
	ret
-
 
94
 
65
 
95
 
-
 
96
open:
-
 
97
;        call    make_fullpaths
-
 
98
 
-
 
99
;;       mov     eax,fullpath_open
-
 
100
;;       DEBUGF  '"%s"\n',eax
-
 
101
 
-
 
102
;        mov     dword[file_info_open+8],-1
-
 
103
;        mcall   58,file_info_open
-
 
104
;        or      eax,eax                 ; found
-
 
105
;        jz      @f
-
 
106
;        cmp     eax,6
-
 
107
;        jne     file_error
-
 
108
;@@: mov [filesize],ebx
-
 
109
;        clc
-
 
110
;        ret
-
 
111
;file_error:
-
 
112
;        stc
-
 
113
;        ret
66
open:
114
 
Line -... Line 115...
-
 
115
           call    make_fullpaths
67
	call	make_fullpaths
116
 
-
 
117
           xor eax, eax
-
 
118
           mov [fileio.cmd], 5
68
 
119
           mov [fileio.offset], eax
-
 
120
           mov [fileio.offset+4], eax
-
 
121
           mov [fileio.count], eax
-
 
122
           mov [fileio.buff], fileinfo
Line 69... Line 123...
69
;       mov     eax,fullpath_open
123
           mov byte [fileio.buff+4], al
70
;       DEBUGF  '"%s"\n',eax
124
           mov [fileio.name], fullpath_open
71
 
125
 
72
	mov	dword[file_info_open+8],-1
-
 
73
	mcall	58,file_info_open
126
           mov eax, 70
74
	or	eax,eax 		; found
127
           mov ebx, fileio
-
 
128
           int 0x40
75
	jz	@f
129
           test eax, eax
76
	cmp	eax,6
130
           jnz .fail
77
	jne	file_error
131
           mov ebx, [fileinfo.size]
78
@@: mov	[filesize],ebx
132
           mov [filesize],ebx
79
	clc
133
           clc
80
	ret
134
           ret
Line 81... Line 135...
81
file_error:
135
.fail:
-
 
136
           stc
-
 
137
           ret
-
 
138
 
-
 
139
read:
-
 
140
;          pusha
82
	stc
141
;          mov     edi,edx
-
 
142
;          mov     esi,[filepos]
-
 
143
;          add     esi,0x20000
-
 
144
;          cld
-
 
145
;          rep     movsb
-
 
146
;          popa
-
 
147
;;         ret
-
 
148
 
-
 
149
           xor eax, eax
-
 
150
           mov [fileio.cmd], eax
-
 
151
           mov [fileio.offset], eax
-
 
152
           mov [fileio.offset+4], eax
-
 
153
           mov [fileio.count], ecx
-
 
154
           mov [fileio.buff], edx
-
 
155
           mov byte [fileio.buff+4], al
-
 
156
           mov [fileio.name], fullpath_open
83
	ret
157
           mov eax, 70
Line -... Line 158...
-
 
158
           mov ebx, fileio
84
 
159
           int 0x40
85
create:
160
close:
86
	call  make_fullpaths
161
           ret
87
	ret
162
 
88
 
163
 
89
; ebx file handle
164
; ebx file handle
90
; ecx count of bytes to write
165
; ecx count of bytes to write
91
; edx pointer to buffer
166
; edx pointer to buffer
92
write:
167
write:
93
	pusha
168
;        pusha
-
 
169
;        mov     [file_info_write+8],ecx
-
 
170
;        mov     [file_info_write+12],edx
-
 
171
;        mov     [filesize],edx
-
 
172
;        mov     eax,58
-
 
173
;        mov     ebx,file_info_write
-
 
174
;        int     0x40
-
 
175
;        popa
-
 
176
;        ret
-
 
177
 
-
 
178
           xor eax, eax
-
 
179
           mov [fileio.cmd], 2
-
 
180
           mov [fileio.offset], eax
-
 
181
           mov [fileio.offset+4], eax
-
 
182
           mov [fileio.count], ecx
94
	mov	[file_info_write+8],ecx
183
           mov [fileio.buff], edx
-
 
184
           mov byte [fileio.buff+4], al
-
 
185
           mov [fileio.name], fullpath_write
-
 
186
           mov eax, 70
-
 
187
           mov ebx, fileio
95
	mov	[file_info_write+12],edx
188
           int 0x40
-
 
189
           test eax, eax
96
	mov	[filesize],edx
190
           jnz .fail
Line 97... Line 191...
97
	mov	eax,58
191
           clc
98
	mov	ebx,file_info_write
192
           ret
99
	int	0x40
193
.fail:
Line 177... Line 271...
177
 
271
 
178
;        add  esp,4
272
;        add  esp,4
179
	popa
273
	popa
Line 180... Line -...
180
	ret
-
 
181
 
-
 
182
read:
-
 
183
	pusha
-
 
184
	mov	edi,edx
-
 
185
	mov	esi,[filepos]
-
 
186
	add	esi,0x20000
-
 
187
	cld
-
 
188
	rep	movsb
-
 
Line 189... Line -...
189
	popa
-
 
Line 190... Line 274...
190
;       ret
274
	ret
191
 
275
 
192
close:	ret
276
 
193
 
277
 
Line 204... Line 288...
204
    @@: mov	eax,[filepos]
288
    @@: mov	eax,[filepos]
205
	add	eax,edx
289
	add	eax,edx
206
	mov	[filepos],eax
290
	mov	[filepos],eax
207
	ret
291
	ret
Line 208... Line -...
208
 
-
 
209
 
-
 
210
 
292
 
211
display_character:
293
display_character:
212
	pusha
294
	pusha
213
	cmp	[_mode],NORMAL_MODE
295
	cmp	[_mode],NORMAL_MODE
214
	jne	@f
296
	jne	@f
Line 424... Line 506...
424
	call	display_string
506
	call	display_string
425
	mov	esi,error_suffix
507
	mov	esi,error_suffix
426
	call	display_string
508
	call	display_string
427
	jmp	exit_program
509
	jmp	exit_program
Line -... Line 510...
-
 
510
 
-
 
511
align 4
-
 
512
fileio FILEIO
-
 
513
align 4
Line 428... Line 514...
428
 
514
fileinfo FILEINFO
429
 
515
 
Line 430... Line 516...
430
character   db ?,0
516
character   db ?,0