mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 14:31:38 +01:00 
			
		
		
		
	* stdcall fixes and asm routines cleanup
This commit is contained in:
		
							parent
							
								
									e720d73bd9
								
							
						
					
					
						commit
						b5ac7cde64
					
				| @ -83,7 +83,7 @@ asm | ||||
|  movw P, %dx | ||||
|  movb Data, %al | ||||
|  outb %al, %dx | ||||
| end; | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| 
 | ||||
| function TPort.ReadPort (P: word): byte; assembler; | ||||
| asm | ||||
| @ -94,7 +94,7 @@ asm | ||||
|  call syscall | ||||
|  movw P, %dx | ||||
|  inb %dx, %al | ||||
| end; | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| 
 | ||||
| procedure TPortW.WritePort (P: word; Data : word); assembler; | ||||
| asm | ||||
| @ -106,7 +106,7 @@ asm | ||||
|  movw P, %dx | ||||
|  movw Data, %ax | ||||
|  outw %ax, %dx | ||||
| end; | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| 
 | ||||
| function TPortW.ReadPort (P: word): word; assembler; | ||||
| asm | ||||
| @ -117,7 +117,7 @@ asm | ||||
|  call syscall | ||||
|  movw P, %dx | ||||
|  inw %dx, %ax | ||||
| end; | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| 
 | ||||
| procedure TPortL.WritePort (P: word; Data: longint); assembler; | ||||
| asm | ||||
| @ -129,7 +129,7 @@ asm | ||||
|  movw P, %dx | ||||
|  movl Data, %eax | ||||
|  outl %eax, %dx | ||||
| end; | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| 
 | ||||
| function TPortL.ReadPort (P: word): longint; assembler; | ||||
| asm | ||||
| @ -140,13 +140,16 @@ asm | ||||
|  call syscall | ||||
|  movw P, %dx | ||||
|  inl %dx, %eax | ||||
| end; | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| 
 | ||||
| end. | ||||
| 
 | ||||
