comparison mc-nop-386.c @ 14:77c0710a8729

struct copy
author kono
date Mon, 17 Jan 2000 01:20:59 +0900
parents a8a812dace23
children 6667dbd4f718
comparison
equal deleted inserted replaced
13:a8a812dace23 14:77c0710a8729
755 printf("\tmovl %d(%s),%s\n",offset,from, drn); 755 printf("\tmovl %d(%s),%s\n",offset,from, drn);
756 printf("\tmovl %s,%d(%s)\n",drn, offset,to); 756 printf("\tmovl %s,%d(%s)\n",drn, offset,to);
757 break; 757 break;
758 default: 758 default:
759 if (length <=MAX_COPY_LEN) { 759 if (length <=MAX_COPY_LEN) {
760 for(;length>4;length-=4,offset+=4); 760 for(;length>=4;length-=4,offset+=4)
761 emit_copy(from,to,4,offset); 761 emit_copy(from,to,4,offset);
762 for(;length>2;length-=2,offset+=2); 762 for(;length>=2;length-=2,offset+=2)
763 emit_copy(from,to,2,offset); 763 emit_copy(from,to,2,offset);
764 if(length>0) 764 if(length>0)
765 emit_copy(from,to,length,offset); 765 emit_copy(from,to,length,offset);
766 return; 766 return;
767 } 767 }
768 printf("\texch %%edi,%s\n",from); 768 printf("\txchg %%edi,%s\n",from);
769 printf("\texch %%esi,%s\n",to); 769 printf("\txchg %%esi,%s\n",to);
770 printf("\texch %%ecx,%s\n",drn); 770 printf("\txchg %%ecx,%s\n",drn);
771 printf("\tmovl $%d,%%ecx\n",length); 771 printf("\tmovl $%d,%%ecx\n",length/4);
772 printf("\tcld\n\trep\n\tmovsl\n"); 772 printf("\tcld\n\trep\n\tmovsl\n");
773 printf("\texch %%ecx,%s\n",drn); 773 printf("\txchg %%ecx,%s\n",drn);
774 printf("\texch %%esi,%s\n",to); 774 printf("\txchg %%esi,%s\n",to);
775 printf("\texch %%edi,%s\n",from); 775 printf("\txchg %%edi,%s\n",from);
776 if(length%4) {
777 emit_copy("%esi","%edi",length,offset+length/4);
778 }
776 } 779 }
777 } 780 }
778 781
779 int 782 int
780 struct_push(int e4,int t) 783 struct_push(int e4,int t)
781 { 784 {
782 int e5; 785 int length;
783 g_expr(e4); 786 g_expr(e4);
784 e5=size(t); 787 length=size(t);
785 if(e5%size_of_int) { 788 if(length%size_of_int) {
786 e5 += size_of_int - (e5%size_of_int); 789 length += size_of_int - (length%size_of_int);
787 } 790 }
788 printf("\tsubl $%d,%%esp\n",e5); 791 printf("\tsubl $%d,%%esp\n",length);
789 if (e5<=MAX_COPY_LEN) 792 if (length<=MAX_COPY_LEN)
790 emit_copy(crn,"%esp",e5,0); 793 emit_copy(crn,"%esp",length,0);
791 else { 794 else {
792 printf("\tpushl %%edi\n"); 795 printf("\tpushl %%edi\n");
793 printf("\tpushl %%esi\n"); 796 printf("\tpushl %%esi\n");
794 printf("\tpushl %%ecx\n"); 797 printf("\tpushl %%ecx\n");
795 printf("\tleal 12(%%esp),%%di\n"); 798 printf("\tleal 12(%%esp),%%di\n");
796 if (rname[creg]!=REG_ESI) 799 if (rname[creg]!=REG_ESI)
797 printf("\tmovl %s,%%esi\n",crn); 800 printf("\tmovl %s,%%esi\n",crn);
798 printf("\tmovl $%d,%%ecx\n",e5); 801 printf("\tmovl $%d,%%ecx\n",length/size_of_int);
799 printf("\tcld\n\trep\n\tmovsl\n"); 802 printf("\tcld\n\trep\n\tmovsl\n");
800 printf("\tpopl %%ecx\n"); 803 printf("\tpopl %%ecx\n");
801 printf("\tpopl %%esi\n"); 804 printf("\tpopl %%esi\n");
802 printf("\tpopl %%edi\n"); 805 printf("\tpopl %%edi\n");
803 } 806 }
804 return e5/size_of_int; 807 return length/size_of_int;
805 } 808 }
806 809
807 void 810 void
808 function(int e1) 811 function(int e1)
809 { 812 {
1030 char *xrn; 1033 char *xrn;
1031 1034
1032 e2 = cadr(e1); 1035 e2 = cadr(e1);
1033 e3 = cadr(e2); 1036 e3 = cadr(e2);
1034 e4 = caddr(e1); 1037 e4 = caddr(e1);
1035 sz = size(cadr(e2)); /* cld rep movsb */ 1038 sz = cadddr(e1); /* cld rep movsb */
1036 g_expr(e4); 1039 g_expr(e4);
1037 emit_push(); 1040 emit_push();
1038 g_expr(e2); 1041 g_expr(e2);
1039 xrn = emit_pop(0); 1042 xrn = emit_pop(0);
1040 emit_copy(crn,xrn,sz,0); 1043 emit_copy(crn,xrn,sz,0);