Browse Source

* rename laod/copystring -> load/copyshortstring
* fixed int-bool cnv bug
+ char-ansistring conversion

peter 27 years ago
parent
commit
3df27389c0
4 changed files with 61 additions and 130 deletions
  1. 9 3
      compiler/cg386add.pas
  2. 7 2
      compiler/cg386cal.pas
  3. 38 12
      compiler/cg386cnv.pas
  4. 7 113
      compiler/cg386ld.pas

+ 9 - 3
compiler/cg386add.pas

@@ -167,12 +167,13 @@ implementation
                         emitcall('FPC_ANSICAT',true);
                         unused:=savedunused;
                         p^.location.register:=getexplicitregister32(R_EAX);
+                        p^.location.loc:=LOC_REGISTER;
                         emit_reg_reg(A_MOV,S_L,R_EAX,p^.location.register);
                         popusedregisters(pushedregs);
                         maybe_loadesi;
                         ungetiftemp(p^.left^.location.reference);
                         ungetiftemp(p^.right^.location.reference);
-                        gettempofsizereference(4,hr);
+                        gettempofsizereference(4,p^.location.reference);
                         temptoremove^.concat(new(ptemptodestroy,init(hr,p^.resulttype)));
                         exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,p^.location.register,
                           newreference(hr))));
@@ -243,7 +244,7 @@ implementation
                              { release the registers }
                              del_reference(p^.left^.location.reference);
                              gettempofsizereference(256,href);
-                             copystring(href,p^.left^.location.reference,255);
+                             copyshortstring(href,p^.left^.location.reference,255);
                              ungetiftemp(p^.left^.location.reference);
 
                              { does not hurt: }
@@ -1404,7 +1405,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.24  1998-11-07 12:49:30  peter
+  Revision 1.25  1998-11-16 15:35:35  peter
+    * rename laod/copystring -> load/copyshortstring
+    * fixed int-bool cnv bug
+    + char-ansistring conversion
+
+  Revision 1.24  1998/11/07 12:49:30  peter
     * fixed ansicompare which returns signed
 
   Revision 1.23  1998/10/29 15:42:43  florian

+ 7 - 2
compiler/cg386cal.pas

@@ -553,7 +553,7 @@ implementation
                                   { generate copy }
                                   if is_shortstring(p^.resulttype) then
                                     begin
-                                       copystring(stackref,p^.left^.location.reference,
+                                       copyshortstring(stackref,p^.left^.location.reference,
                                          pstringdef(p^.resulttype)^.len);
                                     end
                                   else
@@ -1552,7 +1552,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.43  1998-11-15 16:32:33  florian
+  Revision 1.44  1998-11-16 15:35:36  peter
+    * rename laod/copystring -> load/copyshortstring
+    * fixed int-bool cnv bug
+    + char-ansistring conversion
+
+  Revision 1.43  1998/11/15 16:32:33  florian
     * some stuff of Pavel implement (win32 dll creation)
     * bug with ansistring function results fixed
 

+ 38 - 12
compiler/cg386cnv.pas

@@ -405,7 +405,7 @@ implementation
                       stringdispose(p^.location.reference.symbol);
                       gettempofsizereference(p^.resulttype^.size,p^.location.reference);
                       del_reference(p^.left^.location.reference);
-                      copystring(p^.location.reference,p^.left^.location.reference,pstringdef(p^.resulttype)^.len);
+                      copyshortstring(p^.location.reference,p^.left^.location.reference,pstringdef(p^.resulttype)^.len);
                       ungetiftemp(p^.left^.location.reference);
                    end;
                  st_longstring:
@@ -597,18 +597,39 @@ implementation
 
 
     procedure second_char_to_string(p,hp : ptree;convtyp : tconverttype);
+      var
+        pushed : tpushed;
       begin
          clear_location(p^.location);
          p^.location.loc:=LOC_MEM;
-         gettempofsizereference(256,p^.location.reference);
-         { call loadstring with correct left and right }
-         p^.right:=p^.left;
-         p^.left:=p;
-         loadstring(p);
-         p^.left:=nil; { reset left tree, which is empty }
-         { p^.right is not disposed for typeconv !! PM }
-         disposetree(p^.right);
-         p^.right:=nil;
+         case pstringdef(p^.resulttype)^.string_typ of
+           st_shortstring :
+             begin
+               gettempofsizereference(256,p^.location.reference);
+               { call loadstring with correct left and right }
+               p^.right:=p^.left;
+               p^.left:=p;
+               loadshortstring(p);
+               p^.left:=nil; { reset left tree, which is empty }
+               { p^.right is not disposed for typeconv !! PM }
+               disposetree(p^.right);
+               p^.right:=nil;
+             end;
+           st_ansistring :
+             begin
+               gettempofsizereference(4,p^.location.reference);
+               {temptoremove^.concat(new(ptemptodestroy,init(p^.location.reference,p^.resulttype)));}
+               exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,0,newreference(p^.location.reference))));
+               pushusedregisters(pushed,$ff);
+               emit_push_loc(p^.left^.location);
+               emitpushreferenceaddr(exprasmlist,p^.location.reference);
+               emitcall('FPC_CHAR2ANSI',true);
+               popusedregisters(pushed);
+               maybe_loadesi;
+             end;
+           else
+            internalerror(4179);
+        end;
       end;
 
 
