mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-30 12:50:19 +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
60 lines
1.2 KiB
C#
60 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 Jump: ProcessorInstruction
|
|
{
|
|
public Jump(InstructionOperand operand)
|
|
{
|
|
Dest = operand;
|
|
}
|
|
|
|
public InstructionOperand Dest { get; set; }
|
|
|
|
public override int? Size
|
|
{
|
|
get { throw new NotImplementedException(); }
|
|
}
|
|
|
|
public override void Compile(Stream destStream)
|
|
{
|
|
if (Dest is ImmediateOperand)
|
|
{
|
|
var dest = Dest as ImmediateOperand;
|
|
if (dest.Value.FitsInSByte())
|
|
{
|
|
destStream.WriteByte(0xEB);
|
|
destStream.WriteSByte(dest.Value);
|
|
} else
|
|
{
|
|
destStream.WriteByte(0xE9);
|
|
destStream.WriteInt(dest.Value);
|
|
}
|
|
return;
|
|
}
|
|
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override string OpCodeFASM
|
|
{
|
|
get { return "jmp"; }
|
|
}
|
|
|
|
public override string ToFASM()
|
|
{
|
|
if (Dest is ImmediateOperand)
|
|
{
|
|
var dest = Dest as ImmediateOperand;
|
|
return string.Format("jmp {0}", dest.Value + (dest.Value.FitsInSByte()? 2: 5));
|
|
}
|
|
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|