mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-31 21:30:19 +00:00
58 lines
No EOL
1.6 KiB
C#
58 lines
No EOL
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Indy.IL2CPU.Assembler.X86 {
|
|
public abstract class InstructionWithDestinationAndSource : InstructionWithDestination, IInstructionWithSource {
|
|
public ElementReference SourceRef {
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public Guid SourceReg {
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public uint? SourceValue {
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public bool SourceIsIndirect {
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public int SourceDisplacement {
|
|
get;
|
|
set;
|
|
}
|
|
|
|
protected string GetSourceAsString() {
|
|
string xDest = "";
|
|
if (SourceRef != null) {
|
|
xDest = SourceRef.ToString();
|
|
} else {
|
|
if (SourceReg != Guid.Empty) {
|
|
xDest = Registers.GetRegisterName(SourceReg);
|
|
} else {
|
|
xDest = "0x" + SourceValue.GetValueOrDefault().ToString("X").ToUpperInvariant();
|
|
}
|
|
}
|
|
if (SourceDisplacement != 0) {
|
|
xDest += " + " + SourceDisplacement;
|
|
}
|
|
if (SourceIsIndirect) {
|
|
return "[" + xDest + "]";
|
|
} else {
|
|
return xDest;
|
|
}
|
|
}
|
|
|
|
public override string ToString() {
|
|
return Mnemonic + " " + this.GetDestinationAsString() + ", " + GetSourceAsString();
|
|
}
|
|
}
|
|
} |