Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwoord committed Jun 17, 2016
1 parent ac1f590 commit cc44dc0
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 97 deletions.
16 changes: 7 additions & 9 deletions source/Cosmos.Core.Plugs/Assemblers/UpdateIDT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
var xInterruptsWithParam = new int[] { 8, 10, 11, 12, 13, 14 };
for (int j = 0; j < 256; j++)
{
new CPUAll.Label("__ISR_Handler_" + j.ToString("X2"));
XS.Label("__ISR_Handler_" + j.ToString("X2"));
XS.Call("__INTERRUPT_OCCURRED__");

if (Array.IndexOf(xInterruptsWithParam, j) == -1)
Expand All @@ -129,11 +129,9 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a

XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX)); //
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX)); // pass old stack address (pointer to InterruptContext struct) to the interrupt handler
//new CPUx86.Move("eax",
// "esp");
//new CPUx86.Push("eax");
new CPUx86.JumpToSegment { Segment = 8, DestinationLabel = "__ISR_Handler_" + j.ToString("X2") + "_SetCS" };
new CPUAll.Label("__ISR_Handler_" + j.ToString("X2") + "_SetCS");

XS.JumpToSegment(8, "__ISR_Handler_" + j.ToString("X2") + "_SetCS");
XS.Label("__ISR_Handler_" + j.ToString("X2") + "_SetCS");
MethodBase xHandler = GetInterruptHandler((byte)j);
if (xHandler == null)
{
Expand All @@ -152,9 +150,9 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
new CPUAll.Label("__ISR_Handler_" + j.ToString("X2") + "_END");
XS.InterruptReturn();
}
new CPUAll.Label("__INTERRUPT_OCCURRED__");
XS.Label("__INTERRUPT_OCCURRED__");
XS.Return();
new CPUAll.Label("__AFTER__ALL__ISR__HANDLER__STUBS__");
XS.Label("__AFTER__ALL__ISR__HANDLER__STUBS__");
XS.Noop();
XS.Set(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EBP), sourceDisplacement: 8);
XS.Compare(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX), 0);
Expand All @@ -167,7 +165,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// Reenable interrupts
XS.EnableInterrupts();

new CPUAll.Label(".__AFTER_ENABLE_INTERRUPTS");
XS.Label(".__AFTER_ENABLE_INTERRUPTS");
}
}
}
4 changes: 2 additions & 2 deletions source/Cosmos.Core.Plugs/CPUImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public override void AssembleNew(CPUAll.Assembler aAssembler, object aMethodInfo
XS.ShiftRight(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ECX), 1);
XS.Jump(CPUx86.ConditionalTestEnum.NotBelow, ".step2");
XS.StoreByteInString();
new CPUAll.Label(".step2");
XS.Label(".step2");
XS.ShiftRight(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ECX), 1);
XS.Jump(CPUx86.ConditionalTestEnum.NotBelow, ".step3");
XS.StoreWordInString();
new CPUAll.Label(".step3");
XS.Label(".step3");
new CPUx86.Stos { Size = 32, Prefixes = CPUx86.InstructionPrefixes.Repeat };
}
}
Expand Down
22 changes: 11 additions & 11 deletions source/Cosmos.Core.Plugs/System/Assemblers/InvokeImplAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
*/
XS.ClearInterruptFlag();
XS.Label(".DEBUG");
//new CPU.Label("____DEBUG_FOR_MULTICAST___");
//XS.Label("____DEBUG_FOR_MULTICAST___");
XS.Comment("move address of delegate to eax");
XS.Set(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX), XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EBP), sourceDisplacement: Ldarg.GetArgumentDisplacement(xMethodInfo, 0));

Expand Down Expand Up @@ -130,7 +130,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
XS.Exchange(XSRegisters.EBP, XSRegisters.EDX, destinationIsIndirect: true);
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX));//ebp
XS.Set(XSRegisters.ESP, XSRegisters.EDI, destinationDisplacement: 12);
new Assembler.Label(".noReturn");
XS.Label(".noReturn");
XS.EnableInterrupts();
}

Expand Down Expand Up @@ -167,7 +167,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// * EBX contains the number of items in the array
// * ECX contains the argument size
// */
// //new CPU.Label("____DEBUG_FOR_MULTICAST___");
// //XS.Label("____DEBUG_FOR_MULTICAST___");
// // new CPUx86.Cli();//DEBUG ONLY
// new CPU.Comment("push address of delgate to stack");
// Ldarg.DoExecute(xAssembler, xMethodInfo, 0);
Expand Down Expand Up @@ -195,13 +195,13 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// new CPU.Comment("ecx points to the size of the delegated methods arguments");
// XS.Xor(XSRegisters.EDX, XSRegisters.CPUx86.Registers.EDX);
// ;//make sure edx is 0
// new CPU.Label(".BEGIN_OF_LOOP");
// XS.Label(".BEGIN_OF_LOOP");
// XS.Compare(XSRegisters.EDX, XSRegisters.CPUx86.Registers.EBX);//are we at the end of this list
// XS.Jump(ConditionalTestEnum.Equal, ".END_OF_INVOKE_");//then we better stop
// //new CPUx86.Compare("edx", 0);
// //new CPUx86.JumpIfLessOrEqual(".noreturnYet");
// //new CPUx86.Add("esp", 4);
// //new CPU.Label(".noreturnYet");
// //XS.Label(".noreturnYet");
// //new CPU.Comment("space for the return value");
// //new CPUx86.Pushd("0");
// XS.Pushad();
Expand All @@ -217,7 +217,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// XS.Jump(ConditionalTestEnum.Zero, ".NO_THIS");
// XS.Push(XSRegisters.EDI);

