2
0
Эх сурвалжийг харах

* stdcall fixes and asm routines cleanup

Tomas Hajny 22 жил өмнө
parent
commit
8ebff2e7fc
4 өөрчлөгдсөн 111 нэмэгдсэн , 104 устгасан
  1. 28 23
      rtl/emx/dos.pas
  2. 10 7
      rtl/emx/ports.pas
  3. 28 36
      rtl/emx/system.pas
  4. 45 38
      rtl/emx/sysutils.pp

+ 28 - 23
rtl/emx/dos.pas

@@ -214,7 +214,7 @@ asm
     jnz @LCFstop
     inc ax
 @LCFstop:
-end;
+end ['eax', 'ecx', 'edx'];
 {$ASMMODE ATT}
 
 begin
@@ -274,7 +274,7 @@ begin
         xorb %ah,%ah
         movw %ax,doserror
         popl %ebx
-    end;
+    end ['eax', 'ecx', 'edx'];
 end;
 
 procedure SetFTime (var F; Time: longint);
@@ -316,7 +316,7 @@ begin
             xorb %ah,%ah
             movw %ax,doserror
             popl %ebx
-        end;
+        end ['eax', 'ecx', 'edx'];
 end;
 
 procedure msdos(var regs:registers);
@@ -541,7 +541,7 @@ begin
     .Lexprg1:
         movw %di,doserror
         movl %eax,__RESULT
-    end;
+    end ['eax', 'ebx', 'ecx', 'edx', 'esi', 'edi'];
 
     freemem(args,ArgsSize);
     FreeMem(env, envc*sizeof(pchar)+16384);
@@ -555,7 +555,7 @@ function dosversion:word;assembler;
 asm
     movb $0x30,%ah
     call syscall
-end;
+end ['eax'];
 
 procedure GetDate (var Year, Month, Day, DayOfWeek: word);
 
@@ -575,7 +575,7 @@ begin
         movl Year, %edi
         xchgw %ecx, %eax
         stosw
-    end;
+    end ['eax', 'ecx', 'edx'];
 end;
 
 {$asmmode intel}
@@ -598,7 +598,7 @@ begin
             mov  dl, byte ptr Day
             mov  ah, 2Bh
             call syscall
-        end;
+        end ['eax', 'ecx', 'edx'];
 end;
 
 {$asmmode att}
@@ -620,7 +620,7 @@ asm
     movl Hour, %edi
     movb %ch,%al
     stosw
-end;
+end ['eax', 'ecx', 'edx'];
 
 {$asmmode intel}
 procedure SetTime (Hour, Minute, Second, Sec100: word);
@@ -643,7 +643,7 @@ begin
             mov  dl, byte ptr Sec100
             mov  ah, 2Dh
             call syscall
-        end;
+        end ['eax', 'ecx', 'edx'];
 end;
 
 {$asmmode att}
@@ -660,10 +660,10 @@ begin
 {! Do not use in OS/2. Also not recommended in DOS. Use
        signal handling instead.
     asm
-        movb 8(%ebp),%dl
+        movb BreakValue,%dl
         movw $0x3301,%ax
         call syscall
-    end;
+    end ['eax', 'edx'];
 }
 end;
 
@@ -677,7 +677,7 @@ begin
          call syscall
          movl verify,%edi
          stosb
-      end
+      end ['eax', 'edi']
   else
   verify := true;
 end;
@@ -691,7 +691,7 @@ begin
         movb verify,%al
         movb $0x2e,%ah
         call syscall
-    end;
+    end ['eax'];
  end;
 
 
@@ -723,7 +723,7 @@ begin
             popl %ebx
             leave
             ret
-        end
+        end ['eax', 'ecx', 'edx']
     else
         {In OS/2, we use the filesystem information.}
         begin
@@ -765,7 +765,7 @@ begin
             popl %ebx
             leave
             ret
-        end
+        end ['eax', 'ecx', 'edx']
     else
         {In OS/2, we use the filesystem information.}
 begin
@@ -838,6 +838,7 @@ end;
 
     begin
         asm
+            pushl %esi
             movl path,%edx
             movw attr,%cx
             {No need to set DTA in EMX. Just give a pointer in ESI.}
@@ -847,7 +848,8 @@ end;
             jnc .LFF
             movw %ax,doserror
         .LFF:
-        end;
+            popl %esi
+        end ['eax', 'ecx', 'edx'];
     end;
 
 
@@ -881,20 +883,21 @@ end;
 
     begin
         asm
