瀏覽代碼

* stdcall fixes

peter 22 年之前
父節點
當前提交
8457961ba6
共有 5 個文件被更改,包括 163 次插入22 次删除
  1. 12 1
      rtl/go32v2/crt.pp
  2. 12 1
      rtl/watcom/crt.pp
  3. 4 3
      rtl/watcom/dos.pp
  4. 32 11
      rtl/watcom/system.pp
  5. 103 6
      rtl/watcom/watcom.pp

+ 12 - 1
rtl/go32v2/crt.pp

@@ -454,6 +454,8 @@ end;
 
 procedure initdelay;assembler;
 asm
+	pushl %ebx
+	pushl %edi
         { for some reason, using int $31/ax=$901 doesn't work here }
         { and interrupts are always disabled at this point when    }
         { running a program inside gdb(pas). Web bug 1345 (JM)     }
@@ -473,11 +475,15 @@ asm
         movl    $55,%ecx
         divl    %ecx
         movl    %eax,DelayCnt
+	popl %edi
+	popl %ebx
 end;
 
 
 procedure Delay(MS: Word);assembler;
 asm
+	pushl %ebx
+	pushl %edi
         movzwl  MS,%ecx
         jecxz   .LDelay2
         movl    $0x400,%edi
@@ -488,6 +494,8 @@ asm
         call    DelayLoop
         loop    .LDelay1
 .LDelay2:
+	popl %edi
+	popl %ebx
 end;
 
 
@@ -834,7 +842,10 @@ end.
 
 {
   $Log$
-  Revision 1.9  2003-03-17 18:13:13  peter
+  Revision 1.10  2003-10-03 21:56:36  peter
+    * stdcall fixes
+
+  Revision 1.9  2003/03/17 18:13:13  peter
     * exported ScreenHeight, ScreenWidth
 
   Revision 1.8  2002/12/15 20:22:24  peter

+ 12 - 1
rtl/watcom/crt.pp

@@ -444,6 +444,8 @@ end;
 
 procedure initdelay;assembler;
 asm
+        pushl %ebx
+        pushl %edi
         { for some reason, using int $31/ax=$901 doesn't work here }
         { and interrupts are always disabled at this point when    }
         { running a program inside gdb(pas). Web bug 1345 (JM)     }
@@ -463,11 +465,15 @@ asm
         movl    $55,%ecx
         divl    %ecx
         movl    %eax,DelayCnt
+        popl    %edi
+        popl    %ebx
 end;
 
 
 procedure Delay(MS: Word);assembler;
 asm
+        pushl %ebx
+        pushl %edi
         movzwl  MS,%ecx
         jecxz   .LDelay2
         movl    $0x400,%edi
@@ -478,6 +484,8 @@ asm
         call    DelayLoop
         loop    .LDelay1
 .LDelay2:
+        popl    %edi
+        popl    %ebx
 end;
 
 
@@ -821,7 +829,10 @@ end.
 
 {
   $Log$
-  Revision 1.2  2003-09-07 22:29:26  hajny
+  Revision 1.3  2003-10-03 21:59:28  peter
+    * stdcall fixes
+
+  Revision 1.2  2003/09/07 22:29:26  hajny
     * syswat renamed to system, CVS log added
 
 

+ 4 - 3
rtl/watcom/dos.pp

@@ -143,8 +143,6 @@ implementation
 uses
   strings;
 
-{$ASMMODE ATT}
-
 {******************************************************************************
                            --- Dos Interrupt ---
 ******************************************************************************}
@@ -1050,7 +1048,10 @@ end.
 
 {
   $Log$
-  Revision 1.2  2003-09-07 22:29:26  hajny
+  Revision 1.3  2003-10-03 21:59:28  peter
+    * stdcall fixes
+
+  Revision 1.2  2003/09/07 22:29:26  hajny
     * syswat renamed to system, CVS log added
 
   Revision 1.1  2003/09/05 18:09:35  florian

+ 32 - 11
rtl/watcom/system.pp

@@ -2,7 +2,7 @@
     $Id$
     This file is part of the Free Pascal run time library.
     Copyright (c) 1999-2000 by the Free Pascal development team.
- 
+
     Watcom
 
     See the file COPYING.FPC, included in this distribution,
@@ -99,7 +99,7 @@ Const
       tb_segment:word;
 
   const tb_offset=0;
-        tb_size=8192;      
+        tb_size=8192;
 
 IMPLEMENTATION
 
@@ -163,6 +163,7 @@ end;
 procedure alloc_tb; assembler;
 { allocate 8kB real mode transfer buffer }
 asm
+   pushl %ebx
    movw $0x100,%ax
    movw $512,%bx
    int $0x31
@@ -170,6 +171,7 @@ asm
    shll $16,%eax
    shrl $12,%eax
    movl %eax,tb
+   popl %ebx
 end;
 
 procedure sysseg_move(sseg : word;source : longint;dseg : word;dest : longint;count : longint);
@@ -178,6 +180,8 @@ begin
      exit;
    if (sseg<>dseg) or ((sseg=dseg) and (source>dest)) then
      asm
+        pushl %esi
+        pushl %edi
         pushw %es
         pushw %ds
         cld
@@ -198,10 +202,14 @@ begin
         movsb
         popw %ds
         popw %es
-     end ['ESI','EDI','ECX','EAX']
+        popl %edi
+        popl %esi
+     end
    else if (source<dest) then
      { copy backward for overlapping }
      asm
+        pushl %esi
+        pushl %edi
         pushw %es
         pushw %ds
         std
@@ -236,7 +244,9 @@ begin
         cld
         popw %ds
         popw %es
-     end ['ESI','EDI','ECX'];
+        popl %edi
+        popl %esi
+     end;
 end;
 
 
@@ -250,9 +260,10 @@ end;
 
 
 
-function strcopy(dest,source : pchar) : pchar;
-begin
-  asm
+function strcopy(dest,source : pchar) : pchar;assembler;
+asm
+        pushl %esi
+        pushl %edi
         cld
         movl 12(%ebp),%edi
         movl $0xffffffff,%ecx
@@ -271,9 +282,8 @@ begin
         rep
         movsb
         movl 8(%ebp),%eax
-        leave
-        ret $8
-  end;
+        popl %edi
+        popl %esi
 end;
 
 
@@ -303,6 +313,8 @@ begin
    regs.realsp:=0;
    regs.realss:=0;
    asm
+      pushl %edi
+      pushl %ebx
       pushw %fs
       movw  intnr,%bx
       xorl  %ecx,%ecx
@@ -310,6 +322,8 @@ begin
       movw  $0x300,%ax
       int   $0x31
       popw  %fs
+      popl %ebx
+      popl %edi
    end;
 end;
 
@@ -317,12 +331,14 @@ end;
 procedure set_pm_interrupt(vector : byte;const intaddr : tseginfo);
 begin
   asm
+        pushl %ebx
         movl intaddr,%eax
         movl (%eax),%edx
         movw 4(%eax),%cx
         movl $0x205,%eax
         movb vector,%bl
         int $0x31
+        popl %ebx
   end;
 end;
 
@@ -330,12 +346,14 @@ end;
 procedure get_pm_interrupt(vector : byte;var intaddr : tseginfo);
 begin
   asm
+        pushl %ebx
         movb    vector,%bl
         movl    $0x204,%eax
         int     $0x31
         movl    intaddr,%eax
         movl    %edx,(%eax)
         movw    %cx,4(%eax)
+        popl %ebx
   end;
 end;
 
@@ -1121,7 +1139,10 @@ END.
 
 {
   $Log$
-  Revision 1.4  2003-09-29 18:52:36  hajny
+  Revision 1.5  2003-10-03 21:59:28  peter
+    * stdcall fixes
+
+  Revision 1.4  2003/09/29 18:52:36  hajny
     * append fix applied to Amiga, Atari, EMX, GO32v2, OS/2 and Watcom
 
   Revision 1.3  2003/09/27 11:52:36  peter

+ 103 - 6
rtl/watcom/watcom.pp

@@ -232,6 +232,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movl bytes,%ebx
             addl $0xf,%ebx              // round up
             shrl $0x4,%ebx              // convert to Paragraphs
@@ -246,6 +247,7 @@ interface
             movw %dx,%ax                // return Selector in lo(Result)
           .LDos_end:
             movl %eax,__result
+            popl %ebx
          end;
       end;
 
@@ -267,6 +269,8 @@ interface
          regs.realsp:=0;
          regs.realss:=0;
          asm
+            pushl %ebx
+            pushl %edi
             { save all used registers to avoid crash under NTVDM }
             { when spawning a 32-bit DPMI application            }
             pushw %fs
@@ -279,6 +283,8 @@ interface
             popw  %fs
             setnc %al
             movb  %al,__RESULT
+            popl  %edi
+            popl  %ebx
          end;
       end;
 
@@ -286,6 +292,7 @@ interface
 
       begin
          asm
+            pushl %edi
             movl ofs,%edi
             movl count,%ecx
             movb c,%dl
@@ -309,13 +316,15 @@ interface
             rep
             stosb
             popw %es
-         end ['EAX','ECX','EDX','EDI'];
+            popl %edi
+         end;
       end;
 
     procedure seg_fillword(seg : word;ofs : longint;count : longint;w : word);
 
       begin
          asm
+            pushl %edi
             movl ofs,%edi
             movl count,%ecx
             movw w,%dx
@@ -337,7 +346,8 @@ interface
             rep
             stosw
             popw %es
-         end ['EAX','ECX','EDX','EDI'];
+            popl %edi
+         end;
       end;
 
     procedure seg_move(sseg : word;source : longint;dseg : word;dest : longint;count : longint);
@@ -347,6 +357,8 @@ interface
            exit;
          if (sseg<>dseg) or ((sseg=dseg) and (source>dest)) then
            asm
+              pushl %edi
+              pushl %esi
               pushw %es
               pushw %ds
               cld
@@ -367,10 +379,14 @@ interface
               movsb
               popw %ds
               popw %es
-           end ['ESI','EDI','ECX','EAX']
+              popl %esi
+              popl %edi
+           end
          else if (source<dest) then
            { copy backward for overlapping }
            asm
+              pushl %edi
+              pushl %esi
               pushw %es
               pushw %ds
               std
@@ -405,7 +421,9 @@ interface
               cld
               popw %ds
               popw %es
-           end ['ESI','EDI','ECX'];
+              popl %esi
+              popl %edi
+           end;
       end;
 
     procedure outportb(port : word;data : byte);
@@ -492,6 +510,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movl intaddr,%eax
             movl (%eax),%edx
             movw 4(%eax),%cx
@@ -501,6 +520,7 @@ interface
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -508,6 +528,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movl intaddr,%eax
             movw (%eax),%dx
             movw 4(%eax),%cx
@@ -517,6 +538,7 @@ interface
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -524,6 +546,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movl intaddr,%eax
             movl (%eax),%edx
             movw 4(%eax),%cx
@@ -533,6 +556,7 @@ interface
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -540,6 +564,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movl intaddr,%eax
             movl (%eax),%edx
             movw 4(%eax),%cx
@@ -549,6 +574,7 @@ interface
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -556,6 +582,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movl $0x210,%eax
             movb e,%bl
             int $0x31
@@ -565,6 +592,7 @@ interface
             movl intaddr,%eax
             movl %edx,(%eax)
             movw %cx,4(%eax)
+            popl %ebx
          end;
       end;
 
@@ -572,6 +600,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movl $0x202,%eax
             movb e,%bl
             int $0x31
@@ -581,6 +610,7 @@ interface
             movl intaddr,%eax
             movl %edx,(%eax)
             movw %cx,4(%eax)
+            popl %ebx
          end;
       end;
 
@@ -588,6 +618,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movb vector,%bl
             movl $0x204,%eax
             int $0x31
@@ -597,6 +628,7 @@ interface
             movl intaddr,%eax
             movl %edx,(%eax)
             movw %cx,4(%eax)
+            popl %ebx
          end;
       end;
 
@@ -604,6 +636,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movb vector,%bl
             movl $0x200,%eax
             int $0x31
@@ -614,6 +647,7 @@ interface
             movzwl %dx,%edx
             movl %edx,(%eax)
             movw %cx,4(%eax)
+            popl %ebx
          end;
       end;
 
@@ -637,11 +671,13 @@ interface
 
 //!!!!    var
 //!!!!       ___v2prt0_ds_alias : word; external name '___v2prt0_ds_alias';
-   var ___v2prt0_ds_alias : word; 
+   var ___v2prt0_ds_alias : word;
 
     function get_rm_callback(pm_func : pointer;const reg : trealregs;var rmcb : tseginfo) : boolean;
       begin
          asm
+            pushl %esi
+            pushl %edi
             movl  pm_func,%esi
             movl  reg,%edi
             pushw %es
@@ -661,6 +697,8 @@ interface
             movzwl %dx,%edx
             movl  %edx,(%eax)
             movw  %cx,4(%eax)
+            popl %edi
+            popl %esi
          end;
       end;
 
@@ -679,12 +717,14 @@ interface
 
       begin
          asm
+            pushl %ebx
             movw d,%bx
             movl $1,%eax
             int $0x31
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -692,10 +732,12 @@ interface
 
       begin
          asm
+            pushl %ebx
             movw seg,%bx
             movl $2,%eax
             int $0x31
             movw %ax,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -713,6 +755,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movw d,%bx
             movl $6,%eax
             int $0x31
@@ -721,17 +764,20 @@ interface
             shll $16,%ecx
             orl %ecx,%eax
             movl %eax,__RESULT
+            popl %ebx
          end;
       end;
 
     function get_page_size:longint;
       begin
         asm
+           pushl %ebx
            movl $0x604,%eax
            int $0x31
            shll $16,%ebx
            movw %cx,%bx
            movl %ebx,__RESULT
+           popl %ebx
         end;
       end;
 
@@ -745,6 +791,8 @@ interface
          linearaddr:=linearaddr-pageofs;
          size:=size+pageofs;
          asm
+            pushl %esi
+            pushl %ebx
             movl $0x504,%eax
             movl linearaddr,%ebx
             movl size,%ecx
@@ -757,6 +805,8 @@ interface
             movl blockhandle,%eax
             movl %esi,(%eax)
             movl %ebx,pageofs
+            popl %ebx
+            popl %esi
          end;
          if pageofs<>linearaddr then
            request_linear_region:=false;
@@ -765,6 +815,9 @@ interface
     function allocate_memory_block(size:longint):longint;
       begin
         asm
+          pushl %esi
+          pushl %edi
+          pushl %ebx
           movl  $0x501,%eax
           movl  size,%ecx
           movl  %ecx,%ebx
@@ -780,12 +833,17 @@ interface
           shll  $16,%esi
           movw  %di,%si
           movl  %ebx,__RESULT
+          popl %ebx
+          popl %edi
+          popl %esi
         end;
      end;
 
     function free_memory_block(blockhandle : longint) : boolean;
       begin
          asm
+            pushl %esi
+            pushl %edi
             movl blockhandle,%esi
             movl %esi,%edi
             shll $16,%esi
@@ -794,6 +852,8 @@ interface
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %edi
+            popl %esi
          end;
       end;
 
@@ -801,6 +861,9 @@ interface
 
       begin
           asm
+            pushl %esi
+            pushl %edi
+            pushl %ebx
             movl  $0x600,%eax
             movl  linearaddr,%ecx
             movl  %ecx,%ebx
@@ -812,6 +875,9 @@ interface
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %ebx
+            popl %edi
+            popl %esi
           end;
       end;
 
@@ -843,6 +909,9 @@ interface
 
       begin
          asm
+            pushl %esi
+            pushl %edi
+            pushl %ebx
             movl  $0x601,%eax
             movl  linearaddr,%ecx
             movl  %ecx,%ebx
@@ -854,6 +923,9 @@ interface
             pushf
             call  test_int31
             movb  %al,__RESULT
+            popl %ebx
+            popl %edi
+            popl %esi
          end;
       end;
 
@@ -883,6 +955,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movw d,%bx
             leal s,%eax
             movw (%eax),%dx
@@ -892,6 +965,7 @@ interface
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -899,6 +973,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movw d,%bx
             movw w,%cx
             movl $9,%eax
@@ -906,6 +981,7 @@ interface
             pushf
             call test_int31
             movw %ax,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -913,6 +989,7 @@ interface
 
       begin
          asm
+            pushl %ebx
             movw d,%bx
             leal s,%eax
             movw (%eax),%dx
@@ -922,6 +999,7 @@ interface
             pushf
             call test_int31
             movb %al,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -954,12 +1032,14 @@ interface
 
       begin
          asm
+            pushl %ebx
             movw seg,%bx
             movl $0xa,%eax
             int $0x31
             pushf
             call test_int31
             movw %ax,__RESULT
+            popl %ebx
          end;
       end;
 
@@ -967,12 +1047,14 @@ interface
 
       begin
          asm
+            pushl %edi
             movl meminfo,%edi
             movl $0x500,%eax
             int $0x31
             pushf
             movb %al,__RESULT
             call test_int31
+            popl %edi
          end;
       end;
 
@@ -980,6 +1062,9 @@ interface
 
       begin
          asm
+            pushl %esi
+            pushl %edi
+            pushl %ebx
             movl phys_addr,%ebx
             movl %ebx,%ecx
             shrl $16,%ebx
@@ -993,6 +1078,9 @@ interface
             shll $16,%ebx
             movw %cx,%bx
             movl %ebx,__RESULT
+            popl %ebx
+            popl %edi
+            popl %esi
          end;
       end;
 
@@ -1022,6 +1110,9 @@ interface
     function map_device_in_memory_block(handle,offset,pagecount,device:longint):boolean;
       begin
          asm
+            pushl %esi
+            pushl %edi
+            pushl %ebx
            movl device,%edx
            movl handle,%esi
            movl offset,%ebx
@@ -1032,6 +1123,9 @@ interface
            setnc %al
            movb %al,__RESULT
            call test_int31
+            popl %ebx
+            popl %edi
+            popl %esi
          end;
       end;
 
@@ -1062,7 +1156,10 @@ end.
 
 {
   $Log$
-  Revision 1.2  2003-09-07 22:29:26  hajny
+  Revision 1.3  2003-10-03 21:59:28  peter
+    * stdcall fixes
+
+  Revision 1.2  2003/09/07 22:29:26  hajny
     * syswat renamed to system, CVS log added