Cosmos/source/Indy.IL2CPU/Assembler/x86/_Infra/InstructionWithDestination.cs
2008-11-08 13:00:37 +00:00

58 lines
No EOL
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Indy.IL2CPU.Assembler.X86 {
public abstract class InstructionWithDestination : Instruction {
public ElementReference DestinationRef {
get;
set;
}
public Guid DestinationReg {
get;
set;
}
public uint DestinationValue {
get;
set;
}
public bool DestinationIsIndirect {
get;
set;
}
public int DestinationDisplacement {
get;
set;
}
protected string GetDestinationAsString() {
string xDest = "";
if (DestinationRef != null) {
xDest = DestinationRef.ToString();
} else {
if (DestinationReg != Guid.Empty) {
xDest = Registers.GetRegisterName(DestinationReg);
} else {
xDest = "0x" + DestinationValue.ToString("X").ToUpperInvariant();
}
}
if (DestinationDisplacement != 0) {
xDest += " + " + DestinationDisplacement;
}
if (DestinationIsIndirect) {
return "[" + xDest + "]";
} else {
return xDest;
}
}
public override string ToString() {
return base.mMnemonic + " " + GetDestinationAsString();
}
}
}