Browse Source

* fixed for stackaligment also on 4 bytes, never use 'ret $..' direct

peter 27 years ago
parent
commit
4967811717
1 changed files with 78 additions and 112 deletions
  1. 78 112
      rtl/i386/set.inc

+ 78 - 112
rtl/i386/set.inc

@@ -16,12 +16,11 @@
 
 
 {$ASMMODE ATT}
 {$ASMMODE ATT}
 
 
-procedure do_load_small(p : pointer;l:longint);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_LOAD_SMALL'];
+procedure do_load_small(p : pointer;l:longint);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_LOAD_SMALL'];
 {
 {
-  load a set from an
+  load a normal set p from a smallset l
 }
 }
-begin
-  asm
+asm
         movl    p,%edi
         movl    p,%edi
         movl    l,%eax
         movl    l,%eax
         movl    %eax,(%edi)
         movl    %eax,(%edi)
@@ -30,16 +29,14 @@ begin
         xorl    %eax,%eax
         xorl    %eax,%eax
         rep
         rep
         stosl
         stosl
-  end;
 end;
 end;
 
 
 
 
-procedure do_set_byte(p : pointer;b : byte); [public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SET_BYTE'];
+procedure do_set_byte(p : pointer;b : byte);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SET_BYTE'];
 {
 {
   add the element b to the set pointed by p
   add the element b to the set pointed by p
 }
 }
-begin
-    asm
+asm
        pushl %eax
        pushl %eax
        movl p,%edi
        movl p,%edi
        movb b,%al
        movb b,%al
@@ -50,19 +47,14 @@ begin
        andl $7,%eax
        andl $7,%eax
        btsl %eax,(%edi)
        btsl %eax,(%edi)
        popl %eax
        popl %eax
-       { own exit, the compiler generates a ret $8, IMHO }
-       leave
-       ret $6
-    end;
 end;
 end;
 
 
 
 
-procedure do_set_range(p : pointer;l,h : byte);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SET_RANGE'];
+procedure do_set_range(p : pointer;l,h : byte);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SET_RANGE'];
 {
 {
   bad implementation, but it's very seldom used
   bad implementation, but it's very seldom used
 }
 }
-begin
-  asm
+asm
         pushl   %eax
         pushl   %eax
         movl    p,%edi
         movl    p,%edi
         xorl    %eax,%eax
         xorl    %eax,%eax
@@ -82,16 +74,14 @@ begin
         jmp     .LSET_SET_RANGE_LOOP
         jmp     .LSET_SET_RANGE_LOOP
 .LSET_SET_RANGE_EXIT:
 .LSET_SET_RANGE_EXIT:
         popl %eax
         popl %eax
-  end;
 end;
 end;
 
 
 
 
-procedure do_in_byte(p : pointer;b : byte);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_IN_BYTE'];
+procedure do_in_byte(p : pointer;b : byte);assembler;[public,alias:{$ifdef FPCNAMES}'FPC_'+{$endif}'SET_IN_BYTE'];
 {
 {
   tests if the element b is in the set p the carryflag is set if it present
   tests if the element b is in the set p the carryflag is set if it present
 }
 }
-begin
-    asm
+asm
        pushl %eax
        pushl %eax
        movl p,%edi
        movl p,%edi
        movb b,%al
        movb b,%al
@@ -102,23 +92,18 @@ begin
        andl $7,%eax
        andl $7,%eax
        btl %eax,(%edi)
        btl %eax,(%edi)
        popl %eax
        popl %eax
-       { own exit, the compiler generates a ret $8, IMHO }
-       leave
-       ret $6
-    end;
 end;
 end;
 
 
 
 
 
 
-procedure do_add_sets(set1,set2,dest : pointer);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_ADD_SETS'];
+procedure do_add_sets(set1,set2,dest : pointer);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_ADD_SETS'];
 {
 {
   adds set1 and set2 into set dest
   adds set1 and set2 into set dest
 }
 }
-begin
-   asm
-      movl 8(%ebp),%esi
-      movl 12(%ebp),%ebx
-      movl 16(%ebp),%edi
+asm
+      movl set1,%esi
+      movl set2,%ebx
+      movl dest,%edi
       movl $8,%ecx
       movl $8,%ecx
    .LMADDSETS1:
    .LMADDSETS1:
       lodsl
       lodsl
@@ -127,19 +112,18 @@ begin
       addl $4,%ebx
       addl $4,%ebx
       decl %ecx
       decl %ecx
       jnz .LMADDSETS1
       jnz .LMADDSETS1
-   end;
 end;
 end;
 
 
 
 
-{ multiplies (i.E. takes common elements of) set1 and set2 }
-{ result put in dest                                       }
 
 
-procedure do_mul_sets(set1,set2,dest : pointer);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_MUL_SETS'];
-begin
-   asm
-      movl 8(%ebp),%esi
-      movl 12(%ebp),%ebx
-      movl 16(%ebp),%edi
+procedure do_mul_sets(set1,set2,dest:pointer);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_MUL_SETS'];
+{
+  multiplies (takes common elements of) set1 and set2 result put in dest
+}
+asm
+      movl set1,%esi
+      movl set2,%ebx
+      movl dest,%edi
       movl $8,%ecx
       movl $8,%ecx
   .LMMULSETS1:
   .LMMULSETS1:
       lodsl
       lodsl
@@ -148,19 +132,17 @@ begin
       addl $4,%ebx
       addl $4,%ebx
       decl %ecx
       decl %ecx
       jnz .LMMULSETS1
       jnz .LMMULSETS1
-   end;
 end;
 end;
 
 
 
 
-procedure do_sub_sets(set1,set2,dest : pointer);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SUB_SETS'];
+procedure do_sub_sets(set1,set2,dest:pointer);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SUB_SETS'];
 {
 {
   computes the diff from set1 to set2 result in dest
   computes the diff from set1 to set2 result in dest
 }
 }
-begin
-     asm
-        movl 8(%ebp),%esi
-        movl 12(%ebp),%ebx
-        movl 16(%ebp),%edi
+asm
+        movl set1,%esi
+        movl set2,%ebx
+        movl dest,%edi
         movl $8,%ecx
         movl $8,%ecx
     .LMSUBSETS1:
     .LMSUBSETS1:
         lodsl
         lodsl
@@ -171,19 +153,17 @@ begin
         addl $4,%ebx
         addl $4,%ebx
         decl %ecx
         decl %ecx
         jnz .LMSUBSETS1
         jnz .LMSUBSETS1
-     end;
 end;
 end;
 
 
 
 
-procedure do_symdif_sets(set1,set2,dest : pointer);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SYMDIF_SETS'];
+procedure do_symdif_sets(set1,set2,dest:pointer);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SYMDIF_SETS'];
 {
 {
    computes the symetric diff from set1 to set2 result in dest
    computes the symetric diff from set1 to set2 result in dest
 }
 }
-begin
-     asm
-        movl 8(%ebp),%esi
-        movl 12(%ebp),%ebx
-        movl 16(%ebp),%edi
+asm
+        movl set1,%esi
+        movl set2,%ebx
+        movl dest,%edi
         movl $8,%ecx
         movl $8,%ecx
     .LMSYMDIFSETS1:
     .LMSYMDIFSETS1:
         lodsl
         lodsl
@@ -193,17 +173,16 @@ begin
         addl $4,%ebx
         addl $4,%ebx
         decl %ecx
         decl %ecx
         jnz .LMSYMDIFSETS1
         jnz .LMSYMDIFSETS1
-     end;
 end;
 end;
 
 
-procedure do_comp_sets(set1,set2 : pointer);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_COMP_SETS'];
+
+procedure do_comp_sets(set1,set2 : pointer);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_COMP_SETS'];
 {
 {
   compares set1 and set2 zeroflag is set if they are equal
   compares set1 and set2 zeroflag is set if they are equal
 }
 }
-begin
-     asm
-        movl 8(%ebp),%esi
-        movl 12(%ebp),%edi
+asm
+        movl set1,%esi
+        movl set2,%edi
         movl $8,%ecx
         movl $8,%ecx
     .LMCOMPSETS1:
     .LMCOMPSETS1:
         lodsl
         lodsl
@@ -217,22 +196,20 @@ begin
           we have zero flag set, and that what is expected }
           we have zero flag set, and that what is expected }
         cmpl %eax,%eax
         cmpl %eax,%eax
     .LMCOMPSETEND:
     .LMCOMPSETEND:
