mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Cosmos.Compiler.Assembler;
|
|
using Cosmos.Compiler.Assembler.X86;
|
|
|
|
namespace Cosmos.Compiler.XSharp {
|
|
public class AddressIndirect : Address {
|
|
public readonly RegistersEnum? Register;
|
|
public readonly ElementReference Reference;
|
|
public readonly uint Address;
|
|
public readonly int Displacement;
|
|
|
|
public AddressIndirect(Register32 aBaseRegister, Int32 aDisplacement) {
|
|
Register = Registers.GetRegister(aBaseRegister.Name);
|
|
Displacement = aDisplacement;
|
|
}
|
|
public AddressIndirect(uint aBaseAddress, int aDisplacement) {
|
|
Address = aBaseAddress;
|
|
Displacement = aDisplacement;
|
|
}
|
|
|
|
public override string ToString() {
|
|
if (Register != null) {
|
|
if (Displacement == 0) {
|
|
return "[" + Registers.GetRegisterName(Register.Value) + "]";
|
|
} else {
|
|
return "[" + Registers.GetRegisterName(Register.Value) + " + " + Displacement + "]";
|
|
}
|
|
} else {
|
|
if (Displacement == 0) {
|
|
return "[" + Address.ToString() + "]";
|
|
} else {
|
|
return "[" + Address.ToString() + " + " + Displacement + "]";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|