Ver Fonte

* regcall fixes

Tomas Hajny há 21 anos atrás
pai
commit
ac8870b489
3 ficheiros alterados com 158 adições e 25 exclusões
  1. 30 4
      rtl/emx/dos.pas
  2. 70 7
      rtl/emx/ports.pas
  3. 58 14
      rtl/emx/system.pas

+ 30 - 4
rtl/emx/dos.pas

@@ -204,9 +204,13 @@ var i,p1:longint;
 {$ASMMODE INTEL}
 function CheckFile (FN: ShortString):boolean; assembler;
 asm
-    mov ax, 4300h
+{$IFDEF REGCALL}
+    mov edx, eax
+{$ELSE REGCALL}
     mov edx, FN      { get pointer to string }
+{$ENDIF REGCALL}
     inc edx          { avoid length byte     }
+    mov ax, 4300h
     call syscall
     mov ax, 0
     jc @LCFstop
@@ -260,14 +264,23 @@ procedure GetFTime (var F; var Time: longint); assembler;
 asm
     pushl %ebx
     {Load handle}
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+    pushl %edx
+{$ELSE REGCALL}
     movl F,%ebx
+{$ENDIF REGCALL}
     movl (%ebx),%ebx
     {Get date}
     movw $0x5700,%ax
     call syscall
     shll $16,%edx
     movw %cx,%dx
+{$IFDEF REGCALL}
+    popl %ebx
+{$ELSE REGCALL}
     movl Time,%ebx
+{$ENDIF REGCALL}
     movl %edx,(%ebx)
     movw %ax,DosError
     popl %ebx
@@ -594,7 +607,12 @@ end;
 
 {$asmmode att}
 
-procedure GetTime (var Hour, Minute, Second, Sec100: word); assembler;
+procedure GetTime (var Hour, Minute, Second, Sec100: word);
+{$IFDEF REGCALL}
+begin
+{$ELSE REGCALL}
+                                                            assembler;
+{$ENDIF REGCALL}
 asm
     movb $0x2c, %ah
     call syscall
@@ -611,7 +629,12 @@ asm
     movl Hour, %edi
     movb %ch,%al
     stosw
-end ['eax', 'ecx', 'edx'];
+{$IFDEF REGCALL}
+  end ['eax', 'ecx', 'edx'];
+end;
+{$ELSE REGCALL}
+end {['eax', 'ecx', 'edx']};
+{$ENDIF REGCALL}
 
 {$asmmode intel}
 procedure SetTime (Hour, Minute, Second, Sec100: word);
@@ -1225,7 +1248,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.7  2003-10-25 22:45:37  hajny
+  Revision 1.8  2003-12-26 22:20:44  hajny
+    * regcall fixes
+
+  Revision 1.7  2003/10/25 22:45:37  hajny
     * file handling related fixes
 
   Revision 1.6  2003/10/07 21:33:24  hajny

+ 70 - 7
rtl/emx/ports.pas

@@ -76,77 +76,140 @@ procedure syscall; external name '___SYSCALL';
 procedure TPort.WritePort (P: word; Data: byte); assembler;
 asm
  xorl %ecx, %ecx
+{$IFDEF REGCALL}
+ movw %ax, %cx
+ pushl %edx
+ pushl %ecx
+{$ELSE REGCALL}
  movw P, %cx
+{$ENDIF REGCALL}
  movl %ecx, %edx
  movw $0x7F12, %ax
  call syscall
+{$IFDEF REGCALL}
+ popl %edx
+ popl %eax
+{$ELSE REGCALL}
  movw P, %dx
  movb Data, %al
+{$ENDIF REGCALL}
  outb %al, %dx
-end ['eax', 'ecx', 'edx'];
+end {['eax', 'ecx', 'edx']};
 
 function TPort.ReadPort (P: word): byte; assembler;
 asm
  xorl %ecx, %ecx
+{$IFDEF REGCALL}
+ movw %ax, %cx
+{$ELSE REGCALL}
  movw P, %cx
+ pushl %ecx
+{$ENDIF REGCALL}
  movl %ecx, %edx
  movw $0x7F12, %ax
  call syscall
+{$IFDEF REGCALL}
+ popl %edx
+{$ELSE REGCALL}
  movw P, %dx
+{$ENDIF REGCALL}
  inb %dx, %al
-end ['eax', 'ecx', 'edx'];
+end {['eax', 'ecx', 'edx']};
 
 procedure TPortW.WritePort (P: word; Data : word); assembler;
 asm
  xorl %ecx, %ecx