-     end;
 end;
 end;
 
 
 
 
 {$ifdef LARGESETS}
 {$ifdef LARGESETS}
 
 
-procedure do_set(p : pointer;b : word);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SET_WORD'];
+procedure do_set(p : pointer;b : word);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SET_WORD'];
 {
 {
   sets the element b in set p works for sets larger than 256 elements
   sets the element b in set p works for sets larger than 256 elements
   not yet use by the compiler so
   not yet use by the compiler so
 }
 }
-begin
-    asm
+asm
        pushl %eax
        pushl %eax
-       movl 8(%ebp),%edi
-       movw 12(%ebp),%ax
+       movl p,%edi
+       movw b,%ax
        andl $0xfff8,%eax
        andl $0xfff8,%eax
        shrl $3,%eax
        shrl $3,%eax
        addl %eax,%edi
        addl %eax,%edi
@@ -240,20 +217,18 @@ begin
        andl $7,%eax
        andl $7,%eax
        btsl %eax,(%edi)
        btsl %eax,(%edi)
        popl %eax
        popl %eax
-    end;
 end;
 end;
 
 
 
 
-procedure do_in(p : pointer;b : word);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_IN_WORD'];
+procedure do_in(p : pointer;b : word);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_IN_WORD'];
 {
 {
   tests if the element b is in the set p the carryflag is set if it present
   tests if the element b is in the set p the carryflag is set if it present
   works for sets larger than 256 elements
   works for sets larger than 256 elements
 }
 }