@@ -990,7 +1011,7 @@ implementation
                 exprasmlist^.concat(new(pai386,op_reg_reg(A_MOVZX,S_BW,hregister,p^.location.register)));
               end;
           4 : begin
-                p^.location.register:=reg16toreg32(hregister);
+                p^.location.register:=reg8toreg32(hregister);
                 exprasmlist^.concat(new(pai386,op_reg_reg(A_MOVZX,S_BL,hregister,p^.location.register)));
               end;
          else
@@ -1286,7 +1307,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.31  1998-11-05 12:02:30  peter
+  Revision 1.32  1998-11-16 15:35:38  peter
+    * rename laod/copystring -> load/copyshortstring
+    * fixed int-bool cnv bug
+    + char-ansistring conversion
+
+  Revision 1.31  1998/11/05 12:02:30  peter
     * released useansistring
     * removed -Sv, its now available in fpc modes
 

+ 7 - 113
compiler/cg386ld.pas

@@ -358,7 +358,7 @@ implementation
                        { we do not need destination anymore }
                        del_reference(p^.left^.location.reference);
                        del_reference(p^.right^.location.reference);
-                       loadstring(p);
+                       loadshortstring(p);
                        ungetiftemp(p^.right^.location.reference);
                     end;
                 end
@@ -578,117 +578,6 @@ implementation
         vtWideString = 15;
         vtInt64      = 16;
 
-    procedure emit_mov_loc_ref(const t:tlocation;const ref:treference);
-      begin
-        case t.loc of
-          LOC_REGISTER,
-         LOC_CREGISTER : begin
-                           exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,
-                             t.register,newreference(ref))));
-                           ungetregister32(t.register); { the register is not needed anymore }
-                         end;
-               LOC_MEM,
-         LOC_REFERENCE : begin
-                           if t.reference.isintvalue then
-                             exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,
-                               t.reference.offset,newreference(ref))))
-                           else
-                             begin
-                               exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
-                                 newreference(t.reference),R_EDI)));
-                               exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,
-                                 R_EDI,newreference(ref))));
-                             end;
-                           ungetiftemp(t.reference);
-                         end;
-        else
-         internalerror(330);
-        end;
-      end;
-
-
-    procedure emit_push_loc(const t:tlocation);
-      begin
-        case t.loc of
-          LOC_REGISTER,
-         LOC_CREGISTER : begin
-                           exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,t.register)));
-                           ungetregister32(t.register); { the register is not needed anymore }
-                         end;
-               LOC_MEM,
-         LOC_REFERENCE : begin
-                           if t.reference.isintvalue then
-                             exprasmlist^.concat(new(pai386,op_const(A_PUSH,S_L,t.reference.offset)))
-                           else
-                             exprasmlist^.concat(new(pai386,op_ref(A_PUSH,S_L,newreference(t.reference))));
-                           ungetiftemp(t.reference);
-                         end;
-        else
-         internalerror(330);
-        end;
-      end;
-
-
-    procedure emit_to_reference(var p:ptree);
-      begin
-        case p^.location.loc of
-               LOC_FPU : begin
-                           reset_reference(p^.location.reference);
-                           gettempofsizereference(10,p^.location.reference);
-                           floatstore(pfloatdef(p^.resulttype)^.typ,p^.location.reference);
-                           p^.location.loc:=LOC_REFERENCE;
-                         end;
-               LOC_MEM,
-         LOC_REFERENCE : ;
-        else
-         internalerror(333);
-        end;
-      end;
-
-
-    procedure emit_lea_loc_ref(const t:tlocation;const ref:treference);
-      begin
-        case t.loc of
-               LOC_MEM,
-         LOC_REFERENCE : begin
-                           if t.reference.isintvalue then
-                             internalerror(331)
-                           else
-                             begin
-                               exprasmlist^.concat(new(pai386,op_ref_reg(A_LEA,S_L,
-                                 newreference(t.reference),R_EDI)));
-                               exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,
-                                 R_EDI,newreference(ref))));
-                             end;
-                           ungetiftemp(t.reference);
-                         end;
-        else
-         internalerror(332);
-        end;
-      end;
-
-
-    procedure emit_push_lea_loc(const t:tlocation);
-      begin
-        case t.loc of
-               LOC_MEM,
-         LOC_REFERENCE : begin
-                           if t.reference.isintvalue then
-                             internalerror(331)
-                           else
-                             begin
-                               exprasmlist^.concat(new(pai386,op_ref_reg(A_LEA,S_L,
-                                 newreference(t.reference),R_EDI)));
-                               exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,R_EDI)));
-                             end;
-                           ungetiftemp(t.reference);
-                         end;
-        else
-         internalerror(332);
-        end;
-      end;
-
-
     procedure secondarrayconstruct(var p : ptree);
       var
         hp    : ptree;
@@ -790,7 +679,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.26  1998-11-10 10:09:10  peter
+  Revision 1.27  1998-11-16 15:35:39  peter
+    * rename laod/copystring -> load/copyshortstring
+    * fixed int-bool cnv bug
+    + char-ansistring conversion
+
+  Revision 1.26  1998/11/10 10:09:10  peter
     * va_list -> array of const
 
   Revision 1.25  1998/11/05 12:02:35  peter