+{$IFDEF REGCALL}
+ movw %ax, %cx
+ pushl %edx
+ pushl %ecx
+{$ELSE REGCALL}
  movw P, %cx
+{$ENDIF REGCALL}
  movl %ecx, %edx
  movw $0x7F12, %ax
  call syscall
+{$IFDEF REGCALL}
+ popl %edx
+ popl %eax
+{$ELSE REGCALL}
  movw P, %dx
  movw Data, %ax
+{$ENDIF REGCALL}
  outw %ax, %dx
-end ['eax', 'ecx', 'edx'];
+end {['eax', 'ecx', 'edx']};
 
 function TPortW.ReadPort (P: word): word; assembler;
 asm
  xorl %ecx, %ecx
+{$IFDEF REGCALL}
+ movw %ax, %cx
+ pushl %ecx
+{$ELSE REGCALL}
  movw P, %cx
+{$ENDIF REGCALL}
  movl %ecx, %edx
  movw $0x7F12, %ax
  call syscall
+{$IFDEF REGCALL}
+ popl %edx
+{$ELSE REGCALL}
  movw P, %dx
+{$ENDIF REGCALL}
  inw %dx, %ax
-end ['eax', 'ecx', 'edx'];
+end {['eax', 'ecx', 'edx']};
 
 procedure TPortL.WritePort (P: word; Data: longint); assembler;
 asm
  xorl %ecx, %ecx
+{$IFDEF REGCALL}
+ movw %ax, %cx
+ pushl %edx
+ pushl %ecx
+{$ELSE REGCALL}
  movw P, %cx
+{$ENDIF REGCALL}
  movl %ecx, %edx
  movw $0x7F12, %ax
  call syscall
+{$IFDEF REGCALL}
+ popl %edx
+ popl %eax
+{$ELSE REGCALL}
  movw P, %dx
  movl Data, %eax
+{$ENDIF REGCALL}
  outl %eax, %dx
-end ['eax', 'ecx', 'edx'];
+end {['eax', 'ecx', 'edx']};
 
 function TPortL.ReadPort (P: word): longint; assembler;
 asm
  xorl %ecx, %ecx
+{$IFDEF REGCALL}
+ movw %ax, %cx
+ pushl %ecx
+{$ELSE REGCALL}
  movw P, %cx
+{$ENDIF REGCALL}
  movl %ecx, %edx
  movw $0x7F12, %ax
  call syscall
+{$IFDEF REGCALL}
+ popl %edx
+{$ELSE REGCALL}
  movw P, %dx
+{$ENDIF REGCALL}
  inl %dx, %eax