-begin
-     asm
+asm
         pushl %eax
         pushl %eax
-        movl 8(%ebp),%edi
-        movw 12(%ebp),%ax
+        movl p,%edi
+        movw b,%ax
         andl $0xfff8,%eax
         andl $0xfff8,%eax
         shrl $3,%eax
         shrl $3,%eax
         addl %eax,%edi
         addl %eax,%edi
@@ -261,21 +236,18 @@ begin
         andl $7,%eax
         andl $7,%eax
         btl %eax,(%edi)
         btl %eax,(%edi)
         popl %eax
         popl %eax
-     end;
 end;
 end;
 
 
 
 
-procedure add_sets(set1,set2,dest : pointer;size : longint);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_ADD_SETS_SIZE'];
+procedure add_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_ADD_SETS_SIZE'];
 {
 {
   adds set1 and set2 into set dest size is the number of bytes in the set
   adds set1 and set2 into set dest size is the number of bytes in the set
 }
 }
-
-begin
-   asm
-      movl 8(%ebp),%esi
-      movl 12(%ebp),%ebx
-      movl 16(%ebp),%edi
-      movl 20(%ebp),%ecx
+asm
+      movl set1,%esi
+      movl set2,%ebx
+      movl dest,%edi
+      movl size,%ecx
   .LMADDSETSIZES1:
   .LMADDSETSIZES1:
       lodsl
       lodsl
       orl (%ebx),%eax
       orl (%ebx),%eax
@@ -283,21 +255,19 @@ begin
       addl $4,%ebx
       addl $4,%ebx
       decl %ecx
       decl %ecx
       jnz .LMADDSETSIZES1
       jnz .LMADDSETSIZES1
-   end;
 end;
 end;
 
 
 
 
-procedure mul_sets(set1,set2,dest : pointer;size : longint);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_MUL_SETS_SIZE'];
+procedure mul_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_MUL_SETS_SIZE'];
 {
 {
   multiplies (i.E. takes common elements of) set1 and set2 result put in
   multiplies (i.E. takes common elements of) set1 and set2 result put in
   dest size is the number of bytes in the set
   dest size is the number of bytes in the set
 }
 }
