mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-02 22:30:27 +00:00
41 lines
862 B
C#
41 lines
862 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
namespace Lost.JIT.AMD64
|
|
{
|
|
[Serializable]
|
|
public abstract class ConditionalJumpInstruction: ProcessorInstruction
|
|
{
|
|
public ConditionalJumpInstruction(int targetOffset)
|
|
{
|
|
TargetOffset = targetOffset;
|
|
}
|
|
|
|
public int TargetOffset { get; set; }
|
|
|
|
public override int? Size
|
|
{
|
|
get { throw new NotImplementedException(); }
|
|
}
|
|
|
|
public override void Compile(Stream destStream)
|
|
{
|
|
if (TargetOffset.FitsInByte())
|
|
{
|
|
destStream.WriteByte(OpcodeBase);
|
|
destStream.WriteSByte(TargetOffset);
|
|
return;
|
|
} else
|
|
{
|
|
destStream.WriteByte(0x0F);
|
|
destStream.WriteByte(OpcodeBase + 0x10);
|
|
destStream.WriteInt(TargetOffset);
|
|
}
|
|
}
|
|
|
|
protected abstract int OpcodeBase { get; }
|
|
}
|
|
}
|