-end ['eax', 'ecx', 'edx'];
+end {['eax', 'ecx', 'edx']};
 
 end.
 
 {
   $Log$
-  Revision 1.2  2003-10-07 21:33:24  hajny
+  Revision 1.3  2003-12-26 22:20:44  hajny
+    * regcall fixes
+
+  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

+ 58 - 14
rtl/emx/system.pas

@@ -205,7 +205,7 @@ asm
     mov  ah, 04ch
     mov  al, byte ptr exitcode
     call syscall
-end ['EAX'];
+end {['EAX']};
 
 {$ASMMODE ATT}
 
@@ -308,7 +308,11 @@ end;
 {$ELSE DUMPGROW}
                                      assembler;
 asm
+{$IFDEF REGCALL}
+    movl %eax,%edx
+{$ELSE REGCALL}
     movl size,%edx
+{$ENDIF REGCALL}
     movw $0x7f00,%ax
     call syscall
     inc %eax         { Result in EAX, -1 = error (has to be transformed to 0) }
@@ -377,7 +381,7 @@ begin
         movb $0x41,%ah
         call syscall
         jnc .LERASE1
-        movw %ax,inoutres;
+        movw %ax,inoutres
     .LERASE1:
     end ['eax', 'edx'];
 end;
@@ -393,7 +397,7 @@ begin
         movb $0x56,%ah
         call syscall
         jnc .LRENAME1
-        movw %ax,inoutres;
+        movw %ax,inoutres
     .LRENAME1:
     end ['eax', 'edx', 'edi'];
 end;
@@ -401,13 +405,17 @@ end;
 function do_read(h,addr,len:longint):longint; assembler;
 asm
     pushl %ebx
+{$IFNDEF REGCALL}
     movl len,%ecx
     movl addr,%edx
+    movl %eax,%ebx
+{$ELSE REGCALL}
     movl h,%ebx
+{$ENDIF REGCALL}
     movb $0x3f,%ah
     call syscall
     jnc .LDOSREAD1
-    movw %ax,inoutres;
+    movw %ax,inoutres
     xorl %eax,%eax
 .LDOSREAD1:
     popl %ebx
@@ -416,16 +424,21 @@ end {['eax', 'ebx', 'ecx', 'edx']};
 function do_write(h,addr,len:longint) : longint; assembler;
 asm
     pushl %ebx
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+{$ENDIF REGCALL}
     xorl %eax,%eax
     cmpl $0,len    { 0 bytes to write is undefined behavior }
     jz   .LDOSWRITE1
+{$IFNDEF REGCALL}
     movl len,%ecx
     movl addr,%edx
     movl h,%ebx
+{$ENDIF REGCALL}
     movb $0x40,%ah
     call syscall
     jnc .LDOSWRITE1
-    movw %ax,inoutres;
+    movw %ax,inoutres
 .LDOSWRITE1:
     popl %ebx
 end {['eax', 'ebx', 'ecx', 'edx']};
@@ -433,12 +446,16 @@ end {['eax', 'ebx', 'ecx', 'edx']};
 function do_filepos(handle:longint): longint; assembler;
 asm
     pushl %ebx
-    movw $0x4201,%ax
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+{$ELSE REGCALL}
     movl handle,%ebx
+{$ENDIF REGCALL}
+    movw $0x4201,%ax
     xorl %edx,%edx
     call syscall
     jnc .LDOSFILEPOS
-    movw %ax,inoutres;
+    movw %ax,inoutres
     xorl %eax,%eax
 .LDOSFILEPOS:
     popl %ebx
@@ -447,12 +464,16 @@ end {['eax', 'ebx', 'ecx', 'edx']};
 procedure do_seek(handle,pos:longint); assembler;
 asm
     pushl %ebx
-    movw $0x4200,%ax
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+{$IFDEF REGCALL}
     movl handle,%ebx
     movl pos,%edx
+{$IFDEF REGCALL}
+    movw $0x4200,%ax
     call syscall
     jnc .LDOSSEEK1
-    movw %ax,inoutres;
+    movw %ax,inoutres
 .LDOSSEEK1:
     popl %ebx
 end {['eax', 'ebx', 'ecx', 'edx']};
@@ -460,8 +481,12 @@ end {['eax', 'ebx', 'ecx', 'edx']};
 function do_seekend(handle:longint):longint; assembler;
 asm
     pushl %ebx
-    movw $0x4202,%ax
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+{$ELSE REGCALL}
     movl handle,%ebx
+{$ENDIF REGCALL}
+    movw $0x4202,%ax
     xorl %edx,%edx
     call syscall
     jnc .Lset_at_end1
@@ -483,24 +508,36 @@ 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
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+    pushl %eax
+{$ELSE REGCALL}
     movl Handle,%ebx
     movl Pos,%edx
+{$ENDIF REGCALL}
+    movl $0x7F25,%eax
     call syscall
     incl %eax
     movl %ecx, %eax
+{$IFDEF REGCALL}
+    popl %ebx
+{$ENDIF REGCALL}
     jnz .LTruncate1      { compare the value of EAX to verify error }
 (* File position is undefined after truncation, move to the end. *)
     movl $0x4202,%eax
+{$IFNDEF REGCALL}
     movl Handle,%ebx
+{$ENDIF REGCALL}
     movl $0,%edx
     call syscall
     jnc .LTruncate2
 .LTruncate1:
-    movw %ax,inoutres;
+    movw %ax,inoutres
 .LTruncate2:
-end ['eax', 'ebx', 'ecx', 'edx'];
+    popl %ebx
+end {['eax', 'ebx', 'ecx', 'edx']};
 
 const
     FileHandleCount: cardinal = 20;
@@ -665,7 +702,11 @@ begin
 *)
 asm
     push ebx
+{$IFDEF REGCALL}
+    mov ebx, eax
+{$ELSE REGCALL}
     mov ebx, Handle
+{$ENDIF REGCALL}
     mov eax, 4400h
     call syscall
     mov eax, 1
@@ -1266,7 +1307,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.21  2003-12-17 22:52:39  hajny
+  Revision 1.22  2003-12-26 22:20:44  hajny
+    * regcall fixes
+
+  Revision 1.21  2003/12/17 22:52:39  hajny
     * fix for stackbottom change to pointer
 
   Revision 1.20  2003/11/06 23:21:51  hajny