* stdcall fixes and asm routines cleanup

This commit is contained in:
Tomas Hajny 2003-10-07 21:26:34 +00:00
parent e720d73bd9
commit b5ac7cde64
5 changed files with 131 additions and 120 deletions

View File

@ -83,7 +83,7 @@ asm
movw P, %dx movw P, %dx
movb Data, %al movb Data, %al
outb %al, %dx outb %al, %dx
end; end ['eax', 'ecx', 'edx'];
function TPort.ReadPort (P: word): byte; assembler; function TPort.ReadPort (P: word): byte; assembler;
asm asm
@ -94,7 +94,7 @@ asm
call syscall call syscall
movw P, %dx movw P, %dx
inb %dx, %al inb %dx, %al
end; end ['eax', 'ecx', 'edx'];
procedure TPortW.WritePort (P: word; Data : word); assembler; procedure TPortW.WritePort (P: word; Data : word); assembler;
asm asm
@ -106,7 +106,7 @@ asm
movw P, %dx movw P, %dx
movw Data, %ax movw Data, %ax
outw %ax, %dx outw %ax, %dx
end; end ['eax', 'ecx', 'edx'];
function TPortW.ReadPort (P: word): word; assembler; function TPortW.ReadPort (P: word): word; assembler;
asm asm
@ -117,7 +117,7 @@ asm
call syscall call syscall
movw P, %dx movw P, %dx
inw %dx, %ax inw %dx, %ax
end; end ['eax', 'ecx', 'edx'];
procedure TPortL.WritePort (P: word; Data: longint); assembler; procedure TPortL.WritePort (P: word; Data: longint); assembler;
asm asm
@ -129,7 +129,7 @@ asm
movw P, %dx movw P, %dx
movl Data, %eax movl Data, %eax
outl %eax, %dx outl %eax, %dx
end; end ['eax', 'ecx', 'edx'];
function TPortL.ReadPort (P: word): longint; assembler; function TPortL.ReadPort (P: word): longint; assembler;
asm asm
@ -140,13 +140,16 @@ asm
call syscall call syscall
movw P, %dx movw P, %dx
inl %dx, %eax inl %dx, %eax
end; end ['eax', 'ecx', 'edx'];
end. end.
{ {
$Log$ $Log$
Revision 1.2 2002-09-07 16:01:25 peter Revision 1.3 2003-10-07 21:26:35 hajny
* stdcall fixes and asm routines cleanup
Revision 1.2 2002/09/07 16:01:25 peter
* old logs removed and tabs fixed * old logs removed and tabs fixed
} }

View File

