p = p->link;
                }
        }
+       
+       // movb elimination.
+       // movb is simulated by the linker
+       // when a register other than ax, bx, cx, dx
+       // is used, so rewrite to other instructions
+       // when possible.  a movb into a register
+       // can smash the entire 32-bit register without
+       // causing any trouble.
+       for(r=firstr; r!=R; r=r->link) {
+               p = r->prog;
+               if(p->as == AMOVB && regtyp(&p->to)) {
+                       // movb into register.
+                       // from another register or constant can be movl.
+                       if(regtyp(&p->from) || p->from.type == D_CONST)
+                               p->as = AMOVL;
+                       else
+                               p->as = AMOVBLZX;
+               }
+       }
 
        // constant propagation
        // find MOV $con,R followed by
        for(r=firstr; r!=R; r=r->link) {
                p = r->prog;
                switch(p->as) {
+               case AMOVB:
+               case AMOVW:
                case AMOVL:
                        if(regtyp(&p->to))
                        if(regtyp(&p->from)) {
                        }
                        break;
 
+               case AADDB:
                case AADDL:
                case AADDW:
                        if(p->from.type != D_CONST || needc(p->link))
                        }
                        break;
 
+               case ASUBB:
                case ASUBL:
                case ASUBW:
                        if(p->from.type != D_CONST || needc(p->link))
                case AMOVSL:
                        return 0;
 
+               case AMOVB:
+               case AMOVW:
                case AMOVL:
                        if(p->to.type == v1->type)
                                goto gotit;
 
 
        case ANOP:      /* rhs store */
+       case AMOVB:
+       case AMOVW:
        case AMOVL:
        case AMOVBLSX:
        case AMOVBLZX:
        case AXORB:
        case AXORL:
        case AXORW:
-       case AMOVB:
-       case AMOVW:
                if(copyas(&p->to, v))
                        return 2;
                goto caseread;