-begin
-      asm
-         movl 8(%ebp),%esi
-         movl 12(%ebp),%ebx
-         movl 16(%ebp),%edi
-         movl 20(%ebp),%ecx
+asm
+         movl set1,%esi
+         movl set2,%ebx
+         movl dest,%edi
+         movl size,%ecx
      .LMMULSETSIZES1:
      .LMMULSETSIZES1:
          lodsl
          lodsl
          andl (%ebx),%eax
          andl (%ebx),%eax
@@ -305,17 +275,15 @@ begin
          addl $4,%ebx
          addl $4,%ebx
          decl %ecx
          decl %ecx
          jnz .LMMULSETSIZES1
          jnz .LMMULSETSIZES1
-      end;
 end;
 end;
 
 
 
 
-procedure sub_sets(set1,set2,dest : pointer;size : longint);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SUB_SETS_SIZE'];
-begin
-      asm
-         movl 8(%ebp),%esi
-         movl 12(%ebp),%ebx
-         movl 16(%ebp),%edi
-         movl 20(%ebp),%ecx
+procedure sub_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SUB_SETS_SIZE'];
+asm
+         movl set1,%esi
+         movl set2,%ebx
+         movl dest,%edi
+         movl size,%ecx
      .LMSUBSETSIZES1:
      .LMSUBSETSIZES1:
          lodsl
          lodsl
          movl (%ebx),%edx
          movl (%ebx),%edx
@@ -325,20 +293,18 @@ begin
          addl $4,%ebx
          addl $4,%ebx
          decl %ecx
          decl %ecx
          jnz .LMSUBSETSIZES1
          jnz .LMSUBSETSIZES1
-      end;
 end;
 end;
 
 
 
 
-procedure sym_sub_sets(set1,set2,dest : pointer;size : longint);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SYMDIF_SETS_SIZE'];
+procedure sym_sub_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_SYMDIF_SETS_SIZE'];
 {
 {
    computes the symetric diff from set1 to set2 result in dest
    computes the symetric diff from set1 to set2 result in dest
 }
 }
-begin
-   asm
-      movl 8(%ebp),%esi
-      movl 12(%ebp),%ebx
-      movl 16(%ebp),%edi
-      movl 20(%ebp),%ecx
+asm
+      movl set1,%esi
+      movl set2,%ebx
+      movl dest,%edi
+      movl size,%ecx
   .LMSYMDIFSETSIZE1:
   .LMSYMDIFSETSIZE1:
       lodsl
       lodsl
       movl (%ebx),%edx
       movl (%ebx),%edx
@@ -347,16 +313,14 @@ begin
       addl $4,%ebx
       addl $4,%ebx
       decl %ecx
       decl %ecx
       jnz .LMSYMDIFSETSIZE1
       jnz .LMSYMDIFSETSIZE1
-   end;
 end;
 end;
 
 
 
 
-procedure comp_sets(set1,set2 : pointer;size : longint);[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_COMP_SETS_SIZE'];
-begin
-   asm
-      movl 8(%ebp),%esi
-      movl 12(%ebp),%edi
-      movl 16(%ebp),%ecx
+procedure comp_sets(set1,set2 : pointer;size : longint);assembler;[public,alias: {$ifdef FPCNAMES}'FPC_'+{$endif}'SET_COMP_SETS_SIZE'];
+asm
+      movl set1,%esi
+      movl set2,%edi
+      movl size,%ecx
   .LMCOMPSETSIZES1:
   .LMCOMPSETSIZES1:
       lodsl
       lodsl
       movl (%edi),%edx
       movl (%edi),%edx
@@ -369,14 +333,16 @@ begin
         we have zero flag set, and that what is expected }
         we have zero flag set, and that what is expected }
       cmpl %eax,%eax
       cmpl %eax,%eax
   .LMCOMPSETSIZEEND:
   .LMCOMPSETSIZEEND:
-   end;
 end;
 end;
 
 
 {$endif LARGESET}
 {$endif LARGESET}
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.4  1998-09-14 10:48:12  peter
+  Revision 1.5  1998-10-22 12:48:29  peter
+    * fixed for stackaligment also on 4 bytes, never use 'ret $..' direct
+
+  Revision 1.4  1998/09/14 10:48:12  peter
     * FPC_ names
     * FPC_ names
     * Heap manager is now system independent
     * Heap manager is now system independent