* stdcall changes merged to EMX

This commit is contained in:
Tomas Hajny 2003-10-04 17:53:08 +00:00
parent c678f31a13
commit 2200cb4d8e
3 changed files with 148 additions and 100 deletions

View File

@ -109,6 +109,8 @@ type {Some string types:}
efdetach: Detached. Function unknown. Info wanted!
efpm: Run as presentation manager program.
Not found info about execwinflags
Determining the window state of the program:
efdefault: Run the pm program in it's default situation.
efminimize: Run the pm program minimized.
@ -116,9 +118,7 @@ type {Some string types:}
effullscreen: Run the non-pm program fullscreen.
efwindowed: Run the non-pm program in a window.
Other options are not implemented defined because lack of
knowledge about what they do.}
}
type execrunflags=(efwait,efno_wait,efoverlay,efdebug,efsession,
efdetach,efpm);
execwinflags=(efdefault,efminimize,efmaximize,effullscreen,
@ -260,6 +260,7 @@ procedure getftime(var f;var time:longint);
begin
asm
pushl %ebx
{Load handle}
movl f,%ebx
movl (%ebx),%ebx
@ -272,6 +273,7 @@ begin
movl %edx,(%ebx)
xorb %ah,%ah
movw %ax,doserror
popl %ebx
end;
end;
@ -282,26 +284,27 @@ var FStat: PFileStatus3;
begin
if os_mode = osOS2 then
begin
New (FStat);
RC := DosQueryFileInfo (FileRec (F).Handle, ilStandard, FStat,
SizeOf (FStat^));
if RC = 0 then
begin
FStat^.DateLastAccess := Hi (Time);
FStat^.DateLastWrite := Hi (Time);
FStat^.TimeLastAccess := Lo (Time);
FStat^.TimeLastWrite := Lo (Time);
RC := DosSetFileInfo (FileRec (F).Handle, ilStandard,
FStat, SizeOf (FStat^));
begin
New (FStat);
RC := DosQueryFileInfo (FileRec (F).Handle, ilStandard, FStat,
SizeOf (FStat^));
if RC = 0 then
begin
FStat^.DateLastAccess := Hi (Time);
FStat^.DateLastWrite := Hi (Time);
FStat^.TimeLastAccess := Lo (Time);
FStat^.TimeLastWrite := Lo (Time);
RC := DosSetFileInfo (FileRec (F).Handle, ilStandard,
FStat, SizeOf (FStat^));
end;
DosError := integer(RC);
Dispose (FStat);
end;
DosError := integer(RC);
Dispose (FStat);
end
else
asm
pushl %ebx
{Load handle}
movl f,%ebx
movl (%ebx),%ebx
@ -312,6 +315,7 @@ begin
call syscall
xorb %ah,%ah
movw %ax,doserror
popl %ebx
end;
end;
@ -388,7 +392,7 @@ begin
popl %ebx {Flags.}
movl %ebx,32(%eax)
{FS and GS too}
end;
end ['eax','ebx','ecx','edx','esi','edi'];
end;
procedure exec(const path:pathstr;const comline:comstr);
@ -498,7 +502,7 @@ begin
stosb {Store an extra 0 to finish. (AL is now 0).}
incl %edx
movw %dx,ES.SizeEnv {Store environment size.}
end;
end ['eax','ebx','ecx','edx','esi','edi'];
{Environment ready, now set-up exec structure.}
es.argofs:=args;
@ -580,12 +584,12 @@ procedure SetDate (Year, Month, Day: word);
var DT: TDateTime;
begin
if os_mode = osOS2 then
begin
DosGetDateTime (DT);
DT.Year := Year;
DT.Month := byte (Month);
DT.Day := byte (Day);
DosSetDateTime (DT);
begin
DosGetDateTime (DT);
DT.Year := Year;
DT.Month := byte (Month);
DT.Day := byte (Day);
DosSetDateTime (DT);
end
else
asm
@ -623,13 +627,13 @@ procedure SetTime (Hour, Minute, Second, Sec100: word);
var DT: TDateTime;
begin
if os_mode = osOS2 then
begin
DosGetDateTime (DT);
DT.Hour := byte (Hour);
DT.Minute := byte (Minute);
DT.Second := byte (Second);
DT.Sec100 := byte (Sec100);
DosSetDateTime (DT);
begin
DosGetDateTime (DT);
DT.Hour := byte (Hour);
DT.Minute := byte (Minute);
DT.Second := byte (Second);
DT.Sec100 := byte (Sec100);
DosSetDateTime (DT);
end
else
asm
@ -647,7 +651,7 @@ end;
procedure getcbreak(var breakvalue:boolean);
begin
breakvalue := True;
breakvalue := True;
end;
procedure setcbreak(breakvalue:boolean);
@ -675,8 +679,8 @@ begin
stosb
end
else
verify := true;
end;
verify := true;
end;
procedure setverify(verify:boolean);
@ -700,6 +704,7 @@ begin
if (os_mode = osDOS) or (os_mode = osDPMI) then
{Function 36 is not supported in OS/2.}
asm
pushl %ebx
movb Drive,%dl
movb $0x36,%ah
call syscall
@ -711,23 +716,24 @@ begin
movw %ax,%dx
movl $0,%eax
xchgl %edx,%eax
leave
ret
jmp .LDISKFREE2
.LDISKFREE1:
cltd
.LDISKFREE2:
popl %ebx
leave
ret
end
else
{In OS/2, we use the filesystem information.}
begin
RC := DosQueryFSInfo (Drive, 1, FI, SizeOf (FI));
if RC = 0 then
DiskFree := int64 (FI.Free_Clusters) *
int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
else
DiskFree := -1;
end;
RC := DosQueryFSInfo (Drive, 1, FI, SizeOf (FI));
if RC = 0 then
DiskFree := int64 (FI.Free_Clusters) *
int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
else
DiskFree := -1;
end;
end;
function DiskSize (Drive: byte): int64;
@ -739,6 +745,7 @@ begin
if (os_mode = osDOS) or (os_mode = osDPMI) then
{Function 36 is not supported in OS/2.}
asm
pushl %ebx
movb Drive,%dl
movb $0x36,%ah
call syscall
@ -751,23 +758,24 @@ begin
movw %ax,%dx
movl $0,%eax
xchgl %edx,%eax
leave
ret
jmp .LDISKSIZE2
.LDISKSIZE1:
cltd
.LDISKSIZE2:
popl %ebx
leave
ret
end
else
{In OS/2, we use the filesystem information.}
begin
RC := DosQueryFSinfo (Drive, 1, FI, SizeOf (FI));
if RC = 0 then
DiskSize := int64 (FI.Total_Clusters) *
int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
else
DiskSize := -1;
end;
begin
RC := DosQueryFSinfo (Drive, 1, FI, SizeOf (FI));
if RC = 0 then
DiskSize := int64 (FI.Total_Clusters) *
int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector)
else
DiskSize := -1;
end;
end;
@ -799,8 +807,8 @@ const NameSize=255;
var L, I: longint;
type TRec = record
T, D: word;
end;
T, D: word;
end;
begin
if os_mode = osOS2 then with F do
@ -850,17 +858,17 @@ var path0: array[0..255] of char;
Count: cardinal;
begin
{No error.}
DosError := 0;
{No error.}
DosError := 0;
if os_mode = osOS2 then
begin
New (F.FStat);
F.Handle := longint ($FFFFFFFF);
Count := 1;
DosError := integer (DosFindFirst (Path, F.Handle,
Attr and FindResvdMask, F.FStat, SizeOf (F.FStat^),
Count, ilStandard));
if (DosError = 0) and (Count = 0) then DosError := 18;
New (F.FStat);
F.Handle := longint ($FFFFFFFF);
Count := 1;
DosError := integer (DosFindFirst (Path, F.Handle,
Attr and FindResvdMask, F.FStat, SizeOf (F.FStat^),
Count, ilStandard));
if (DosError = 0) and (Count = 0) then DosError := 18;
end else
begin
strPcopy(path0,path);
@ -905,9 +913,9 @@ procedure FindClose (var F: SearchRec);
begin
if os_mode = osOS2 then
begin
if F.Handle <> $FFFFFFFF then DosError := DosFindClose (F.Handle);
Dispose (F.FStat);
end;
if F.Handle <> $FFFFFFFF then DosError := DosFindClose (F.Handle);
Dispose (F.FStat);
end;
end;
procedure swapvectors;
@ -988,7 +996,7 @@ begin
pop eax
mov P, edi { place pointer to variable contents in P }
@End:
end;
end ['eax','ebx','ecx','edx','esi','edi'];
GetEnvPChar := P;
end;
{$ASMMODE ATT}
@ -1115,6 +1123,7 @@ begin
move(path[1],buffer,length(path));
buffer[length(path)]:=#0;
asm
pushl %ebx
movw $0x4300,%ax
leal buffer,%edx
call syscall
@ -1123,6 +1132,7 @@ begin
.Lnoerror:
movl attr,%ebx
movw %cx,(%ebx)
popl %ebx
end;
end;
@ -1139,7 +1149,7 @@ begin
DosError := 0;
path := StrPas(filerec(f).Name);
{ Takes care of slash and backslash support }
path:=FExPand(path);
path:=FExpand(path);
move(path[1],buffer,length(path));
buffer[length(path)]:=#0;
asm
@ -1222,7 +1232,10 @@ begin
end.
{
$Log$
Revision 1.4 2003-06-26 17:12:29 yuri
Revision 1.5 2003-10-04 17:53:08 hajny
* stdcall changes merged to EMX
Revision 1.4 2003/06/26 17:12:29 yuri
* pmbidi added
* some cosmetic changes

View File

@ -18,22 +18,6 @@
unit {$ifdef VER1_0}sysemx{$else}System{$endif};
{Changelog:
People:
DM - Daniel Mantione
Date: Description of change: Changed by:
- First released version 0.1. DM
Coding style:
My coding style is a bit unusual for Pascal. Nevertheless I friendly ask
you to try to make your changes not look all to different. In general,
set your IDE to use a tabsize of 4.}
interface
{Link the startup code.}
@ -360,12 +344,14 @@ begin
((os_MODE = osOS2) and (h > 2)) then
begin
asm
pushl %ebx
movb $0x3e,%ah
movl h,%ebx
call syscall
jnc .Lnoerror { error code? }
movw %ax, InOutRes { yes, then set InOutRes }
.Lnoerror:
popl %ebx
end;
end;
end;
@ -390,6 +376,7 @@ begin
allowslash(p1);
allowslash(p2);
asm
pushl %edi
movl P1, %edx
movl P2, %edi
movb $0x56,%ah
@ -397,11 +384,13 @@ begin
jnc .LRENAME1
movw %ax,inoutres;
.LRENAME1:
popl %edi
end;
end;
function do_read(h,addr,len:longint):longint; assembler;
asm
pushl %ebx
movl len,%ecx
movl addr,%edx
movl h,%ebx
@ -411,10 +400,12 @@ asm
movw %ax,inoutres;
xorl %eax,%eax
.LDOSREAD1:
popl %ebx
end;
function do_write(h,addr,len:longint) : longint; assembler;
asm
pushl %ebx
xorl %eax,%eax
cmpl $0,len { 0 bytes to write is undefined behavior }
jz .LDOSWRITE1
@ -426,10 +417,12 @@ asm
jnc .LDOSWRITE1
movw %ax,inoutres;
.LDOSWRITE1:
popl %ebx
end;
function do_filepos(handle:longint): longint; assembler;
asm
pushl %ebx
movw $0x4201,%ax
movl handle,%ebx
xorl %edx,%edx
@ -438,10 +431,12 @@ asm
movw %ax,inoutres;
xorl %eax,%eax
.LDOSFILEPOS:
popl %ebx
end;
procedure do_seek(handle,pos:longint); assembler;
asm
pushl %ebx
movw $0x4200,%ax
movl handle,%ebx
movl pos,%edx
@ -449,10 +444,12 @@ asm
jnc .LDOSSEEK1
movw %ax,inoutres;
.LDOSSEEK1:
popl %ebx
end;
function do_seekend(handle:longint):longint; assembler;
asm
pushl %ebx
movw $0x4202,%ax
movl handle,%ebx
xorl %edx,%edx
@ -461,6 +458,7 @@ asm
movw %ax,inoutres;
xorl %eax,%eax
.Lset_at_end1:
popl %ebx
end;
function do_filesize(handle:longint):longint;
@ -475,6 +473,7 @@ end;
procedure do_truncate(handle,pos:longint); assembler;
asm
pushl %ebx
(* DOS function 40h isn't safe for this according to EMX documentation *)
movl $0x7F25,%eax
movl Handle,%ebx
@ -492,6 +491,7 @@ asm
.LTruncate1:
movw %ax,inoutres;
.LTruncate2:
popl %ebx
end;
const
@ -520,12 +520,14 @@ begin
Inc (FileHandleCount, 10);
Err := 0;
asm
pushl %ebx
movl $0x6700, %eax
movl FileHandleCount, %ebx
call syscall
jnc .LIncFHandles
movw %ax, Err
.LIncFHandles:
popl %ebx
end;
if Err <> 0 then
begin
@ -647,6 +649,7 @@ begin
else
*)
asm
push ebx
mov ebx, Handle
mov eax, 4400h
call syscall
@ -656,6 +659,7 @@ asm
jnz @IsDevEnd
dec eax { nope, so result is zero }
@IsDevEnd:
pop ebx
end;
{$ASMMODE ATT}
@ -833,7 +837,7 @@ begin
jz @LCHDIR
mov InOutRes, 15
@LCHDIR:
end;
end ['eax','edx','esi'];
if (Length (S) > 2) and (InOutRes <> 0) then
{ Under EMX 0.9d DOS this routine may sometime }
{ fail or crash the system. }
@ -870,7 +874,7 @@ begin
jnc .LGetDir
movw %ax, InOutRes
.LGetDir:
end;
end [ 'eax','edx','esi'];
{ Now Dir should be filled with directory in ASCIIZ, }
{ starting from dir[4] }
dir[0]:=#3;
@ -1042,7 +1046,7 @@ begin
@Stop:
inc eax
mov EnvSize, eax
end;
end ['eax','ecx','edx','esi','edi'];
Environment := GetMem (EnvSize);
asm
cld
@ -1065,7 +1069,7 @@ begin
jmp @L2
@Stop2:
stosb
end;
end ['eax','ecx','edx','esi','edi'];
end;
@ -1128,6 +1132,7 @@ begin
{Determine the operating system we are running on.}
{$ASMMODE INTEL}
asm
push ebx
mov os_mode, 0
mov eax, 7F0Ah
call syscall
@ -1137,7 +1142,6 @@ begin
jz @noRSX
mov os_mode, 2
@noRSX:
{Enable the brk area by initializing it with the initial heap size.}
mov eax, 7F01h
@ -1165,6 +1169,7 @@ begin
mov edx, 8
call syscall
{$ENDIF CONTHEAP}
pop ebx
end;
{ in OS/2 this will always be nil, but in DOS mode }
@ -1174,6 +1179,7 @@ begin
read-access to the first meg. of memory.}
if os_mode in [osDOS,osDPMI] then
asm
push ebx
mov eax, 7F13h
xor ebx, ebx
mov ecx, 0FFFh
@ -1182,6 +1188,7 @@ begin
jc @endmem
mov first_meg, eax
@endmem:
pop ebx
end
else
begin
@ -1242,7 +1249,10 @@ begin
end.
{
$Log$
Revision 1.8 2003-09-29 18:39:59 hajny
Revision 1.9 2003-10-04 17:53:08 hajny
* stdcall changes merged to EMX
Revision 1.8 2003/09/29 18:39:59 hajny
* append fix applied to GO32v2, OS/2 and EMX
Revision 1.7 2003/09/27 11:52:35 peter

View File

@ -296,6 +296,7 @@ end;
function FileRead (Handle: longint; var Buffer; Count: longint): longint;
assembler;
asm
push ebx
mov eax, 3F00h
mov ebx, Handle
mov ecx, Count
@ -304,12 +305,14 @@ asm
jnc @FReadEnd
mov eax, -1
@FReadEnd:
pop ebx
end;
function FileWrite (Handle: longint; const Buffer; Count: longint): longint;
assembler;
asm
push ebx
mov eax, 4000h
mov ebx, Handle
mov ecx, Count
@ -318,11 +321,13 @@ asm
jnc @FWriteEnd
mov eax, -1
@FWriteEnd:
pop ebx
end;
function FileSeek (Handle, FOffset, Origin: longint): longint; assembler;
asm
push ebx
mov eax, Origin
mov ah, 42h
mov ebx, Handle
@ -331,6 +336,7 @@ asm
jnc @FSeekEnd
mov eax, -1
@FSeekEnd:
pop ebx
end;
Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64;
@ -343,15 +349,18 @@ procedure FileClose (Handle: longint);
begin
if (Handle > 4) or ((os_mode = osOS2) and (Handle > 2)) then
asm
push ebx
mov eax, 3E00h
mov ebx, Handle
call syscall
pop ebx
end;
end;
function FileTruncate (Handle, Size: longint): boolean; assembler;
asm
push ebx
mov eax, 7F25h
mov ebx, Handle
mov edx, Size
@ -365,6 +374,7 @@ asm
jnc @FTruncEnd
dec eax
@FTruncEnd:
pop ebx
end;
@ -533,6 +543,7 @@ end;
function FileGetDate (Handle: longint): longint; assembler;
asm
push ebx
mov ax, 5700h
mov ebx, Handle
call syscall
@ -541,6 +552,7 @@ asm
mov ax, dx
shld eax, ecx, 16
@FGetDateEnd:
pop ebx
end;
@ -572,6 +584,7 @@ begin
end
else
asm
push ebx
mov ax, 5701h
mov ebx, Handle
mov cx, word ptr [Age]
@ -581,6 +594,7 @@ begin
mov eax, -1
@FSetDateEnd:
mov [ebp - 4], eax
pop ebx
end;
end;
@ -679,6 +693,7 @@ begin
FN2 := NewName + #0;
{$ENDIF}
asm
push edi
mov ax, 5600h
{$IFOPT H+}
mov edx, OldName
@ -696,6 +711,7 @@ asm
@FRenameEnd:
{$IFOPT H-}
mov [ebp - 4], eax
pop edi
end;
{$ENDIF}
end;
@ -716,6 +732,7 @@ begin
if (os_mode = osDOS) or (os_mode = osDPMI) then
{Function 36 is not supported in OS/2.}
asm
pushl %ebx
movb Drive,%dl
movb $0x36,%ah
call syscall
@ -727,10 +744,11 @@ begin
movw %ax,%dx
movl $0,%eax
xchgl %edx,%eax
leave
ret
jmp .LDISKFREE2
.LDISKFREE1:
cltd
.LDISKFREE2:
popl %ebx
leave
ret
end
@ -755,6 +773,7 @@ begin
if (os_mode = osDOS) or (os_mode = osDPMI) then
{Function 36 is not supported in OS/2.}
asm
pushl %ebx
movb Drive,%dl
movb $0x36,%ah
call syscall
@ -767,10 +786,11 @@ begin
movw %ax,%dx
movl $0,%eax
xchgl %edx,%eax
leave
ret
.LDISKSIZE1:
jmp .LDISKSIZE2
.LDISKSIZE1:
cltd
.LDISKSIZE2:
popl %ebx
leave
ret
end
@ -856,6 +876,7 @@ end;
procedure GetLocalTime (var SystemTime: TSystemTime); assembler;
asm
push edi
(* Expects the default record alignment (word)!!! *)
mov ah, 2Ah
call syscall
@ -881,6 +902,7 @@ asm
shl eax, 16
mov al, dh
stosd
pop edi
end;
{$asmmode default}
@ -987,7 +1009,10 @@ end.
{
$Log$
Revision 1.8 2003-06-26 17:12:29 yuri
Revision 1.9 2003-10-04 17:53:08 hajny
* stdcall changes merged to EMX
Revision 1.8 2003/06/26 17:12:29 yuri
* pmbidi added
* some cosmetic changes