Mercurial > hg > CbC > old > device
diff mc-nop-386.c @ 39:c63c4fdeb9a7
struct done.
author | kono |
---|---|
date | Tue, 11 Feb 2003 22:36:51 +0900 |
parents | d48d952da354 |
children | 060d1e549fec |
line wrap: on
line diff
--- a/mc-nop-386.c Tue Feb 11 11:26:51 2003 +0900 +++ b/mc-nop-386.c Tue Feb 11 22:36:51 2003 +0900 @@ -746,7 +746,8 @@ void emit_copy(int from,int to,int length,int offset) { - if (length<0) return; + int fix = 0; + if (length<=0) return; switch (length) { case 0: break; case 1: @@ -769,17 +770,24 @@ emit_copy(from,to,2,offset); if(length>0) emit_copy(from,to,length,offset); - return; + break; } - use_register(from,REG_EDI,1); - use_register(to, REG_ESI,1); - use_register(dreg,REG_ECX,1); + use_register(from,REG_ESI,1); + use_register(to, REG_EDI,1); + use_register(dreg,REG_ECX,0); printf("\tmovl $%d,%%ecx\n",length/4); + fix = (length/4)*4; printf("\tcld\n\trep\n\tmovsl\n"); if(length%4) { emit_copy(from,to,length,offset+length/4); } } + /* this code is necessary for the value of assignment or function call */ + /* otherwise we don't need this */ + if (fix) printf("\tsubl $%d,%s\n",fix,register_name(to,0)); + if(creg!=to) { + free_register(creg); creg=to; + } } int @@ -1114,7 +1122,7 @@ /* structure assignment */ e2 = cadr(e1); /* pointer variable to the struct */ e3 = cadr(e2); /* offset of the variable (distination) */ - e4 = caddr(e1); /* rright value (source) */ + e4 = caddr(e1); /* right value (source) */ sz = cadddr(e1); /* size of struct or union */ g_expr(e4); emit_push();