| { | ||||
|   $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 | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -413,7 +413,7 @@ begin | ||||
|       mov ecx, 260 | ||||
|       mov eax, 7F33h | ||||
|       call syscall    { error handle already with empty string } | ||||
|     end; | ||||
|             end ['eax', 'ecx', 'edx']; | ||||
|     ParamStr := StrPas (PChar (P)); | ||||
|     FreeMem (P, 260); | ||||
|   end | ||||
| @ -433,7 +433,7 @@ asm | ||||
|     call syscall | ||||
|     mov word ptr [randseed], cx | ||||
|     mov word ptr [randseed + 2], dx | ||||
| end; | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| 
 | ||||
| {$ASMMODE ATT} | ||||
| 
 | ||||
| @ -461,7 +461,7 @@ begin | ||||
|     movw $0x7f00,%ax | ||||
|     call syscall     { result directly in EAX } | ||||
|     mov  %eax,L | ||||
|   end; | ||||
|   end ['eax', 'edx']; | ||||
|   WriteLn ('New heap at ', L); | ||||
|   Sbrk := pointer(L); | ||||
| end; | ||||
| @ -471,7 +471,7 @@ asm | ||||
|     movl size,%edx | ||||
|     movw $0x7f00,%ax | ||||
|     call syscall     { result directly in EAX } | ||||
| end; | ||||
| end ['eax', 'edx']; | ||||
| {$ENDIF DUMPGROW} | ||||
| 
 | ||||
| function getheapstart:pointer;assembler; | ||||
| @ -519,7 +519,7 @@ begin | ||||
|         movw  %ax, InOutRes       { yes, then set InOutRes } | ||||
|      .Lnoerror: | ||||
|         popl %ebx | ||||
|      end; | ||||
|      end ['eax']; | ||||
|    end; | ||||
| end; | ||||
| 
 | ||||
| @ -538,7 +538,6 @@ end; | ||||
| 
 | ||||
| function do_read(h,addr,len:longint):longint; assembler; | ||||
| asm | ||||
|     pushl %ebx | ||||
|     movl len,%ecx | ||||
|     movl addr,%edx | ||||
|     movl h,%ebx | ||||
| @ -548,12 +547,10 @@ asm | ||||
|     movw %ax,inoutres; | ||||
|     xorl %eax,%eax | ||||
| .LDOSREAD1: | ||||
|     popl %ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| 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 | ||||
| @ -565,12 +562,10 @@ asm | ||||
|     jnc .LDOSWRITE1 | ||||
|     movw %ax,inoutres; | ||||
| .LDOSWRITE1: | ||||
|     popl %ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| function do_filepos(handle:longint): longint; assembler; | ||||
| asm | ||||
|     pushl %ebx | ||||
|     movw $0x4201,%ax | ||||
|     movl handle,%ebx | ||||
|     xorl %edx,%edx | ||||
| @ -579,12 +574,10 @@ asm | ||||
|     movw %ax,inoutres; | ||||
|     xorl %eax,%eax | ||||
| .LDOSFILEPOS: | ||||
|     popl %ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| procedure do_seek(handle,pos:longint); assembler; | ||||
| asm | ||||
|     pushl %ebx | ||||
|     movw $0x4200,%ax | ||||
|     movl handle,%ebx | ||||
|     movl pos,%edx | ||||
| @ -592,12 +585,10 @@ asm | ||||
|     jnc .LDOSSEEK1 | ||||
|     movw %ax,inoutres; | ||||
| .LDOSSEEK1: | ||||
|     popl %ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| function do_seekend(handle:longint):longint; assembler; | ||||
| asm | ||||
|     pushl %ebx | ||||
|     movw $0x4202,%ax | ||||
|     movl handle,%ebx | ||||
|     xorl %edx,%edx | ||||
| @ -606,8 +597,7 @@ asm | ||||
|     movw %ax,inoutres; | ||||
|     xorl %eax,%eax | ||||
| .Lset_at_end1: | ||||
|     popl %ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| function do_filesize(handle:longint):longint; | ||||
| 
 | ||||
| @ -621,7 +611,6 @@ 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 | ||||
| @ -639,8 +628,7 @@ asm | ||||
| .LTruncate1: | ||||
|     movw %ax,inoutres; | ||||
| .LTruncate2: | ||||
|     popl %ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| const | ||||
|     FileHandleCount: longint = 20; | ||||
| @ -722,6 +710,7 @@ begin | ||||
|     if Flags and 112 = 0 then | ||||
|         Action := Action or 64; | ||||
|     asm | ||||
|         pushl %ebx | ||||
|         movl $0x7f2b, %eax | ||||
|         movl Action, %ecx | ||||
|         movl p, %edx | ||||
| @ -733,7 +722,8 @@ begin | ||||
| .LOPEN1: | ||||
|         movl f,%edx         { Warning : This assumes Handle is first } | ||||
|         movw %ax,(%edx)     { field of FileRec                       } | ||||
|     end; | ||||
|         popl %ebx | ||||
|     end ['eax', 'ecx', 'edx']; | ||||
|     if (InOutRes = 4) and Increase_File_Handle_Count then | ||||
| (* Trying again after increasing amount of file handles *) | ||||
|         asm | ||||
| @ -748,7 +738,7 @@ begin | ||||
| .LOPEN2: | ||||
|             movl f,%edx | ||||
|             movw %ax,(%edx) | ||||
|         end; | ||||
|         end ['eax', 'ecx', 'edx']; | ||||
|       { for systems that have more handles } | ||||
|     if FileRec (F).Handle > FileHandleCount then | ||||
|         FileHandleCount := FileRec (F).Handle; | ||||
| @ -765,10 +755,13 @@ function do_isdevice (Handle: longint): boolean; assembler; | ||||
| (* | ||||
| var HT, Attr: longint; | ||||
| begin | ||||
|     if os_mode = osOS2 then | ||||
|         begin | ||||
|   if DosQueryHType (Handle, HT, Attr) <> 0 then HT := 1; | ||||
|         end | ||||
|     else | ||||
| *) | ||||
| asm | ||||
|     push ebx | ||||
|     mov ebx, Handle | ||||
|     mov eax, 4400h | ||||
|     call syscall | ||||
| @ -778,8 +771,7 @@ asm | ||||
|     jnz @IsDevEnd | ||||
|     dec eax                 { nope, so result is zero } | ||||
| @IsDevEnd: | ||||
|     pop ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'edx']; | ||||
| {$ASMMODE ATT} | ||||
| 
 | ||||
