mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 21:08:51 +00:00
This commit is contained in:
parent
46bb6ac755
commit
bf883e964a
27 changed files with 39 additions and 36 deletions
|
|
@ -16,7 +16,7 @@ namespace Cosmos.Sys.Plugs.Assemblers
|
|||
SourceValue = 0x64,
|
||||
DestinationReg = CPUx86.Registers.DX
|
||||
};
|
||||
new CPUx86.In {
|
||||
new CPUx86.IN {
|
||||
DestinationReg = CPUx86.Registers.AL
|
||||
};
|
||||
new CPUx86.Test {
|
||||
|
|
@ -43,7 +43,7 @@ namespace Cosmos.Sys.Plugs.Assemblers
|
|||
SourceValue = 0x64,
|
||||
DestinationReg = CPUx86.Registers.DX
|
||||
};
|
||||
new CPUx86.In {
|
||||
new CPUx86.IN {
|
||||
DestinationReg = CPUx86.Registers.AL
|
||||
};
|
||||
new CPUx86.Test {
|
||||
|
|
|
|||
|
|
@ -94,12 +94,12 @@
|
|||
<Compile Include="ExternalLabel.cs" />
|
||||
<Compile Include="Halt.cs" />
|
||||
<Compile Include="IDivide.cs" />
|
||||
<Compile Include="In.cs" />
|
||||
<Compile Include="Inc.cs" />
|
||||
<Compile Include="Int1.cs" />
|
||||
<Compile Include="Int3.cs" />
|
||||
<Compile Include="Interrupt.cs" />
|
||||
<Compile Include="InterruptReturn.cs" />
|
||||
<Compile Include="IN.cs" />
|
||||
<Compile Include="INC.cs" />
|
||||
<Compile Include="INT1.cs" />
|
||||
<Compile Include="INT3.cs" />
|
||||
<Compile Include="INT.cs" />
|
||||
<Compile Include="IRET.cs" />
|
||||
<Compile Include="JumpAlways.cs" />
|
||||
<Compile Include="JumpBase.cs" />
|
||||
<Compile Include="JumpToSegment.cs" />
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
namespace Cosmos.Compiler.Assembler.X86 {
|
||||
[OpCode("int")]
|
||||
public class Interrupt : InstructionWithDestination {
|
||||
public class INT : InstructionWithDestination {
|
||||
public override void WriteText( Cosmos.Compiler.Assembler.Assembler aAssembler, System.IO.TextWriter aOutput )
|
||||
{
|
||||
//TODO: In base have a property that has the opcode from above and we can reuse it.
|
||||
aOutput.Write("Int " + DestinationValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,6 @@ using System.Text;
|
|||
|
||||
namespace Cosmos.Compiler.Assembler.X86 {
|
||||
[OpCode("iret")]
|
||||
public class InterruptReturn: Instruction {
|
||||
public class IRET: Instruction {
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
|
||||
namespace Cosmos.Compiler.Assembler.X86 {
|
||||
[OpCode("in")]
|
||||
public class In : InstructionWithDestinationAndSize {
|
||||
public class IN : InstructionWithDestinationAndSize {
|
||||
public override void WriteText( Cosmos.Compiler.Assembler.Assembler aAssembler, System.IO.TextWriter aOutput )
|
||||
{
|
||||
base.WriteText(aAssembler, aOutput);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ using System.Text;
|
|||
|
||||
namespace Cosmos.Compiler.Assembler.X86 {
|
||||
[OpCode("inc")]
|
||||
public class Inc : InstructionWithDestinationAndSize {
|
||||
public class INC : InstructionWithDestinationAndSize {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// See note in Int3 as to why we need a separate op for Int1 versus Int 0x01
|
||||
[OpCode("Int1")]
|
||||
public class Int1: Instruction {
|
||||
public class INT1: Instruction {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// are cases where the long form could be preferred. Thus instead we have
|
||||
// chosen to follow the NASM model in our code.
|
||||
[OpCode("Int3")]
|
||||
public class Int3 : Instruction {
|
||||
public class INT3 : Instruction {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -209,7 +209,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
new Return { DestinationValue = aBytes };
|
||||
}
|
||||
public void ReturnFromInterrupt() {
|
||||
new InterruptReturn();
|
||||
new IRET();
|
||||
}
|
||||
|
||||
public void EnableInterrupts() {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ namespace Cosmos.Compiler.XSharp {
|
|||
return new MemoryAction(xAddrIndirect.Reference, xAddrIndirect.Displacement) { IsIndirect = true };
|
||||
} else {
|
||||
if (xAddrIndirect.Register != null) {
|
||||
return new MemoryAction(xAddrIndirect.Register.Value, xAddrIndirect.Displacement) { IsIndirect = true };
|
||||
//TODO: HACK.... This defaults all registers without the size argument to 32. We need to really rebuild this code
|
||||
return new MemoryAction(xAddrIndirect.Register.Value, xAddrIndirect.Displacement) { Size = 32, IsIndirect = true };
|
||||
} else {
|
||||
return new MemoryAction(xAddrIndirect.Address, xAddrIndirect.Displacement) { IsIndirect = true };
|
||||
}
|
||||
|
|
@ -58,7 +59,8 @@ namespace Cosmos.Compiler.XSharp {
|
|||
var xAddrDirect = aAddress as AddressDirect;
|
||||
if (xAddrDirect != null) {
|
||||
if (xAddrDirect.Label != null) {
|
||||
new Move { DestinationRef = ElementReference.New(xAddrDirect.Label), SourceValue = value.Value.GetValueOrDefault(), SourceRef = value.Reference, SourceReg = value.Register, SourceIsIndirect = value.IsIndirect };
|
||||
// Default is 32, in future save type that created the label, ie DataMemberInt vs DataMemberByte and set the size
|
||||
new Move { DestinationRef = ElementReference.New(xAddrDirect.Label), DestinationIsIndirect = true, SourceValue = value.Value.GetValueOrDefault(), SourceRef = value.Reference, SourceReg = value.Register, SourceIsIndirect = value.IsIndirect };
|
||||
} else {
|
||||
new Move { DestinationValue = xAddrDirect.Address, SourceValue = value.Value.GetValueOrDefault(), SourceRef = value.Reference, SourceReg = value.Register, SourceIsIndirect = value.IsIndirect };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
}
|
||||
|
||||
public static MemoryAction operator ++(MemoryAction aTarget) {
|
||||
aTarget.ApplyToDest(new Inc());
|
||||
aTarget.ApplyToDest(new INC());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
}
|
||||
|
||||
public static implicit operator RegisterAL(PortNumber aPort) {
|
||||
new In { DestinationReg = Registers.AL };
|
||||
new IN { DestinationReg = Registers.AL };
|
||||
return Instance;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
}
|
||||
|
||||
public static implicit operator RegisterBL(PortNumber aPort) {
|
||||
new In { DestinationReg = Registers.BL };
|
||||
new IN { DestinationReg = Registers.BL };
|
||||
return Instance;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
public static readonly RegisterEAX Instance = new RegisterEAX();
|
||||
|
||||
public static RegisterEAX operator ++(RegisterEAX aRegister) {
|
||||
new Inc { DestinationReg = aRegister.GetId() };
|
||||
new INC { DestinationReg = aRegister.GetId() };
|
||||
return aRegister;
|
||||
}
|
||||
public static RegisterEAX operator +(RegisterEAX aRegister, UInt32 aValue) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
public static readonly RegisterEBP Instance = new RegisterEBP();
|
||||
|
||||
public static RegisterEBP operator ++(RegisterEBP aRegister) {
|
||||
new Inc { DestinationReg = aRegister.GetId() };
|
||||
new INC { DestinationReg = aRegister.GetId() };
|
||||
return aRegister;
|
||||
}
|
||||
public static RegisterEBP operator +(RegisterEBP aRegister, UInt32 aValue) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
public static readonly RegisterEBX Instance = new RegisterEBX();
|
||||
|
||||
public static RegisterEBX operator ++(RegisterEBX aRegister) {
|
||||
new Inc { DestinationReg = aRegister.GetId() };
|
||||
new INC { DestinationReg = aRegister.GetId() };
|
||||
return aRegister;
|
||||
}
|
||||
public static RegisterEBX operator --(RegisterEBX aRegister) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
public static readonly RegisterECX Instance = new RegisterECX();
|
||||
|
||||
public static RegisterECX operator ++(RegisterECX aRegister) {
|
||||
new Inc { DestinationReg = aRegister.GetId() };
|
||||
new INC { DestinationReg = aRegister.GetId() };
|
||||
return aRegister;
|
||||
}
|
||||
public static RegisterECX operator --(RegisterECX aRegister) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
public static readonly RegisterEDI Instance = new RegisterEDI();
|
||||
|
||||
public static RegisterEDI operator ++(RegisterEDI aRegister) {
|
||||
new Inc { DestinationReg = aRegister.GetId() };
|
||||
new INC { DestinationReg = aRegister.GetId() };
|
||||
return aRegister;
|
||||
}
|
||||
public static RegisterEDI operator --(RegisterEDI aRegister) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
public static readonly RegisterESI Instance = new RegisterESI();
|
||||
|
||||
public static RegisterESI operator ++(RegisterESI aRegister) {
|
||||
new Inc { DestinationReg = aRegister.GetId() };
|
||||
new INC { DestinationReg = aRegister.GetId() };
|
||||
return aRegister;
|
||||
}
|
||||
public static RegisterESI operator +(RegisterESI aRegister, UInt32 aValue) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Cosmos.Compiler.XSharp {
|
|||
public static readonly RegisterESP Instance = new RegisterESP();
|
||||
|
||||
public static RegisterESP operator ++(RegisterESP aRegister) {
|
||||
new Inc { DestinationReg = aRegister.GetId() };
|
||||
new INC { DestinationReg = aRegister.GetId() };
|
||||
return aRegister;
|
||||
}
|
||||
public static RegisterESP operator +(RegisterESP aRegister, UInt32 aValue) {
|
||||
|
|
|
|||
|
|
@ -478,7 +478,7 @@ namespace Cosmos.IL2CPU.X86 {
|
|||
}
|
||||
|
||||
// If we made it this far without a return, emit the Tracer
|
||||
new CPUx86.Int3();
|
||||
new CPUx86.INT3();
|
||||
}
|
||||
|
||||
private int[] xCodeOffsets;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
new CPUx86.ShiftRight { DestinationReg = CPUx86.Registers.EDI, SourceValue = 1 };
|
||||
|
||||
// increment shift counter
|
||||
new CPUx86.Inc { DestinationReg = CPUx86.Registers.ECX};
|
||||
new CPUx86.INC { DestinationReg = CPUx86.Registers.ECX};
|
||||
|
||||
// set flags
|
||||
new CPUx86.Or { DestinationReg = CPUx86.Registers.EDI, SourceReg = CPUx86.Registers.EDI };
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
new CPUx86.ShiftRight { DestinationReg = CPUx86.Registers.EDI, SourceValue = 1 };
|
||||
|
||||
// increment shift counter
|
||||
new CPUx86.Inc { DestinationReg = CPUx86.Registers.ECX };
|
||||
new CPUx86.INC { DestinationReg = CPUx86.Registers.ECX };
|
||||
|
||||
// set flags
|
||||
new CPUx86.Or { DestinationReg = CPUx86.Registers.EDI, SourceReg = CPUx86.Registers.EDI };
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace Cosmos.IL2CPU.X86.Plugs.NEW_PLUGS {
|
|||
new CPUx86.Move { DestinationReg = CPUx86.Registers.EDI, SourceReg = CPUx86.Registers.EDI, SourceIsIndirect = true, SourceDisplacement = Ldfld.GetFieldOffset(xMethodInfo.MethodBase.DeclaringType, "System.Object System.Delegate._target") };//i really dont get the +12, MtW: that's for the object header
|
||||
new CPU.Label(".noTHIStoPop");
|
||||
new CPUx86.Popad();
|
||||
new CPUx86.Inc { DestinationReg = CPUx86.Registers.EDX };
|
||||
new CPUx86.INC { DestinationReg = CPUx86.Registers.EDX };
|
||||
new CPUx86.Add { DestinationReg = CPUx86.Registers.EAX, SourceValue = 4 };
|
||||
new CPUx86.Jump { DestinationLabel = ".BEGIN_OF_LOOP" };
|
||||
new CPU.Label(".END_OF_INVOKE_");
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ namespace Cosmos.IL2CPU.X86.Plugs.CustomImplementations.System.Assemblers
|
|||
//new CPUx86.Move("[esp]", "edi");
|
||||
new CPU.Label(".noTHIStoPop");
|
||||
new CPUx86.Popad();
|
||||
new CPUx86.Inc { DestinationReg = Registers.EDX };
|
||||
new CPUx86.INC { DestinationReg = Registers.EDX };
|
||||
new CPUx86.Add { DestinationReg = Registers.EAX, SourceValue = 4 };
|
||||
new CPUx86.Jump { DestinationLabel = ".BEGIN_OF_LOOP" };
|
||||
new CPU.Label(".END_OF_INVOKE_");
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Cosmos.Core.Plugs
|
|||
//TODO: Do we need to clear rest of EAX first?
|
||||
// MTW: technically not, as in other places, it _should_ be working with AL too..
|
||||
new CPUx86.Move { DestinationReg = CPUx86.Registers.EAX, SourceValue = 0 };
|
||||
new CPUx86.In { DestinationReg = CPUx86.Registers.AL };
|
||||
new CPUx86.IN { DestinationReg = CPUx86.Registers.AL };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ namespace Cosmos.Core.Plugs
|
|||
{
|
||||
new CPUx86.Move { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.EBP, SourceIsIndirect = true, SourceDisplacement = 0x08 };
|
||||
new CPUx86.Move { DestinationReg = CPUx86.Registers.EAX, SourceValue = 0 };
|
||||
new CPUx86.In { DestinationReg = CPUx86.Registers.AX };
|
||||
new CPUx86.IN { DestinationReg = CPUx86.Registers.AX };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ namespace Cosmos.Core.Plugs
|
|||
public static UInt32 Read32(UInt16 aPort)
|
||||
{
|
||||
new CPUx86.Move { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.EBP, SourceIsIndirect = true, SourceDisplacement = 0x08 };
|
||||
new CPUx86.In { DestinationReg = CPUx86.Registers.EAX };
|
||||
new CPUx86.IN { DestinationReg = CPUx86.Registers.EAX };
|
||||
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ namespace Cosmos.Core.Plugs.Assemblers {
|
|||
new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 8 };
|
||||
new CPUAll.Label("__ISR_Handler_" + j.ToString("X2") + "_END");
|
||||
new CPUx86.Move { DestinationRef = CPUAll.ElementReference.New("InterruptsEnabledFlag"), DestinationIsIndirect = true, SourceValue = 1, Size = 32 };
|
||||
new CPUx86.InterruptReturn();
|
||||
new CPUx86.IRET();
|
||||
}
|
||||
new CPUAll.Label("__INTERRUPT_OCCURRED__");
|
||||
new CPUx86.Return();
|
||||
|
|
|
|||
Loading…
Reference in a new issue