public void EmitStringInstruction(IntelInstruction instr, CodeEmitterOld emitter) { this.emitter = emitter; bool incSi = false; bool incDi = false; this.instrCur = instr; switch (instrCur.code) { default: throw new ApplicationException("NYI"); case Opcode.cmps: case Opcode.cmpsb: emitter.Assign( orw.FlagGroup(IntelInstruction.DefCc(Opcode.cmp)), new ConditionOf( new BinaryExpression(Operator.Sub, instrCur.dataWidth, MemSi(), MemDi()))); incSi = true; incDi = true; break; case Opcode.lods: case Opcode.lodsb: emitter.Assign(RegAl, MemSi()); incSi = true; break; case Opcode.movs: case Opcode.movsb: { Identifier tmp = frame.CreateTemporary(instrCur.dataWidth); emitter.Assign(tmp, MemSi()); emitter.Store(MemDi(), tmp); incSi = true; incDi = true; break; } case Opcode.ins: case Opcode.insb: { Identifier regDX = orw.AluRegister(Registers.edx, instrCur.addrWidth); emitter.Store(MemDi(), emitter.PseudoProc("__in", instrCur.dataWidth, regDX)); incDi = true; break; } case Opcode.outs: case Opcode.outsb: { Identifier regDX = orw.AluRegister(Registers.edx, instrCur.addrWidth); emitter.SideEffect("__out" + RegAl.DataType.Prefix, regDX, RegAl); incSi = true; break; } case Opcode.scas: case Opcode.scasb: emitter.Assign( orw.FlagGroup(IntelInstruction.DefCc(Opcode.cmp)), new ConditionOf( new BinaryExpression(Operator.Sub, instrCur.dataWidth, RegAl, MemDi()))); incDi = true; break; case Opcode.stos: case Opcode.stosb: emitter.Store(MemDi(), RegAl); incDi = true; break; } if (incSi) { emitter.Assign(RegSi, new BinaryExpression(Operator.Add, instrCur.addrWidth, RegSi, new Constant(instrCur.addrWidth, instrCur.dataWidth.Size))); } if (incDi) { emitter.Assign(RegDi, new BinaryExpression(Operator.Add, instrCur.addrWidth, RegDi, new Constant(instrCur.addrWidth, instrCur.dataWidth.Size))); } }