mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 22:12:25 +00:00
[-] some unnecessary overloads [+] overloaded operators in order to allow defining memory operands easily [+] overloaded automatic conversions to allow operands [+] Labels support [+] code generator based on F# started
59 lines
1.2 KiB
C#
59 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
namespace Lost.JIT.AMD64
|
|
{
|
|
[Serializable]
|
|
public sealed class ImmediateOperand: InstructionOperand
|
|
{
|
|
public ImmediateOperand(long value)
|
|
{
|
|
this.Value = value;
|
|
this.Size = 8;
|
|
}
|
|
public ImmediateOperand(int value)
|
|
{
|
|
this.Value = value;
|
|
Size = 4;
|
|
}
|
|
public ImmediateOperand(short value)
|
|
{
|
|
this.Value = value;
|
|
Size = 2;
|
|
}
|
|
public ImmediateOperand(byte value)
|
|
{
|
|
this.Value = value;
|
|
Size = 1;
|
|
}
|
|
|
|
public long Value { get; private set; }
|
|
public int Size { get; private set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
string digs = (Size * 2).ToString();
|
|
return "0x" + Value.ToString("X" + digs);
|
|
}
|
|
|
|
public static implicit operator ImmediateOperand(byte value)
|
|
{
|
|
return new ImmediateOperand(value);
|
|
}
|
|
public static implicit operator ImmediateOperand(short value)
|
|
{
|
|
return new ImmediateOperand(value);
|
|
}
|
|
public static implicit operator ImmediateOperand(int value)
|
|
{
|
|
return new ImmediateOperand(value);
|
|
}
|
|
public static implicit operator ImmediateOperand(long value)
|
|
{
|
|
return new ImmediateOperand(value);
|
|
}
|
|
}
|
|
}
|