// new CPU.Label(".NO_THIS");
// XS.Label(".NO_THIS");

// new CPU.Comment("make space for us to copy the arguments too");
// XS.Sub(XSRegisters.ESP, XSRegisters.CPUx86.Registers.EBX);
Expand Down Expand Up @@ -245,7 +245,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// //new CPUx86.JumpIfEqual(".getReturn");
// //new CPUx86.Move(Registers_Old.EAX, "[esp]");
// //new CPUx86.Move("[esp+0x20]", Registers_Old.EAX);
// //new CPU.Label(".getReturn");
// //XS.Label(".getReturn");
// Ldarg.DoExecute(xAssembler, xMethodInfo, 0);
// Ldfld.DoExecute(xAssembler, xMethodInfo.MethodBase.DeclaringType, "System.Object System.Delegate._target");
// // edi contains $this now
Expand All @@ -262,15 +262,15 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// //new CPUx86.Move("ecx", "[ecx + " + (MethodInfo.Arguments[0].TypeInfo.Fields["$$ArgSize$$"].Offset + 12) + "]");//the size of the arguments to the method? + 12??? -- 12 is the size of the current call stack.. i think
// //new CPUx86.Compare("ecx", "0");
// //new CPUx86.JumpIfLessOrEqual(".noTHIStoPop");
// //new CPU.Label(".needToPopThis");
// //XS.Label(".needToPopThis");
// //new CPUx86.Pop("edi");
// //new CPUx86.Move("[esp]", "edi");
// new CPU.Label(".noTHIStoPop");
// XS.Label(".noTHIStoPop");
// XS.Popad();
// XS.INC(XSRegisters.EDX);
// XS.Add(XSRegisters.EAX, 4);
// XS.Jump(".BEGIN_OF_LOOP");
// new CPU.Label(".END_OF_INVOKE_");
// XS.Label(".END_OF_INVOKE_");
// new CPU.Comment("get the return value");
// // TEMP!!!
// // XS.Add(XSRegisters.ESP, 4);
Expand All @@ -288,7 +288,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
// //XS.Xchg(XSRegisters.EBP, XSRegisters.EDX, destinationIsIndirect: true);
// //XS.Push(XSRegisters.EDX);//ebp
// //XS.Mov(XSRegisters.ESP, XSRegisters.EDI, destinationDisplacement: 12);
// new CPU.Label(".noReturn");
// XS.Label(".noReturn");
// // XS.Sti();
// //#warning remove this ^ sti call when issue is fixed!!!
// //MethodInfo.Arguments[0].
Expand Down
8 changes: 4 additions & 4 deletions source/Cosmos.Debug.GDB/BreakpointUC.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions source/Cosmos.Debug.GDB/FormLog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions source/Cosmos.Debug.GDB/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 60 additions & 60 deletions source/Cosmos.Debug.GDB/FormRegisters.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions source/Cosmos.Debug.GDB/WatchUC.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/AppAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ protected void BeforeOp(MethodInfo aMethod, ILOpCode aOpCode, bool emitInt3NotNo
new Mov { DestinationRef = ElementReference.New("DebugStub_CallerEIP"), DestinationIsIndirect = true, SourceReg = RegistersEnum.EAX };
XS.Call("DebugStub_SendStackCorruptionOccurred");
XS.Halt();
new Assembler.Label(xLabel + ".StackCorruptionCheck_End");
XS.Label(xLabel + ".StackCorruptionCheck_End");

}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/ILOp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public static void DoNullReferenceCheck(Assembler.Assembler assembler, bool debu
XS.ClearInterruptFlag();
// don't remove the call. It seems pointless, but we need it to retrieve the EIP value
XS.Call(".NullCheck_GetCurrAddress");
new Assembler.Label(".NullCheck_GetCurrAddress");
XS.Label(".NullCheck_GetCurrAddress");
XS.Pop(XSRegisters.OldToNewRegister(CPU.RegistersEnum.EAX));
new CPU.Mov {DestinationRef = ElementReference.New("DebugStub_CallerEIP"), DestinationIsIndirect = true, SourceReg = CPU.RegistersEnum.EAX};
XS.Call("DebugStub_SendNullReferenceOccurred");
Expand Down
Loading

0 comments on commit cc44dc0

Please sign in to comment.