-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65421be
commit 764a824
Showing
20 changed files
with
2,576 additions
and
2,557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 70 additions & 66 deletions
136
source/XSharp/XSharp/Assembler/Gen1/x86/JumpToSegment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,70 @@ | ||
using System; | ||
|
||
namespace XSharp.Assembler.x86 | ||
{ | ||
[XSharp.Assembler.OpCode("jmp")] | ||
public class JumpToSegment : Instruction { | ||
public XSharp.Assembler.ElementReference DestinationRef { | ||
get; | ||
set; | ||
} | ||
|
||
public ushort Segment { | ||
get; | ||
set; | ||
} | ||
|
||
public override void WriteText( XSharp.Assembler.Assembler aAssembler, System.IO.TextWriter aOutput ) | ||
{ | ||
if (DestinationRef != null) { | ||
aOutput.Write("jmp "); | ||
aOutput.Write(Segment); | ||
aOutput.Write(":"); | ||
aOutput.Write(DestinationRef.ToString()); | ||
} else { | ||
aOutput.Write("jmp "); | ||
aOutput.Write(Segment); | ||
aOutput.Write(":0x0"); | ||
} | ||
} | ||
|
||
public string DestinationLabel { | ||
get { | ||
if (DestinationRef != null) { | ||
return DestinationRef.Name; | ||
} | ||
return String.Empty; | ||
} | ||
set { | ||
DestinationRef = XSharp.Assembler.ElementReference.New(value); | ||
} | ||
} | ||
|
||
public override bool IsComplete( XSharp.Assembler.Assembler aAssembler ) | ||
{ | ||
ulong xAddress; | ||
return DestinationRef == null || DestinationRef.Resolve(aAssembler, out xAddress); | ||
} | ||
|
||
public override void UpdateAddress(XSharp.Assembler.Assembler aAssembler, ref ulong aAddress) { | ||
base.UpdateAddress(aAssembler, ref aAddress); | ||
aAddress += 7; | ||
} | ||
|
||
//public override byte[] GetData(Assembler aAssembler) { | ||
public override void WriteData( XSharp.Assembler.Assembler aAssembler, System.IO.Stream aOutput ) | ||
{ | ||
aOutput.WriteByte(0xEA); | ||
ulong xAddress = 0; | ||
if (DestinationRef != null && DestinationRef.Resolve(aAssembler, out xAddress)) { | ||
xAddress = (ulong)(((long)xAddress) + DestinationRef.Offset); | ||
} | ||
aOutput.Write(BitConverter.GetBytes((uint)(xAddress)), 0, 4); | ||
aOutput.Write(BitConverter.GetBytes(Segment), 0, 2); | ||
} | ||
} | ||
} | ||
using System; | ||
|
||
namespace XSharp.Assembler.x86 | ||
{ | ||
[XSharp.Assembler.OpCode("jmp")] | ||
public class JumpToSegment : Instruction { | ||
public XSharp.Assembler.ElementReference DestinationRef { | ||
get; | ||
set; | ||
} | ||
|
||
public ushort Segment { | ||
get; | ||
set; | ||
} | ||
|
||
public JumpToSegment() | ||
{ | ||
; | ||
} | ||
public override void WriteText( XSharp.Assembler.Assembler aAssembler, System.IO.TextWriter aOutput ) | ||
{ | ||
if (DestinationRef != null) { | ||
aOutput.Write("jmp "); | ||
aOutput.Write(Segment); | ||
aOutput.Write(":"); | ||
aOutput.Write(DestinationRef.ToString()); | ||
} else { | ||
aOutput.Write("jmp "); | ||
aOutput.Write(Segment); | ||
aOutput.Write(":0x0"); | ||
} | ||
} | ||
|
||
public string DestinationLabel { | ||
get { | ||
if (DestinationRef != null) { | ||
return DestinationRef.Name; | ||
} | ||
return String.Empty; | ||
} | ||
set { | ||
DestinationRef = XSharp.Assembler.ElementReference.New(value); | ||
} | ||
} | ||
|
||
public override bool IsComplete( XSharp.Assembler.Assembler aAssembler ) | ||
{ | ||
ulong xAddress; | ||
return DestinationRef == null || DestinationRef.Resolve(aAssembler, out xAddress); | ||
} | ||
|
||
public override void UpdateAddress(XSharp.Assembler.Assembler aAssembler, ref ulong aAddress) { | ||
base.UpdateAddress(aAssembler, ref aAddress); | ||
aAddress += 7; | ||
} | ||
|
||
//public override byte[] GetData(Assembler aAssembler) { | ||
public override void WriteData( XSharp.Assembler.Assembler aAssembler, System.IO.Stream aOutput ) | ||
{ | ||
aOutput.WriteByte(0xEA); | ||
ulong xAddress = 0; | ||
if (DestinationRef != null && DestinationRef.Resolve(aAssembler, out xAddress)) { | ||
xAddress = (ulong)(((long)xAddress) + DestinationRef.Offset); | ||
} | ||
aOutput.Write(BitConverter.GetBytes((uint)(xAddress)), 0, 4); | ||
aOutput.Write(BitConverter.GetBytes(Segment), 0, 2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
namespace XSharp.Assembler.x86 | ||
{ | ||
[XSharp.Assembler.OpCode("push")] | ||
public class Push : InstructionWithDestinationAndSize { | ||
|
||
public Push():base("push") { | ||
Size = 32; | ||
} | ||
} | ||
} | ||
namespace XSharp.Assembler.x86 | ||
{ | ||
[XSharp.Assembler.OpCode("push")] | ||
public class Push : InstructionWithDestinationAndSize { | ||
|
||
public Push():base("push") { | ||
Size = 64; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
source/XSharp/XSharp/Assembler/Gen1/x86/SSE2/ConvertSI2SD.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
namespace XSharp.Assembler.x86.SSE | ||
{ | ||
[XSharp.Assembler.OpCode("cvtsi2sd")] | ||
public class ConvertSI2SD : InstructionWithDestinationAndSource | ||
{ | ||
} | ||
} | ||
namespace XSharp.Assembler.x86.SSE | ||
{ | ||
[XSharp.Assembler.OpCode("cvtsi2sd")] | ||
public class ConvertSI2SD : InstructionWithDestinationAndSource | ||
{ | ||
public ConvertSI2SD() | ||
{ | ||
SourceRequiresSize = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
using System; | ||
|
||
namespace XSharp.Assembler.x86 | ||
{ | ||
[XSharp.Assembler.OpCode("cdq")] | ||
public class SignExtendAX : InstructionWithSize { | ||
public override void WriteText( XSharp.Assembler.Assembler aAssembler, System.IO.TextWriter aOutput ) | ||
{ | ||
switch (Size) { | ||
case 32: | ||
aOutput.Write("cdq"); | ||
return; | ||
case 16: | ||
aOutput.Write("cwde"); | ||
return; | ||
case 8: | ||
aOutput.Write("cbw"); | ||
return; | ||
default: | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} | ||
} | ||
using System; | ||
|
||
namespace XSharp.Assembler.x86 | ||
{ | ||
[XSharp.Assembler.OpCode("cdq")] | ||
public class SignExtendAX : InstructionWithSize { | ||
public override void WriteText( XSharp.Assembler.Assembler aAssembler, System.IO.TextWriter aOutput ) | ||
{ | ||
switch (Size) { | ||
case 64: | ||
aOutput.Write("cqo"); | ||
return; | ||
case 32: | ||
aOutput.Write("cdq"); | ||
return; | ||
case 16: | ||
aOutput.Write("cwde"); | ||
return; | ||
case 8: | ||
aOutput.Write("cbw"); | ||
return; | ||
default: | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.