* stdcall fixes again

This commit is contained in:
Tomas Hajny 2003-10-18 16:58:39 +00:00
parent f659dc38f9
commit c5df303517
3 changed files with 218 additions and 328 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 ['eax', 'ecx', 'edx']; 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 ['eax', 'ecx', 'edx']; 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 ['eax', 'ecx', 'edx']; 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 ['eax', 'ecx', 'edx']; 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 ['eax', 'ecx', 'edx']; 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 ['eax', 'ecx', 'edx']; end {['eax', 'ecx', 'edx']};
end. end.
{ {
$Log$ $Log$
Revision 1.3 2003-10-07 21:26:35 hajny Revision 1.4 2003-10-18 16:58:39 hajny
* stdcall fixes again
Revision 1.3 2003/10/07 21:26:35 hajny
* stdcall fixes and asm routines cleanup * stdcall fixes and asm routines cleanup
Revision 1.2 2002/09/07 16:01:25 peter Revision 1.2 2002/09/07 16:01:25 peter

View File

@ -394,12 +394,12 @@ function paramcount:longint;assembler;
asm asm
movl argc,%eax movl argc,%eax
decl %eax decl %eax
end ['EAX']; end {['EAX']};
function args:pointer;assembler; function args:pointer;assembler;
asm asm
movl argv,%eax movl argv,%eax
end ['EAX']; end {['EAX']};
function paramstr(l:longint):string; function paramstr(l:longint):string;
@ -437,7 +437,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 ['eax', 'ecx', 'edx']; end {['eax', 'ecx', 'edx']};
{$ASMMODE ATT} {$ASMMODE ATT}
@ -483,19 +483,19 @@ asm
jz .LSbrk_End jz .LSbrk_End
dec %eax { No error - back to previous value } dec %eax { No error - back to previous value }
.LSbrk_End: .LSbrk_End:
end ['eax', 'edx']; end {['eax', 'edx']};
{$ENDIF DUMPGROW} {$ENDIF DUMPGROW}
function getheapstart:pointer;assembler; function getheapstart:pointer;assembler;
asm asm
movl heap_base,%eax movl heap_base,%eax
end ['EAX']; end {['EAX']};
function getheapsize:longint;assembler; function getheapsize:longint;assembler;
asm asm
movl heap_brk,%eax movl heap_brk,%eax
end ['EAX']; end {['EAX']};
{$i heap.inc} {$i heap.inc}
@ -550,6 +550,7 @@ 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
@ -559,10 +560,12 @@ asm
movw %ax,inoutres; movw %ax,inoutres;
xorl %eax,%eax xorl %eax,%eax
.LDOSREAD1: .LDOSREAD1:
end ['eax', 'ebx', 'ecx', 'edx']; popl %ebx
end {['eax', 'ebx', 'ecx', 'edx']};
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
@ -574,10 +577,12 @@ asm
jnc .LDOSWRITE1 jnc .LDOSWRITE1
movw %ax,inoutres; movw %ax,inoutres;
.LDOSWRITE1: .LDOSWRITE1:
end ['eax', 'ebx', 'ecx', 'edx']; popl %ebx
end {['eax', 'ebx', 'ecx', 'edx']};
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
@ -586,10 +591,12 @@ asm
movw %ax,inoutres; movw %ax,inoutres;
xorl %eax,%eax xorl %eax,%eax
.LDOSFILEPOS: .LDOSFILEPOS:
end ['eax', 'ebx', 'ecx', 'edx']; popl %ebx
end {['eax', 'ebx', 'ecx', 'edx']};
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
@ -597,10 +604,12 @@ asm
jnc .LDOSSEEK1 jnc .LDOSSEEK1
movw %ax,inoutres; movw %ax,inoutres;
.LDOSSEEK1: .LDOSSEEK1:
end ['eax', 'ebx', 'ecx', 'edx']; popl %ebx
end {['eax', 'ebx', 'ecx', 'edx']};
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
@ -609,7 +618,8 @@ asm
movw %ax,inoutres; movw %ax,inoutres;
xorl %eax,%eax xorl %eax,%eax
.Lset_at_end1: .Lset_at_end1:
end ['eax', 'ebx', 'ecx', 'edx']; popl %ebx
end {['eax', 'ebx', 'ecx', 'edx']};
function do_filesize(handle:longint):longint; function do_filesize(handle:longint):longint;
@ -775,6 +785,7 @@ begin
else else
*) *)
asm asm
push ebx
mov ebx, Handle mov ebx, Handle
mov eax, 4400h mov eax, 4400h
call syscall call syscall
@ -784,7 +795,8 @@ asm
jnz @IsDevEnd jnz @IsDevEnd
dec eax { nope, so result is zero } dec eax { nope, so result is zero }
@IsDevEnd: @IsDevEnd:
end ['eax', 'ebx', 'edx']; pop ebx
end {['eax', 'ebx', 'edx']};
{$ASMMODE ATT} {$ASMMODE ATT}
@ -1165,7 +1177,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.47 2003-10-16 15:43:13 peter Revision 1.48 2003-10-18 16:58:39 hajny
* stdcall fixes again
Revision 1.47 2003/10/16 15:43:13 peter
* THandle is platform dependent * THandle is platform dependent
Revision 1.46 2003/10/14 21:10:06 hajny Revision 1.46 2003/10/14 21:10:06 hajny