| 
 | ||||
| @ -1094,7 +1086,6 @@ begin | ||||
|     os_mode:=OsOs2; | ||||
| {$ASMMODE INTEL} | ||||
|     asm | ||||
|         push ebx | ||||
|     {Enable the brk area by initializing it with the initial heap size.} | ||||
|         mov eax, 7F01h | ||||
|         mov edx, heap_brk | ||||
| @ -1121,7 +1112,6 @@ begin | ||||
|         mov edx, 8 | ||||
|         call syscall | ||||
| {$ENDIF CONTHEAP} | ||||
|         pop ebx | ||||
|     end; | ||||
| 
 | ||||
|     {Now request, if we are running under DOS, | ||||
| @ -1160,7 +1150,10 @@ begin | ||||
| end. | ||||
| { | ||||
|   $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. | ||||
| 
 | ||||
|   Revision 1.38  2003/10/06 14:22:40  yuri | ||||
|  | ||||
| @ -256,10 +256,12 @@ begin | ||||
| {$ENDIF} | ||||
|         call syscall | ||||
| {$IFOPT H-} | ||||
|         mov [ebp - 4], eax | ||||
|     end; | ||||
|         mov Result, eax | ||||
| {$ENDIF} | ||||
|     end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| {$IFOPT H-} | ||||
| end; | ||||
| {$ENDIF} | ||||
| 
 | ||||
| 
 | ||||
| function FileCreate (const FileName: string): longint; | ||||
| @ -281,10 +283,12 @@ begin | ||||
| {$ENDIF} | ||||
|         call syscall | ||||
| {$IFOPT H-} | ||||
|         mov [ebp - 4], eax | ||||
|     end; | ||||
|         mov Result, eax | ||||
| {$ENDIF} | ||||
|     end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| {$IFOPT H-} | ||||
| end; | ||||
| {$ENDIF} | ||||
| 
 | ||||
| 
 | ||||
| Function FileCreate (Const FileName : String; Mode:longint) : Longint; | ||||
| @ -296,7 +300,6 @@ end; | ||||
| function FileRead (Handle: longint; var Buffer; Count: longint): longint; | ||||
|                                                                      assembler; | ||||
| asm | ||||
|     push ebx | ||||
|     mov eax, 3F00h | ||||
|     mov ebx, Handle | ||||
|     mov ecx, Count | ||||
| @ -305,14 +308,12 @@ asm | ||||
|     jnc @FReadEnd | ||||
|     mov eax, -1 | ||||
| @FReadEnd: | ||||
|     pop ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| 
 | ||||
| function FileWrite (Handle: longint; const Buffer; Count: longint): longint; | ||||
|                                                                      assembler; | ||||
| asm | ||||
|     push ebx | ||||
|     mov eax, 4000h | ||||
|     mov ebx, Handle | ||||
|     mov ecx, Count | ||||
| @ -321,13 +322,11 @@ asm | ||||
|     jnc @FWriteEnd | ||||
|     mov eax, -1 | ||||
| @FWriteEnd: | ||||
|     pop ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| 
 | ||||
| function FileSeek (Handle, FOffset, Origin: longint): longint; assembler; | ||||
| asm | ||||
|     push ebx | ||||
|     mov eax, Origin | ||||
|     mov ah, 42h | ||||
|     mov ebx, Handle | ||||
| @ -336,8 +335,7 @@ asm | ||||
|     jnc @FSeekEnd | ||||
|     mov eax, -1 | ||||
| @FSeekEnd: | ||||
|     pop ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'edx']; | ||||
| 
 | ||||
| Function FileSeek (Handle : Longint; FOffset,Origin : Int64) : Int64; | ||||
| begin | ||||
| @ -354,13 +352,12 @@ begin | ||||
|             mov ebx, Handle | ||||
|             call syscall | ||||
|             pop ebx | ||||
|         end; | ||||
|         end ['eax']; | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
| function FileTruncate (Handle, Size: longint): boolean; assembler; | ||||
| asm | ||||
|     push ebx | ||||
|     mov eax, 7F25h | ||||
|     mov ebx, Handle | ||||
|     mov edx, Size | ||||
| @ -374,8 +371,7 @@ asm | ||||
|     jnc @FTruncEnd | ||||
|     dec eax | ||||
| @FTruncEnd: | ||||
|     pop ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| 
 | ||||
| function FileAge (const FileName: string): longint; | ||||
| @ -415,10 +411,13 @@ asm | ||||
|     jnz @FExistsEnd | ||||
|     inc eax | ||||
| @FExistsEnd: | ||||
| {$IFOPT H-} | ||||
|     mov Result, eax | ||||
| {$ENDIF} | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| {$IFOPT H-} | ||||
| end; | ||||
| {$ENDIF} | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
| type    TRec = record | ||||
| @ -543,7 +542,6 @@ end; | ||||
| 
 | ||||
| function FileGetDate (Handle: longint): longint; assembler; | ||||
| asm | ||||
|     push ebx | ||||
|     mov ax, 5700h | ||||
|     mov ebx, Handle | ||||
|     call syscall | ||||
| @ -552,8 +550,7 @@ asm | ||||
|     mov ax, dx | ||||
|     shld eax, ecx, 16 | ||||
| @FGetDateEnd: | ||||
|     pop ebx | ||||
| end; | ||||
| end ['eax', 'ebx', 'ecx', 'edx']; | ||||
| 
 | ||||
| 
 | ||||
| function FileSetDate (Handle, Age: longint): longint; | ||||
| @ -593,9 +590,9 @@ begin | ||||
|             jnc @FSetDateEnd | ||||
|             mov eax, -1 | ||||
| @FSetDateEnd: | ||||
|             mov [ebp - 4], eax | ||||
|             mov Result, eax | ||||
|             pop ebx | ||||
|         end; | ||||
|         end ['eax', 'ecx', 'edx']; | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
| @ -620,10 +617,12 @@ asm | ||||
|     mov eax, -1 | ||||
| @FGetAttrEnd: | ||||
| {$IFOPT H-} | ||||
|     mov [ebp - 4], eax | ||||
|     mov Result, eax | ||||
| {$ENDIF} | ||||
|   end ['eax', 'edx']; | ||||
| {$IFOPT H-} | ||||
| end; | ||||
| {$ENDIF} | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
| function FileSetAttr (const Filename: string; Attr: longint): longint; | ||||
| @ -649,10 +648,12 @@ asm | ||||
|     mov eax, -1 | ||||
| @FSetAttrEnd: | ||||
| {$IFOPT H-} | ||||
|     mov [ebp - 4], eax | ||||
|     mov Result, eax | ||||
| {$ENDIF} | ||||
| end ['eax', 'ecx', 'edx']; | ||||
| {$IFOPT H-} | ||||
| end; | ||||
| {$ENDIF} | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
| function DeleteFile (const FileName: string): boolean; | ||||
| @ -677,10 +678,12 @@ asm | ||||
|     inc eax | ||||
| @FDeleteEnd: | ||||
| {$IFOPT H-} | ||||
|     mov [ebp - 4], eax | ||||
|     mov Result, eax | ||||
| {$ENDIF} | ||||
|   end ['eax', 'edx']; | ||||
| {$IFOPT H-} | ||||
| end; | ||||
| {$ENDIF} | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
| function RenameFile (const OldName, NewName: string): boolean; | ||||
| @ -693,7 +696,6 @@ begin | ||||
|     FN2 := NewName + #0; | ||||
| {$ENDIF} | ||||
| asm | ||||
|     push edi | ||||
|     mov ax, 5600h | ||||
| {$IFOPT H+} | ||||
|     mov edx, OldName | ||||
| @ -710,11 +712,12 @@ asm | ||||
|     inc eax | ||||
| @FRenameEnd: | ||||
| {$IFOPT H-} | ||||
|     mov [ebp - 4], eax | ||||
|     pop edi | ||||
|     mov Result, eax | ||||
| {$ENDIF} | ||||
|   end ['eax', 'edx', 'edi']; | ||||
| {$IFOPT H-} | ||||
| end; | ||||
| {$ENDIF} | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
| {**************************************************************************** | ||||
| @ -864,10 +867,13 @@ asm | ||||
|     jz @FExistsEnd | ||||
|     inc eax | ||||
| @FExistsEnd: | ||||
| {$IFOPT H-} | ||||
|     mov Result, eax | ||||
| {$ENDIF} | ||||
|   end ['eax', 'ecx', 'edx']; | ||||
| {$IFOPT H-} | ||||
| end; | ||||
| {$ENDIF} | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
| {**************************************************************************** | ||||
| @ -876,7 +882,6 @@ end; | ||||
| 
 | ||||
| procedure GetLocalTime (var SystemTime: TSystemTime); assembler; | ||||
| asm | ||||
|     push edi | ||||
| (* Expects the default record alignment (word)!!! *) | ||||
|     mov ah, 2Ah | ||||
|     call syscall | ||||
| @ -902,11 +907,9 @@ asm | ||||
|     shl eax, 16 | ||||
|     mov al, dh | ||||
|     stosd | ||||
|     pop edi | ||||
| end; | ||||
| end ['eax', 'ecx', 'edx', 'edi']; | ||||
| {$asmmode default} | ||||
| 
 | ||||
| 
 | ||||
| {**************************************************************************** | ||||
|                               Misc Functions | ||||
| ****************************************************************************} | ||||
| @ -1009,7 +1012,10 @@ end. | ||||
| 
 | ||||
| { | ||||
|   $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 | ||||
| 
 | ||||
|   Revision 1.29  2003/06/06 23:34:40  hajny | ||||
|  | ||||
| @ -189,7 +189,7 @@ begin | ||||
|   mov eax, 7F2Dh | ||||
|   mov edx, ThreadID | ||||
|   call syscall | ||||
|  end; | ||||
|  end ['eax', 'ecx', 'edx']; | ||||
| {$ASMMODE DEFAULT} | ||||
| {$ENDIF EMX} | ||||
| end; | ||||
| @ -237,7 +237,8 @@ begin | ||||
|   mov eax, 7F2Ch | ||||
|   mov edx, ThreadID | ||||
|   call syscall | ||||
|  end; | ||||
| {$warning Error checking missing!!} | ||||
|  end ['eax', 'ecx', 'edx']; | ||||
| {$ASMMODE DEFAULT} | ||||
| {$ENDIF EMX} | ||||
| end; | ||||
| @ -364,7 +365,10 @@ end; | ||||
| 
 | ||||
| { | ||||
|   $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 | ||||
| 
 | ||||
|   Revision 1.9  2002/09/07 16:01:25  peter | ||||
|  | ||||
| @ -356,9 +356,10 @@ var SOfs, CLen: cardinal; | ||||
| begin | ||||
|   if not (Force) then | ||||
|     asm | ||||
|     cld | ||||
|       push ebx | ||||
|       push esi | ||||
|       push edi | ||||
|       cld | ||||
|       mov esi, VideoBuf | ||||
|       mov edi, OldVideoBuf | ||||
|       mov eax, VideoBufSize | ||||
| @ -395,7 +396,8 @@ begin | ||||
| @no_update: | ||||
|       pop edi | ||||
|       pop esi | ||||
|     end | ||||
|       pop ebx | ||||
|     end ['eax', 'ecx', 'edx'] | ||||
|   else | ||||
|     begin | ||||
|     SOfs := 0; | ||||
| @ -468,7 +470,10 @@ end. | ||||
| 
 | ||||
| { | ||||
|   $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 | ||||
| 
 | ||||
|   Revision 1.7  2002/09/07 16:01:25  peter | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Tomas Hajny
						Tomas Hajny