fasm rewritten with fn. 70

git-svn-id: svn://kolibrios.org@182 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2006-10-12 14:24:33 +00:00
parent aacb4b7591
commit b4dd0c152f

View File

@ -4,12 +4,36 @@
; ;
; MenuetOS system.inc by VT ; MenuetOS system.inc by VT
file_info_open: dd 0,0,0xffffff,0x20000,0xf0000 struc FILEIO
{ .cmd dd ?
.offset dd ?
dd ?
.count dd ?
.buff dd ?
db ?
.name dd ?
};
struc FILEINFO
{ .attr dd ?
.flags dd ?
.cr_time dd ?
.cr_date dd ?
.acc_time dd ?
.acc_date dd ?
.mod_time dd ?
.mod_date dd ?
.size dd ?
}
;file_info_open: dd 0,0,0xffffff,0x20000,0xf0000
fullpath_open: ; db '/RD/1/EXAMPLE.ASM' fullpath_open: ; db '/RD/1/EXAMPLE.ASM'
times MAX_PATH db 0 times MAX_PATH db 0
file_info_write: dd 1,0,0,0,0xf0000 ;file_info_write: dd 1,0,0,0,0xf0000
fullpath_write:; db '/RD/1/EXAMPLE' fullpath_write:; db '/RD/1/EXAMPLE'
times MAX_PATH db 0 times MAX_PATH db 0
@ -63,41 +87,111 @@ get_environment_variable:
; stc ; stc
ret ret
open:
call make_fullpaths
; mov eax,fullpath_open
; DEBUGF '"%s"\n',eax
mov dword[file_info_open+8],-1
mcall 58,file_info_open
or eax,eax ; found
jz @f
cmp eax,6
jne file_error
@@: mov [filesize],ebx
clc
ret
file_error:
stc
ret
create: create:
call make_fullpaths call make_fullpaths
ret ret
open:
; call make_fullpaths
;; mov eax,fullpath_open
;; DEBUGF '"%s"\n',eax
; mov dword[file_info_open+8],-1
; mcall 58,file_info_open
; or eax,eax ; found
; jz @f
; cmp eax,6
; jne file_error
;@@: mov [filesize],ebx
; clc
; ret
;file_error:
; stc
; ret
call make_fullpaths
xor eax, eax
mov [fileio.cmd], 5
mov [fileio.offset], eax
mov [fileio.offset+4], eax
mov [fileio.count], eax
mov [fileio.buff], fileinfo
mov byte [fileio.buff+4], al
mov [fileio.name], fullpath_open
mov eax, 70
mov ebx, fileio
int 0x40
test eax, eax
jnz .fail
mov ebx, [fileinfo.size]
mov [filesize],ebx
clc
ret
.fail:
stc
ret
read:
; pusha
; mov edi,edx
; mov esi,[filepos]
; add esi,0x20000
; cld
; rep movsb
; popa
;; ret
xor eax, eax
mov [fileio.cmd], eax
mov [fileio.offset], eax
mov [fileio.offset+4], eax
mov [fileio.count], ecx
mov [fileio.buff], edx
mov byte [fileio.buff+4], al
mov [fileio.name], fullpath_open
mov eax, 70
mov ebx, fileio
int 0x40
close:
ret
; ebx file handle ; ebx file handle
; ecx count of bytes to write ; ecx count of bytes to write
; edx pointer to buffer ; edx pointer to buffer
write: write:
pusha ; pusha
mov [file_info_write+8],ecx ; mov [file_info_write+8],ecx
mov [file_info_write+12],edx ; mov [file_info_write+12],edx
mov [filesize],edx ; mov [filesize],edx
mov eax,58 ; mov eax,58
mov ebx,file_info_write ; mov ebx,file_info_write
; int 0x40
; popa
; ret
xor eax, eax
mov [fileio.cmd], 2
mov [fileio.offset], eax
mov [fileio.offset+4], eax
mov [fileio.count], ecx
mov [fileio.buff], edx
mov byte [fileio.buff+4], al
mov [fileio.name], fullpath_write
mov eax, 70
mov ebx, fileio
int 0x40 int 0x40
popa test eax, eax
jnz .fail
clc
ret
.fail:
stc
ret ret
make_fullpaths: make_fullpaths:
@ -179,17 +273,7 @@ make_fullpaths:
popa popa
ret ret
read:
pusha
mov edi,edx
mov esi,[filepos]
add esi,0x20000
cld
rep movsb
popa
; ret
close: ret
lseek: lseek:
cmp al,0 cmp al,0
@ -206,8 +290,6 @@ lseek:
mov [filepos],eax mov [filepos],eax
ret ret
display_character: display_character:
pusha pusha
cmp [_mode],NORMAL_MODE cmp [_mode],NORMAL_MODE
@ -426,6 +508,10 @@ display_line_data:
call display_string call display_string
jmp exit_program jmp exit_program
align 4
fileio FILEIO
align 4
fileinfo FILEINFO
character db ?,0 character db ?,0
bytes_count dd ? bytes_count dd ?