+            pushl %esi
             movl f,%esi
             movb $0x4f,%ah
             call syscall
             jnc .LFN
             movw %ax,doserror
         .LFN:
-        end;
+            popl %esi
+        end ['eax'];
     end;
 
 
 procedure FindNext (var F: SearchRec);
 var Count: cardinal;
 
-
 begin
     {No error}
     DosError := 0;
@@ -996,7 +999,7 @@ begin
   pop eax
   mov P, edi      { place pointer to variable contents in P }
 @End:
- end ['eax','ebx','ecx','edx','esi','edi'];
+ end ['eax','ecx','edx','esi','edi'];
  GetEnvPChar := P;
 end;
 {$ASMMODE ATT}
@@ -1006,7 +1009,6 @@ function GetEnv (const EnvVar: string): string;
 begin
  GetEnv := StrPas (GetEnvPChar (EnvVar));
 end;
-{$ASMMODE ATT}
 
 procedure fsplit(path:pathstr;var dir:dirstr;var name:namestr;
                  var ext:extstr);
@@ -1133,7 +1135,7 @@ begin
     movl attr,%ebx
     movw %cx,(%ebx)
     popl %ebx
- end;
+ end ['eax', 'ecx', 'edx'];
 end;
 
 procedure setfattr(var f;attr : word);
@@ -1160,7 +1162,7 @@ begin
      jnc  .Lnoerror
      movw %ax,doserror
    .Lnoerror:
-  end;
+  end ['eax', 'ecx', 'edx'];
 end;
 
 
@@ -1232,7 +1234,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.5  2003-10-04 17:53:08  hajny
+  Revision 1.6  2003-10-07 21:33:24  hajny
+    * stdcall fixes and asm routines cleanup
+
+  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

+ 10 - 7
rtl/emx/ports.pas

@@ -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.1  2002-11-17 16:22:54  hajny
+  Revision 1.2  2003-10-07 21:33:24  hajny
+    * stdcall fixes and asm routines cleanup
+
+  Revision 1.1  2002/11/17 16:22:54  hajny
     + RTL for emx target
 
   Revision 1.2  2002/09/07 16:01:25  peter

+ 28 - 36
rtl/emx/system.pas

@@ -239,7 +239,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
@@ -265,7 +265,7 @@ asm
     call syscall
     mov word ptr [randseed], cx
     mov word ptr [randseed + 2], dx
-end;
+end ['eax', 'ecx', 'edx'];
 
 {$ASMMODE ATT}
 
@@ -293,7 +293,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;
@@ -303,7 +303,7 @@ asm
     movl size,%edx
     movw $0x7f00,%ax
     call syscall     { result directly in EAX }
-end;
+end ['eax', 'edx'];
 {$ENDIF DUMPGROW}
 
 function getheapstart:pointer;assembler;
@@ -352,7 +352,7 @@ begin
         movw  %ax, InOutRes       { yes, then set InOutRes }
      .Lnoerror:
         popl %ebx
-     end;
+     end ['eax'];
    end;
 end;
 
@@ -367,7 +367,7 @@ begin
         jnc .LERASE1
         movw %ax,inoutres;
     .LERASE1:
-    end;
+    end ['eax', 'edx'];
 end;
 
 procedure do_rename(p1,p2:Pchar);
@@ -376,7 +376,6 @@ begin
     allowslash(p1);
     allowslash(p2);
     asm
-        pushl %edi
         movl P1, %edx
         movl P2, %edi
         movb $0x56,%ah
@@ -384,13 +383,11 @@ begin
         jnc .LRENAME1
         movw %ax,inoutres;
     .LRENAME1:
-        popl %edi
-    end;
+    end ['eax', 'edx', 'edi'];
 end;
 
 function do_read(h,addr,len:longint):longint; assembler;
 asm
-    pushl %ebx
     movl len,%ecx
     movl addr,%edx
     movl h,%ebx
@@ -400,12 +397,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
@@ -417,12 +412,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
@@ -431,12 +424,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
@@ -444,12 +435,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
@@ -458,8 +447,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;
 
@@ -473,7 +461,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
@@ -491,8 +478,7 @@ asm
 .LTruncate1:
     movw %ax,inoutres;
 .LTruncate2:
-    popl %ebx
-end;
+end ['eax', 'ebx', 'ecx', 'edx'];
 
 const
     FileHandleCount: longint = 20;
@@ -528,7 +514,7 @@ begin
                 movw %ax, Err
 .LIncFHandles:
                 popl %ebx