View File

@ -25,9 +25,6 @@ interface
uses uses
Dos; Dos;
type
THandle = type Longint;
{ Include platform independent interface part } { Include platform independent interface part }
{$i sysutilh.inc} {$i sysutilh.inc}
@ -231,147 +228,124 @@ const
specification for DosFindFirst call.} specification for DosFindFirst call.}
{$ASMMODE INTEL} {$ASMMODE INTEL}
function FileOpen (const FileName: string; Mode: integer): longint; function FileOpen (const FileName: string; Mode: integer): longint; assembler;
{$IFOPT H+} asm
assembler; push ebx
{$ELSE} mov eax, Mode
var FN: string;
begin
FN := FileName + #0;
{$ENDIF}
asm
mov eax, Mode
(* DenyAll if sharing not specified. *) (* DenyAll if sharing not specified. *)
test eax, 112 test eax, 112
jnz @FOpen1 jnz @FOpen1
or eax, 16 or eax, 16
@FOpen1: @FOpen1:
mov ecx, eax mov ecx, eax
mov eax, 7F2Bh mov eax, 7F2Bh
{$IFOPT H+} mov edx, FileName
mov edx, FileName call syscall
{$ELSE} pop ebx
lea edx, FN end {['eax', 'ebx', 'ecx', 'edx']};
inc edx
{$ENDIF}
call syscall
{$IFOPT H-}
mov Result, eax
{$ENDIF}
end ['eax', 'ebx', 'ecx', 'edx'];
{$IFOPT H-}
end;
{$ENDIF}
function FileCreate (const FileName: string): longint; function FileCreate (const FileName: string): longint; assembler;
{$IFOPT H+} asm
assembler; push ebx
{$ELSE} mov eax, 7F2Bh
var FN: string; mov ecx, ofReadWrite or faCreate or doDenyRW (* Sharing to DenyAll *)
mov edx, FileName
call syscall
pop ebx
end {['eax', 'ebx', 'ecx', 'edx']};
function FileCreate (const FileName: string; Mode: longint): longint;
begin begin
FN := FileName + #0; FileCreate := FileCreate(FileName);
{$ENDIF}
asm
mov eax, 7F2Bh
mov ecx, ofReadWrite or faCreate or doDenyRW (* Sharing to DenyAll *)
{$IFOPT H+}
mov edx, FileName
{$ELSE}
lea edx, FN
inc edx
{$ENDIF}
call syscall
{$IFOPT H-}
mov Result, eax
{$ENDIF}
end ['eax', 'ebx', 'ecx', 'edx'];
{$IFOPT H-}
end;
{$ENDIF}
Function FileCreate (Const FileName : String; Mode:longint) : Longint;
begin
FileCreate:=FileCreate(FileName);
end; end;
function FileRead (Handle: longint; var Buffer; Count: longint): longint; function FileRead (Handle: longint; var Buffer; Count: longint): longint;
assembler; assembler;
asm asm
mov eax, 3F00h push ebx
mov ebx, Handle mov eax, 3F00h
mov ecx, Count mov ebx, Handle
mov edx, Buffer mov ecx, Count
call syscall mov edx, Buffer
jnc @FReadEnd call syscall
mov eax, -1 jnc @FReadEnd
mov eax, -1
@FReadEnd: @FReadEnd:
end ['eax', 'ebx', 'ecx', 'edx']; pop ebx
end {['eax', 'ebx', 'ecx', 'edx']};
function FileWrite (Handle: longint; const Buffer; Count: longint): longint; function FileWrite (Handle: longint; const Buffer; Count: longint): longint;
assembler; assembler;
asm asm
mov eax, 4000h push ebx
mov ebx, Handle mov eax, 4000h
mov ecx, Count mov ebx, Handle
mov edx, Buffer mov ecx, Count
call syscall mov edx, Buffer
jnc @FWriteEnd call syscall
mov eax, -1 jnc @FWriteEnd
mov eax, -1
@FWriteEnd: @FWriteEnd:
end ['eax', 'ebx', 'ecx', 'edx']; pop ebx
end {['eax', 'ebx', 'ecx', 'edx']};
function FileSeek (Handle, FOffset, Origin: longint): longint; assembler; function FileSeek (Handle, FOffset, Origin: longint): longint; assembler;
asm asm
mov eax, Origin push ebx
mov ah, 42h mov eax, Origin
mov ebx, Handle mov ah, 42h
mov edx, FOffset mov ebx, Handle
call syscall mov edx, FOffset
jnc @FSeekEnd call syscall
mov eax, -1 jnc @FSeekEnd
mov eax, -1
@FSeekEnd: @FSeekEnd:
end ['eax', 'ebx', 'edx']; pop ebx
end {['eax', 'ebx', 'edx']};
Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64; function FileSeek (Handle: longint; FOffset, Origin: Int64): Int64;
begin begin
{$warning need to add 64bit call } {$warning need to add 64bit call }
Result:=FileSeek(Handle,Longint(Foffset),Longint(Origin)); Result:=FileSeek(Handle,Longint(Foffset),Longint(Origin));
end; end;
procedure FileClose (Handle: longint); procedure FileClose (Handle: longint); assembler;
begin asm
if Handle > 2 then push ebx
asm mov eax, Handle
push ebx cmp eax, 2
mov eax, 3E00h jbe @FCloseEnd
mov ebx, Handle mov ebx, eax
call syscall mov eax, 3E00h
pop ebx call syscall
end ['eax']; @FCloseEnd:
end; pop ebx
end {['eax', 'ebx']};
function FileTruncate (Handle, Size: longint): boolean; assembler; function FileTruncate (Handle, Size: longint): boolean; assembler;
asm asm
mov eax, 7F25h push ebx
mov ebx, Handle mov eax, 7F25h
mov edx, Size mov ebx, Handle
call syscall mov edx, Size
jc @FTruncEnd call syscall
mov eax, 4202h jc @FTruncEnd
mov ebx, Handle mov eax, 4202h
mov edx, 0 mov ebx, Handle
call syscall mov edx, 0
mov eax, 0 call syscall
jnc @FTruncEnd mov eax, 0
dec eax jnc @FTruncEnd
dec eax
@FTruncEnd: @FTruncEnd:
end ['eax', 'ebx', 'ecx', 'edx']; pop ebx
end {['eax', 'ebx', 'ecx', 'edx']};
function FileAge (const FileName: string): longint; function FileAge (const FileName: string): longint;
@ -388,36 +362,18 @@ begin
end; end;
function FileExists (const FileName: string): boolean; function FileExists (const FileName: string): boolean; assembler;
{$IFOPT H+}
assembler;
{$ELSE}
var FN: string;
begin
FN := FileName + #0;
{$ENDIF}
asm asm
mov ax, 4300h mov ax, 4300h
{$IFOPT H+} mov edx, FileName
mov edx, FileName call syscall
{$ELSE} mov eax, 0
lea edx, FN jc @FExistsEnd
inc edx test cx, 18h
{$ENDIF} jnz @FExistsEnd
call syscall inc eax
mov eax, 0
jc @FExistsEnd
test cx, 18h
jnz @FExistsEnd
inc eax
@FExistsEnd: @FExistsEnd:
{$IFOPT H-} end {['eax', 'ecx', 'edx']};
mov Result, eax
{$ENDIF}
end ['eax', 'ecx', 'edx'];
{$IFOPT H-}
end;
{$ENDIF}
type TRec = record type TRec = record
@ -493,15 +449,17 @@ end;
function FileGetDate (Handle: longint): longint; assembler; function FileGetDate (Handle: longint): longint; assembler;
asm asm
mov ax, 5700h push ebx
mov ebx, Handle mov ax, 5700h
call syscall mov ebx, Handle
mov eax, -1 call syscall
jc @FGetDateEnd mov eax, -1
mov ax, dx jc @FGetDateEnd
shld eax, ecx, 16 mov ax, dx
shld eax, ecx, 16
@FGetDateEnd: @FGetDateEnd:
end ['eax', 'ebx', 'ecx', 'edx']; pop ebx
end {['eax', 'ebx', 'ecx', 'edx']};
function FileSetDate (Handle, Age: longint): longint; function FileSetDate (Handle, Age: longint): longint;
@ -530,128 +488,55 @@ begin
end; end;
function FileGetAttr (const FileName: string): longint; function FileGetAttr (const FileName: string): longint; assembler;
{$IFOPT H+}
assembler;
{$ELSE}
var FN: string;
begin
FN := FileName + #0;
{$ENDIF}
asm asm
mov ax, 4300h mov ax, 4300h
{$IFOPT H+} mov edx, FileName
mov edx, FileName call syscall
{$ELSE} jnc @FGetAttrEnd
lea edx, FN mov eax, -1
inc edx
{$ENDIF}
call syscall
jnc @FGetAttrEnd
mov eax, -1
@FGetAttrEnd: @FGetAttrEnd:
{$IFOPT H-} end {['eax', 'edx']};
mov Result, eax
{$ENDIF}
end ['eax', 'edx'];
{$IFOPT H-}
end;
{$ENDIF}
function FileSetAttr (const Filename: string; Attr: longint): longint; function FileSetAttr (const Filename: string; Attr: longint): longint; assembler;
{$IFOPT H+}
assembler;
{$ELSE}
var FN: string;
begin
FN := FileName + #0;
{$ENDIF}
asm asm
mov ax, 4301h mov ax, 4301h
mov ecx, Attr mov ecx, Attr
{$IFOPT H+} mov edx, FileName
mov edx, FileName call syscall
{$ELSE} mov eax, 0
lea edx, FN jnc @FSetAttrEnd
inc edx mov eax, -1
{$ENDIF}
call syscall
mov eax, 0
jnc @FSetAttrEnd
mov eax, -1
@FSetAttrEnd: @FSetAttrEnd:
{$IFOPT H-} end {['eax', 'ecx', 'edx']};
mov Result, eax
{$ENDIF}
end ['eax', 'ecx', 'edx'];
{$IFOPT H-}
end;
{$ENDIF}
function DeleteFile (const FileName: string): boolean; function DeleteFile (const FileName: string): boolean; assembler;
{$IFOPT H+}
assembler;
{$ELSE}
var FN: string;
begin
FN := FileName + #0;
{$ENDIF}
asm asm
mov ax, 4100h mov ax, 4100h
{$IFOPT H+} mov edx, FileName
mov edx, FileName call syscall
{$ELSE} mov eax, 0
lea edx, FN jc @FDeleteEnd
inc edx inc eax
{$ENDIF}
call syscall
mov eax, 0
jc @FDeleteEnd
inc eax
@FDeleteEnd: @FDeleteEnd:
{$IFOPT H-} end {['eax', 'edx']};
mov Result, eax
{$ENDIF}
end ['eax', 'edx'];
{$IFOPT H-}
end;
{$ENDIF}
function RenameFile (const OldName, NewName: string): boolean; function RenameFile (const OldName, NewName: string): boolean; assembler;
{$IFOPT H+}
assembler;
{$ELSE}
var FN1, FN2: string;
begin
FN1 := OldName + #0;
FN2 := NewName + #0;
{$ENDIF}
asm asm
mov ax, 5600h push edi
{$IFOPT H+} mov ax, 5600h
mov edx, OldName mov edx, OldName
mov edi, NewName mov edi, NewName
{$ELSE} call syscall
lea edx, FN1 mov eax, 0
inc edx jc @FRenameEnd
lea edi, FN2 inc eax
inc edi
{$ENDIF}
call syscall
mov eax, 0
jc @FRenameEnd
inc eax
@FRenameEnd: @FRenameEnd:
{$IFOPT H-} pop edi
mov Result, eax end {['eax', 'edx', 'edi']};
{$ENDIF}
end ['eax', 'edx', 'edi'];
{$IFOPT H-}
end;
{$ENDIF}
{**************************************************************************** {****************************************************************************
@ -725,36 +610,18 @@ end;
{$ASMMODE INTEL} {$ASMMODE INTEL}
function DirectoryExists (const Directory: string): boolean; function DirectoryExists (const Directory: string): boolean; assembler;
{$IFOPT H+}
assembler;
{$ELSE}
var FN: string;
begin
FN := Directory + #0;
{$ENDIF}
asm asm
mov ax, 4300h mov ax, 4300h
{$IFOPT H+} mov edx, Directory
mov edx, Directory call syscall
{$ELSE} mov eax, 0
lea edx, FN jc @FExistsEnd
inc edx test cx, 10h
{$ENDIF} jz @FExistsEnd
call syscall inc eax
mov eax, 0
jc @FExistsEnd
test cx, 10h
jz @FExistsEnd
inc eax
@FExistsEnd: @FExistsEnd:
{$IFOPT H-} end {['eax', 'ecx', 'edx']};
mov Result, eax
{$ENDIF}
end ['eax', 'ecx', 'edx'];
{$IFOPT H-}
end;
{$ENDIF}
{**************************************************************************** {****************************************************************************
@ -764,31 +631,33 @@ end;
procedure GetLocalTime (var SystemTime: TSystemTime); assembler; procedure GetLocalTime (var SystemTime: TSystemTime); assembler;
asm asm
(* Expects the default record alignment (word)!!! *) (* Expects the default record alignment (word)!!! *)
mov ah, 2Ah push edi
call syscall mov ah, 2Ah
mov edi, SystemTime call syscall
mov ax, cx mov edi, SystemTime
stosw mov ax, cx
xor eax, eax stosw
mov al, 10 xor eax, eax
mul dl mov al, 10
shl eax, 16 mul dl
mov al, dh shl eax, 16
stosd mov al, dh
push edi stosd
mov ah, 2Ch push edi
call syscall mov ah, 2Ch
pop edi call syscall
xor eax, eax pop edi
mov al, cl xor eax, eax
shl eax, 16 mov al, cl
mov al, ch shl eax, 16
stosd mov al, ch
mov al, dl stosd
shl eax, 16 mov al, dl
mov al, dh shl eax, 16
stosd mov al, dh
end ['eax', 'ecx', 'edx', 'edi']; stosd
pop edi
end {['eax', 'ecx', 'edx', 'edi']};
{$asmmode default} {$asmmode default}
{**************************************************************************** {****************************************************************************
@ -886,7 +755,10 @@ end.
{ {
$Log$ $Log$
Revision 1.33 2003-10-13 21:17:31 hajny Revision 1.34 2003-10-18 16:58:39 hajny
* stdcall fixes again
Revision 1.33 2003/10/13 21:17:31 hajny
* longint to cardinal corrections * longint to cardinal corrections
Revision 1.32 2003/10/08 05:22:47 yuri Revision 1.32 2003/10/08 05:22:47 yuri