public override IEnumerable <TmsCommand> Translate(Z80AssemblyParsing.Commands.NegateCommand z80Command) { var negOneByte = new LabeledAddressTmsOperand(_labelHighlighter.NegOneByteLabel); var accumulatorLowByte = new IndirectRegisterTmsOperand(WorkspaceRegister.R12); var accumulatorOperand = new RegisterTmsOperand(_registerMap[Z80AssemblyParsing.Register.A]); yield return(new MoveByteCommand(z80Command, negOneByte, accumulatorLowByte)); yield return(new NegateCommand(z80Command, accumulatorOperand)); }
public override IEnumerable <TmsCommand> Translate(Z80AssemblyParsing.Commands.RotateRightCarryCommand rotateRightCarryCommand) { var registerOperand = new RegisterTmsOperand(_registerMap[Z80AssemblyParsing.Register.A]); var indirectRegisterOperand = new IndirectRegisterTmsOperand(WorkspaceRegister.R12); var oneBitOperand = new ImmediateTmsOperand(1); yield return(new MoveByteCommand(rotateRightCarryCommand, registerOperand, indirectRegisterOperand)); yield return(new ShiftRightCircularCommand(rotateRightCarryCommand, oneBitOperand, registerOperand)); }
public override IEnumerable <TmsCommand> Translate(T logicCommand) { var zeroByte = new LabeledAddressTmsOperand(_labelHighlighter.ZeroByteLabel); var accumulatorLowByte = new IndirectRegisterTmsOperand(WorkspaceRegister.R12); var accumulatorOperand = new RegisterTmsOperand(_registerMap[Z80AssemblyParsing.Register.A]); if (logicCommand.Operand is Z80AssemblyParsing.Operands.IndirectRegisterOperand && MustUnifyRegisterPairs(logicCommand.Operand, out var copyFromOperand, out var copyToOperand, out var unifiedOperand)) { yield return(new MoveByteCommand(logicCommand, copyFromOperand, copyToOperand)); yield return(GetEquivCommand <TmsEquivCommand>(logicCommand, unifiedOperand, accumulatorOperand)); }
protected bool MustUnifyRegisterPairs(Z80AssemblyParsing.Operand z80operand, out Operand copyFromOperand, out Operand copyToOperand, out Operand unifiedOperand) { if (z80operand is Z80Operands.IndirectRegisterOperand indirectRegisterOperand && !RegisterPairIsMappedToSameWorkspaceRegister(indirectRegisterOperand.Register)) { var registerPair = indirectRegisterOperand.Register; if (_unsplitableRegisters.Contains(registerPair)) { throw new Exception("Can't do unify operation for " + registerPair); } else { copyFromOperand = new RegisterTmsOperand(_registerMap[GetLastRegisterInPair(registerPair)]); copyToOperand = new IndirectRegisterTmsOperand(GetRegisterPointingToLowerByte(registerPair)); unifiedOperand = new IndirectRegisterTmsOperand(_registerMap[GetFirstRegisterInPair(registerPair)]); } return(true); }