-            end;
+            end ['eax'];
             if Err <> 0 then
                 begin
                     Increase_File_Handle_Count := false;
@@ -599,6 +585,7 @@ begin
     if Flags and 112 = 0 then
         Action := Action or 64;
     asm
+        pushl %ebx
         movl $0x7f2b, %eax
         movl Action, %ecx
         movl p, %edx
@@ -610,7 +597,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
@@ -625,7 +613,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;
@@ -660,7 +648,7 @@ asm
     dec eax                 { nope, so result is zero }
 @IsDevEnd:
     pop ebx
-end;
+end ['eax', 'edx'];
 {$ASMMODE ATT}
 
 
@@ -710,7 +698,7 @@ begin
         jnc  .LDOS_DIRS1
         movw %ax,inoutres
     .LDOS_DIRS1:
-    end;
+    end ['eax', 'edx'];
 end;
 
 
@@ -902,7 +890,7 @@ begin
                 call syscall
                 addb $65,%al
                 movb %al,i
-            end;
+            end ['eax'];
             dir[1]:=char(i);
         end;
     if not (FileNameCaseSensitive) then dir:=upcase(dir);
@@ -1150,6 +1138,7 @@ begin
         call syscall
         cmp eax, -1
         jnz @heapok
+        pop ebx
         push dword 204
         call HandleError
     @heapok:
@@ -1170,7 +1159,7 @@ begin
         call syscall
 {$ENDIF CONTHEAP}
         pop ebx
-    end;
+    end ['eax', 'ecx', 'edx'];
 
     { in OS/2 this will always be nil, but in DOS mode }
     { this can be changed.                             }
@@ -1189,7 +1178,7 @@ begin
             mov first_meg, eax
          @endmem:
             pop ebx
-        end
+        end ['eax', 'ecx', 'edx']
     else
         begin
     (* Initialize the amount of file handles *)
@@ -1249,7 +1238,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.9  2003-10-04 17:53:08  hajny
+  Revision 1.10  2003-10-07 21:33:24  hajny
+    * stdcall fixes and asm routines cleanup
+
+  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

+ 45 - 38
rtl/emx/sysutils.pp

@@ -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;
@@ -416,9 +412,12 @@ asm
     inc eax
 @FExistsEnd:
 {$IFOPT H-}
-end;
+    mov Result, eax
 {$ENDIF}
+end ['eax', 'ecx', 'edx'];
+{$IFOPT H-}
 end;
+{$ENDIF}
 
 
 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
-end;
+    mov Result, eax
 {$ENDIF}
+  end ['eax', 'edx'];
+{$IFOPT H-}
 end;
+{$ENDIF}
 
 
 function FileSetAttr (const Filename: string; Attr: longint): longint;
@@ -649,10 +648,12 @@ asm
     mov eax, -1
 @FSetAttrEnd:
 {$IFOPT H-}
-    mov [ebp - 4], eax
-end;
+    mov Result, eax
 {$ENDIF}
+end ['eax', 'ecx', 'edx'];
+{$IFOPT H-}
 end;
+{$ENDIF}
 
 
 function DeleteFile (const FileName: string): boolean;
@@ -677,10 +678,12 @@ asm
     inc eax
 @FDeleteEnd:
 {$IFOPT H-}
-    mov [ebp - 4], eax
-end;
+    mov Result, eax
 {$ENDIF}
+  end ['eax', 'edx'];
+{$IFOPT H-}
 end;
+{$ENDIF}
 
 
 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
-end;
+    mov Result, eax
 {$ENDIF}
+  end ['eax', 'edx', 'edi'];
+{$IFOPT H-}
 end;
+{$ENDIF}
 
 
 {****************************************************************************
@@ -865,9 +868,12 @@ asm
     inc eax
 @FExistsEnd:
 {$IFOPT H-}
-end;
+    mov Result, eax
 {$ENDIF}
+  end ['eax', 'ecx', 'edx'];
+{$IFOPT H-}
 end;
+{$ENDIF}
 
 
 {****************************************************************************
@@ -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,8 +907,7 @@ asm
     shl eax, 16
     mov al, dh
     stosd
-    pop edi
-end;
+end ['eax', 'ecx', 'edx', 'edi'];
 {$asmmode default}
 
 
@@ -1009,7 +1013,10 @@ end.
 
 {
   $Log$
-  Revision 1.9  2003-10-04 17:53:08  hajny
+  Revision 1.10  2003-10-07 21:33:24  hajny
+    * stdcall fixes and asm routines cleanup
+
+  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