@ -413,7 +413,7 @@ begin
mov ecx, 260 mov ecx, 260
mov eax, 7F33h mov eax, 7F33h
call syscall { error handle already with empty string } call syscall { error handle already with empty string }
end; end ['eax', 'ecx', 'edx'];
ParamStr := StrPas (PChar (P)); ParamStr := StrPas (PChar (P));
FreeMem (P, 260); FreeMem (P, 260);
end end
@ -433,7 +433,7 @@ asm
call syscall call syscall
mov word ptr [randseed], cx mov word ptr [randseed], cx
mov word ptr [randseed + 2], dx mov word ptr [randseed + 2], dx
end; end ['eax', 'ecx', 'edx'];
{$ASMMODE ATT} {$ASMMODE ATT}
@ -461,7 +461,7 @@ begin
movw $0x7f00,%ax movw $0x7f00,%ax
call syscall { result directly in EAX } call syscall { result directly in EAX }
mov %eax,L mov %eax,L
end; end ['eax', 'edx'];
WriteLn ('New heap at ', L); WriteLn ('New heap at ', L);
Sbrk := pointer(L); Sbrk := pointer(L);
end; end;
@ -471,7 +471,7 @@ asm
movl size,%edx movl size,%edx
movw $0x7f00,%ax movw $0x7f00,%ax
call syscall { result directly in EAX } call syscall { result directly in EAX }
end; end ['eax', 'edx'];
{$ENDIF DUMPGROW} {$ENDIF DUMPGROW}
function getheapstart:pointer;assembler; function getheapstart:pointer;assembler;
@ -519,7 +519,7 @@ begin
movw %ax, InOutRes { yes, then set InOutRes } movw %ax, InOutRes { yes, then set InOutRes }
.Lnoerror: .Lnoerror:
popl %ebx popl %ebx
end; end ['eax'];
end; end;
end; end;
@ -538,7 +538,6 @@ end;
function do_read(h,addr,len:longint):longint; assembler; function do_read(h,addr,len:longint):longint; assembler;
asm asm
pushl %ebx
movl len,%ecx movl len,%ecx
movl addr,%edx movl addr,%edx
movl h,%ebx movl h,%ebx
@ -548,12 +547,10 @@ asm
movw %ax,inoutres; movw %ax,inoutres;
xorl %eax,%eax xorl %eax,%eax
.LDOSREAD1: .LDOSREAD1:
popl %ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
function do_write(h,addr,len:longint) : longint; assembler; function do_write(h,addr,len:longint) : longint; assembler;
asm asm
pushl %ebx
xorl %eax,%eax xorl %eax,%eax
cmpl $0,len { 0 bytes to write is undefined behavior } cmpl $0,len { 0 bytes to write is undefined behavior }
jz .LDOSWRITE1 jz .LDOSWRITE1
@ -565,12 +562,10 @@ asm
jnc .LDOSWRITE1 jnc .LDOSWRITE1
movw %ax,inoutres; movw %ax,inoutres;
.LDOSWRITE1: .LDOSWRITE1:
popl %ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
function do_filepos(handle:longint): longint; assembler; function do_filepos(handle:longint): longint; assembler;
asm asm
pushl %ebx
movw $0x4201,%ax movw $0x4201,%ax
movl handle,%ebx movl handle,%ebx
xorl %edx,%edx xorl %edx,%edx
@ -579,12 +574,10 @@ asm
movw %ax,inoutres; movw %ax,inoutres;
xorl %eax,%eax xorl %eax,%eax
.LDOSFILEPOS: .LDOSFILEPOS:
popl %ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
procedure do_seek(handle,pos:longint); assembler; procedure do_seek(handle,pos:longint); assembler;
asm asm
pushl %ebx
movw $0x4200,%ax movw $0x4200,%ax
movl handle,%ebx movl handle,%ebx
movl pos,%edx movl pos,%edx
@ -592,12 +585,10 @@ asm
jnc .LDOSSEEK1 jnc .LDOSSEEK1
movw %ax,inoutres; movw %ax,inoutres;
.LDOSSEEK1: .LDOSSEEK1:
popl %ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
function do_seekend(handle:longint):longint; assembler; function do_seekend(handle:longint):longint; assembler;
asm asm
pushl %ebx
movw $0x4202,%ax movw $0x4202,%ax
movl handle,%ebx movl handle,%ebx
xorl %edx,%edx xorl %edx,%edx
@ -606,8 +597,7 @@ asm
movw %ax,inoutres; movw %ax,inoutres;
xorl %eax,%eax xorl %eax,%eax
.Lset_at_end1: .Lset_at_end1:
popl %ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
function do_filesize(handle:longint):longint; function do_filesize(handle:longint):longint;
@ -621,7 +611,6 @@ end;
procedure do_truncate(handle,pos:longint); assembler; procedure do_truncate(handle,pos:longint); assembler;
asm asm
pushl %ebx
(* DOS function 40h isn't safe for this according to EMX documentation *) (* DOS function 40h isn't safe for this according to EMX documentation *)
movl $0x7F25,%eax movl $0x7F25,%eax
movl Handle,%ebx movl Handle,%ebx
@ -639,8 +628,7 @@ asm
.LTruncate1: .LTruncate1:
movw %ax,inoutres; movw %ax,inoutres;
.LTruncate2: .LTruncate2:
popl %ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
const const
FileHandleCount: longint = 20; FileHandleCount: longint = 20;
@ -722,6 +710,7 @@ begin
if Flags and 112 = 0 then if Flags and 112 = 0 then
Action := Action or 64; Action := Action or 64;
asm asm
pushl %ebx
movl $0x7f2b, %eax movl $0x7f2b, %eax
movl Action, %ecx movl Action, %ecx
movl p, %edx movl p, %edx
@ -733,7 +722,8 @@ begin
.LOPEN1: .LOPEN1:
movl f,%edx { Warning : This assumes Handle is first } movl f,%edx { Warning : This assumes Handle is first }
movw %ax,(%edx) { field of FileRec } movw %ax,(%edx) { field of FileRec }
end; popl %ebx
end ['eax', 'ecx', 'edx'];
if (InOutRes = 4) and Increase_File_Handle_Count then if (InOutRes = 4) and Increase_File_Handle_Count then
(* Trying again after increasing amount of file handles *) (* Trying again after increasing amount of file handles *)
asm asm
@ -748,7 +738,7 @@ begin
.LOPEN2: .LOPEN2:
movl f,%edx movl f,%edx
movw %ax,(%edx) movw %ax,(%edx)
end; end ['eax', 'ecx', 'edx'];
{ for systems that have more handles } { for systems that have more handles }
if FileRec (F).Handle > FileHandleCount then if FileRec (F).Handle > FileHandleCount then
FileHandleCount := FileRec (F).Handle; FileHandleCount := FileRec (F).Handle;
@ -765,10 +755,13 @@ function do_isdevice (Handle: longint): boolean; assembler;
(* (*
var HT, Attr: longint; var HT, Attr: longint;
begin begin
if os_mode = osOS2 then
begin
if DosQueryHType (Handle, HT, Attr) <> 0 then HT := 1; if DosQueryHType (Handle, HT, Attr) <> 0 then HT := 1;
end
else
*) *)
asm asm
push ebx
mov ebx, Handle mov ebx, Handle
mov eax, 4400h mov eax, 4400h
call syscall call syscall
@ -778,8 +771,7 @@ asm
jnz @IsDevEnd jnz @IsDevEnd
dec eax { nope, so result is zero } dec eax { nope, so result is zero }
@IsDevEnd: @IsDevEnd:
pop ebx end ['eax', 'ebx', 'edx'];
end;
{$ASMMODE ATT} {$ASMMODE ATT}
@ -1094,7 +1086,6 @@ begin
os_mode:=OsOs2; os_mode:=OsOs2;
{$ASMMODE INTEL} {$ASMMODE INTEL}
asm asm
push ebx
{Enable the brk area by initializing it with the initial heap size.} {Enable the brk area by initializing it with the initial heap size.}
mov eax, 7F01h mov eax, 7F01h
mov edx, heap_brk mov edx, heap_brk
@ -1121,7 +1112,6 @@ begin
mov edx, 8 mov edx, 8
call syscall call syscall
{$ENDIF CONTHEAP} {$ENDIF CONTHEAP}
pop ebx
end; end;
{Now request, if we are running under DOS, {Now request, if we are running under DOS,
@ -1160,7 +1150,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.39 2003-10-06 16:58:27 yuri Revision 1.40 2003-10-07 21:26:35 hajny
* stdcall fixes and asm routines cleanup
Revision 1.39 2003/10/06 16:58:27 yuri
* Another set of native functions. * Another set of native functions.
Revision 1.38 2003/10/06 14:22:40 yuri Revision 1.38 2003/10/06 14:22:40 yuri

View File

@ -256,10 +256,12 @@ begin
{$ENDIF} {$ENDIF}
call syscall call syscall
{$IFOPT H-} {$IFOPT H-}
mov [ebp - 4], eax mov Result, eax
end;
{$ENDIF} {$ENDIF}
end ['eax', 'ebx', 'ecx', 'edx'];
{$IFOPT H-}
end; end;
{$ENDIF}
function FileCreate (const FileName: string): longint; function FileCreate (const FileName: string): longint;
@ -281,10 +283,12 @@ begin
{$ENDIF} {$ENDIF}
call syscall call syscall
{$IFOPT H-} {$IFOPT H-}
mov [ebp - 4], eax mov Result, eax
end;
{$ENDIF} {$ENDIF}
end ['eax', 'ebx', 'ecx', 'edx'];
{$IFOPT H-}
end; end;
{$ENDIF}
Function FileCreate (Const FileName : String; Mode:longint) : Longint; Function FileCreate (Const FileName : String; Mode:longint) : Longint;
@ -296,7 +300,6 @@ end;
function FileRead (Handle: longint; var Buffer; Count: longint): longint; function FileRead (Handle: longint; var Buffer; Count: longint): longint;
assembler; assembler;
asm asm
push ebx
mov eax, 3F00h mov eax, 3F00h
mov ebx, Handle mov ebx, Handle
mov ecx, Count mov ecx, Count
@ -305,14 +308,12 @@ asm
jnc @FReadEnd jnc @FReadEnd
mov eax, -1 mov eax, -1
@FReadEnd: @FReadEnd:
pop ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
function FileWrite (Handle: longint; const Buffer; Count: longint): longint; function FileWrite (Handle: longint; const Buffer; Count: longint): longint;
assembler; assembler;
asm asm
push ebx
mov eax, 4000h mov eax, 4000h
mov ebx, Handle mov ebx, Handle
mov ecx, Count mov ecx, Count
@ -321,13 +322,11 @@ asm
jnc @FWriteEnd jnc @FWriteEnd
mov eax, -1 mov eax, -1
@FWriteEnd: @FWriteEnd:
pop ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
function FileSeek (Handle, FOffset, Origin: longint): longint; assembler; function FileSeek (Handle, FOffset, Origin: longint): longint; assembler;
asm asm
push ebx
mov eax, Origin mov eax, Origin
mov ah, 42h mov ah, 42h
mov ebx, Handle mov ebx, Handle
@ -336,8 +335,7 @@ asm
jnc @FSeekEnd jnc @FSeekEnd
mov eax, -1 mov eax, -1
@FSeekEnd: @FSeekEnd:
pop ebx end ['eax', 'ebx', 'edx'];
end;
Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64; Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64;
begin begin
@ -354,13 +352,12 @@ begin
mov ebx, Handle mov ebx, Handle
call syscall call syscall
pop ebx pop ebx
end; end ['eax'];
end; end;
function FileTruncate (Handle, Size: longint): boolean; assembler; function FileTruncate (Handle, Size: longint): boolean; assembler;
asm asm
push ebx
mov eax, 7F25h mov eax, 7F25h
mov ebx, Handle mov ebx, Handle
mov edx, Size mov edx, Size
@ -374,8 +371,7 @@ asm
jnc @FTruncEnd jnc @FTruncEnd
dec eax dec eax
@FTruncEnd: @FTruncEnd:
pop ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
function FileAge (const FileName: string): longint; function FileAge (const FileName: string): longint;
@ -415,10 +411,13 @@ asm
jnz @FExistsEnd jnz @FExistsEnd
inc eax inc eax
@FExistsEnd: @FExistsEnd:
{$IFOPT H-}
mov Result, eax
{$ENDIF}
end ['eax', 'ecx', 'edx'];
{$IFOPT H-} {$IFOPT H-}
end; end;
{$ENDIF} {$ENDIF}
end;
type TRec = record type TRec = record
@ -543,7 +542,6 @@ end;
function FileGetDate (Handle: longint): longint; assembler; function FileGetDate (Handle: longint): longint; assembler;
asm asm
push ebx
mov ax, 5700h mov ax, 5700h
mov ebx, Handle mov ebx, Handle
call syscall call syscall
@ -552,8 +550,7 @@ asm
mov ax, dx mov ax, dx
shld eax, ecx, 16 shld eax, ecx, 16
@FGetDateEnd: @FGetDateEnd:
pop ebx end ['eax', 'ebx', 'ecx', 'edx'];
end;
function FileSetDate (Handle, Age: longint): longint; function FileSetDate (Handle, Age: longint): longint;
@ -593,9 +590,9 @@ begin
jnc @FSetDateEnd jnc @FSetDateEnd
mov eax, -1 mov eax, -1
@FSetDateEnd: @FSetDateEnd:
mov [ebp - 4], eax mov Result, eax
pop ebx pop ebx
end; end ['eax', 'ecx', 'edx'];
end; end;
@ -620,10 +617,12 @@ asm
mov eax, -1 mov eax, -1
@FGetAttrEnd: @FGetAttrEnd:
{$IFOPT H-} {$IFOPT H-}
mov [ebp - 4], eax mov Result, eax
{$ENDIF}
end ['eax', 'edx'];
{$IFOPT H-}
end; end;
{$ENDIF} {$ENDIF}
end;
function FileSetAttr (const Filename: string; Attr: longint): longint; function FileSetAttr (const Filename: string; Attr: longint): longint;
@ -649,10 +648,12 @@ asm
mov eax, -1 mov eax, -1
@FSetAttrEnd: @FSetAttrEnd:
{$IFOPT H-} {$IFOPT H-}
mov [ebp - 4], eax mov Result, eax
{$ENDIF}
end ['eax', 'ecx', 'edx'];
{$IFOPT H-}
end; end;
{$ENDIF} {$ENDIF}
end;
function DeleteFile (const FileName: string): boolean; function DeleteFile (const FileName: string): boolean;
@ -677,10 +678,12 @@ asm
inc eax inc eax
@FDeleteEnd: @FDeleteEnd:
{$IFOPT H-} {$IFOPT H-}
mov [ebp - 4], eax mov Result, eax
{$ENDIF}
end ['eax', 'edx'];
{$IFOPT H-}
end; end;
{$ENDIF} {$ENDIF}
end;
function RenameFile (const OldName, NewName: string): boolean; function RenameFile (const OldName, NewName: string): boolean;
@ -693,7 +696,6 @@ begin
FN2 := NewName + #0; FN2 := NewName + #0;
{$ENDIF} {$ENDIF}
asm asm
push edi
mov ax, 5600h mov ax, 5600h
{$IFOPT H+} {$IFOPT H+}
mov edx, OldName mov edx, OldName
@ -710,11 +712,12 @@ asm
inc eax inc eax
@FRenameEnd: @FRenameEnd:
{$IFOPT H-} {$IFOPT H-}
mov [ebp - 4], eax mov Result, eax
pop edi {$ENDIF}
end ['eax', 'edx', 'edi'];
{$IFOPT H-}
end; end;
{$ENDIF} {$ENDIF}
end;
{**************************************************************************** {****************************************************************************
@ -864,10 +867,13 @@ asm
jz @FExistsEnd jz @FExistsEnd
inc eax inc eax
@FExistsEnd: @FExistsEnd:
{$IFOPT H-}
mov Result, eax
{$ENDIF}
end ['eax', 'ecx', 'edx'];
{$IFOPT H-} {$IFOPT H-}
end; end;
{$ENDIF} {$ENDIF}
end;
{**************************************************************************** {****************************************************************************
@ -876,7 +882,6 @@ end;
procedure GetLocalTime (var SystemTime: TSystemTime); assembler; procedure GetLocalTime (var SystemTime: TSystemTime); assembler;
asm asm
push edi
(* Expects the default record alignment (word)!!! *) (* Expects the default record alignment (word)!!! *)
mov ah, 2Ah mov ah, 2Ah
call syscall call syscall
@ -902,11 +907,9 @@ asm
shl eax, 16 shl eax, 16
mov al, dh mov al, dh
stosd stosd
pop edi end ['eax', 'ecx', 'edx', 'edi'];
end;
{$asmmode default} {$asmmode default}
{**************************************************************************** {****************************************************************************
Misc Functions Misc Functions
****************************************************************************} ****************************************************************************}
@ -1009,7 +1012,10 @@ end.
{ {
$Log$ $Log$
Revision 1.30 2003-10-03 21:46:41 peter Revision 1.31 2003-10-07 21:26:34 hajny
* stdcall fixes and asm routines cleanup
Revision 1.30 2003/10/03 21:46:41 peter
* stdcall fixes * stdcall fixes
Revision 1.29 2003/06/06 23:34:40 hajny Revision 1.29 2003/06/06 23:34:40 hajny

View File

@ -189,7 +189,7 @@ begin
mov eax, 7F2Dh mov eax, 7F2Dh
mov edx, ThreadID mov edx, ThreadID
call syscall call syscall
end; end ['eax', 'ecx', 'edx'];
{$ASMMODE DEFAULT} {$ASMMODE DEFAULT}
{$ENDIF EMX} {$ENDIF EMX}
end; end;
@ -237,7 +237,8 @@ begin
mov eax, 7F2Ch mov eax, 7F2Ch
mov edx, ThreadID mov edx, ThreadID
call syscall call syscall
end; {$warning Error checking missing!!}
end ['eax', 'ecx', 'edx'];
{$ASMMODE DEFAULT} {$ASMMODE DEFAULT}
{$ENDIF EMX} {$ENDIF EMX}
end; end;
@ -364,7 +365,10 @@ end;
{ {
$Log$ $Log$
Revision 1.10 2003-02-20 17:09:49 hajny Revision 1.11 2003-10-07 21:26:35 hajny
* stdcall fixes and asm routines cleanup
Revision 1.10 2003/02/20 17:09:49 hajny
* fixes for OS/2 v2.1 incompatibility * fixes for OS/2 v2.1 incompatibility
Revision 1.9 2002/09/07 16:01:25 peter Revision 1.9 2002/09/07 16:01:25 peter

View File

@ -356,9 +356,10 @@ var SOfs, CLen: cardinal;
begin begin
if not (Force) then if not (Force) then
asm asm
cld push ebx
push esi push esi
push edi push edi
cld
mov esi, VideoBuf mov esi, VideoBuf
mov edi, OldVideoBuf mov edi, OldVideoBuf
mov eax, VideoBufSize mov eax, VideoBufSize
@ -395,7 +396,8 @@ begin
@no_update: @no_update:
pop edi pop edi
pop esi pop esi
end pop ebx
end ['eax', 'ecx', 'edx']
else else
begin begin
SOfs := 0; SOfs := 0;
@ -468,7 +470,10 @@ end.
{ {
$Log$ $Log$
Revision 1.8 2003-10-03 21:46:41 peter Revision 1.9 2003-10-07 21:26:35 hajny
* stdcall fixes and asm routines cleanup
Revision 1.8 2003/10/03 21:46:41 peter
* stdcall fixes * stdcall fixes
Revision 1.7 2002/09/07 16:01:25 peter Revision 1.7 2002/09/07 16:01:25 peter