Mercurial > hg > CbC > old > device
comparison mc-nop-386.c @ 37:412ad2e6c2a2
struct copy
author | kono |
---|---|
date | Mon, 10 Feb 2003 22:29:12 +0900 |
parents | 9f89cef85b41 |
children | d48d952da354 |
comparison
equal
deleted
inserted
replaced
36:9f89cef85b41 | 37:412ad2e6c2a2 |
---|---|
53 /* static void st_indexx(int byte, int n, int xreg); */ | 53 /* static void st_indexx(int byte, int n, int xreg); */ |
54 static void string(int e1); | 54 static void string(int e1); |
55 static void tosop(int op); | 55 static void tosop(int op); |
56 static void div_cleanup(char *orn); | 56 static void div_cleanup(char *orn); |
57 static void use_register(int virt, int real, int move); | 57 static void use_register(int virt, int real, int move); |
58 static void emit_copy(char *from,char *to,int length,int offset); | |
58 | 59 |
59 extern int error(int n); | 60 extern int error(int n); |
60 extern int fwdlabel(void); | 61 extern int fwdlabel(void); |
61 extern void fwddef(int l); | 62 extern void fwddef(int l); |
62 extern int backdef(void); | 63 extern int backdef(void); |
561 use_register(creg,REG_EAX,0); | 562 use_register(creg,REG_EAX,0); |
562 g_expr(cadddr(e1)); | 563 g_expr(cadddr(e1)); |
563 /* use_register(creg,e4,1); */ | 564 /* use_register(creg,e4,1); */ |
564 use_register(creg,REG_EAX,1); | 565 use_register(creg,REG_EAX,1); |
565 fwddef(e3); | 566 fwddef(e3); |
567 return; | |
568 case RSTRUCT: | |
569 g_expr(e2); | |
566 return; | 570 return; |
567 case SASS: | 571 case SASS: |
568 sassign(e1); | 572 sassign(e1); |
569 return; | 573 return; |
570 case ASS: case CASS: | 574 case ASS: case CASS: |
791 emit_copy(register_name(creg,0),"%esp",length,0); | 795 emit_copy(register_name(creg,0),"%esp",length,0); |
792 else { | 796 else { |
793 printf("\tpushl %%edi\n"); | 797 printf("\tpushl %%edi\n"); |
794 printf("\tpushl %%esi\n"); | 798 printf("\tpushl %%esi\n"); |
795 printf("\tpushl %%ecx\n"); | 799 printf("\tpushl %%ecx\n"); |
796 printf("\tleal 12(%%esp),%%di\n"); | 800 printf("\tleal 12(%%esp),%%edi\n"); |
797 if (rname[creg]!=REG_ESI) | 801 if (rname[creg]!=REG_ESI) |
798 printf("\tmovl %s,%%esi\n",register_name(creg,0)); | 802 printf("\tmovl %s,%%esi\n",register_name(creg,0)); |
799 printf("\tmovl $%d,%%ecx\n",length/size_of_int); | 803 printf("\tmovl $%d,%%ecx\n",length/size_of_int); |
800 printf("\tcld\n\trep\n\tmovsl\n"); | 804 printf("\tcld\n\trep\n\tmovsl\n"); |
801 printf("\tpopl %%ecx\n"); | 805 printf("\tpopl %%ecx\n"); |
1105 { | 1109 { |
1106 int e2,e3,e4,sz; | 1110 int e2,e3,e4,sz; |
1107 char *xrn; | 1111 char *xrn; |
1108 | 1112 |
1109 /* structure assignment */ | 1113 /* structure assignment */ |
1110 e2 = cadr(e1); | 1114 e2 = cadr(e1); /* pointer variable to the struct */ |
1111 e3 = cadr(e2); | 1115 e3 = cadr(e2); /* offset of the variable (distination) */ |
1112 e4 = caddr(e1); | 1116 e4 = caddr(e1); /* rright value (source) */ |
1113 sz = size(cadr(e2)); /* cld rep movsb */ | 1117 sz = cadddr(e1); /* size of struct or union */ |
1114 g_expr(e4); | 1118 g_expr(e4); |
1115 emit_push(); | 1119 emit_push(); |
1116 g_expr(e2); | 1120 g_expr(e2); |
1117 xrn = register_name(emit_pop(0),0); | 1121 xrn = register_name(emit_pop(0),0); |
1118 | 1122 emit_copy(xrn,register_name(creg,0),sz,0); |
1119 return; | 1123 return; |
1120 } | 1124 } |
1121 | 1125 |
1122 void | 1126 void |
1123 assign(int e1) | 1127 assign(int e1) |