From b32a756cd8b1ea3a0021d629cddc1114e032a2cf Mon Sep 17 00:00:00 2001 From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498> Date: Tue, 10 Jul 2012 18:53:48 +0000 Subject: [PATCH] --- .../Cosmos.Compiler.DebugStub/CmdSend.cs | 164 +++++++++++------- .../Cosmos.Compiler.DebugStub/CmdSend.xs | 122 ++++++------- .../Compiler/Cosmos.XSharp/TokenPatterns.cs | 22 ++- .../Tests/XSharpCompilerTester/MainForm.cs | 1 + 4 files changed, 180 insertions(+), 129 deletions(-) diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/CmdSend.cs b/source2/Compiler/Cosmos.Compiler.DebugStub/CmdSend.cs index e62e9ab76..917aa03d8 100644 --- a/source2/Compiler/Cosmos.Compiler.DebugStub/CmdSend.cs +++ b/source2/Compiler/Cosmos.Compiler.DebugStub/CmdSend.cs @@ -34,52 +34,74 @@ namespace Cosmos.Debug.DebugStub { new Comment("X#: }"); new LiteralAssemblerCode("DebugStub_SendRegisters_Exit:"); new LiteralAssemblerCode("Ret"); - new LiteralAssemblerCode("; procedure SendFrame2 {"); - new LiteralAssemblerCode("; AL = (int)Ds2Vs.Frame"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); + new Comment("X#: procedure SendFrame2 {"); + new LiteralAssemblerCode("DebugStub_SendFrame2:"); + new Comment("X#: AL = #Ds2Vs_Frame"); + new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Frame"); + new Comment("X#: ComWriteAL()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); + new Comment("X#: EAX = 32"); + new LiteralAssemblerCode("Mov EAX, 32"); + new Comment("X#: ComWriteAX()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAX"); + new Comment("X#: ESI = .CallerEBP"); + new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerEBP]"); + new LiteralAssemblerCode("; Dont transmit EIP or old EBP"); + new Comment("X#: ESI + 8"); + new LiteralAssemblerCode("Add ESI, 8"); + new Comment("X#: ECX = 32"); + new LiteralAssemblerCode("Mov ECX, 32"); + new Comment("X#: ComWriteX()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteX"); + new Comment("X#: }"); + new LiteralAssemblerCode("DebugStub_SendFrame2_Exit:"); + new LiteralAssemblerCode("Ret"); + new Comment("X#: procedure SendStack2 {"); + new LiteralAssemblerCode("DebugStub_SendStack2:"); + new Comment("X#: AL = #Ds2Vs_Stack"); + new LiteralAssemblerCode("Mov AL, DebugStub_Const_Ds2Vs_Stack"); + new Comment("X#: ComWriteAL()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); + new LiteralAssemblerCode("; Send size of bytes"); + new Comment("X#: ESI = .CallerESP"); + new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerESP]"); + new Comment("X#: EAX = .CallerEBP"); + new LiteralAssemblerCode("Mov EAX, [DebugStub_CallerEBP]"); + new Comment("X#: EAX - ESI"); + new LiteralAssemblerCode("Sub EAX, ESI"); + new Comment("X#: ComWriteAX()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAX"); + new LiteralAssemblerCode("; Send actual bytes"); new LiteralAssemblerCode("; "); - new LiteralAssemblerCode("; EAX = 32"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAX\")"); - new LiteralAssemblerCode("; "); - new LiteralAssemblerCode("; ESI = CallerEBP.Value"); - new LiteralAssemblerCode("; ESI.Add(8) // Dont transmit EIP or old EBP"); - new LiteralAssemblerCode("; ECX = 32"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteX\")"); - new LiteralAssemblerCode("; }"); - new LiteralAssemblerCode("; procedure SendStack2 {"); - new LiteralAssemblerCode("; AL = (int)Ds2Vs.Stack"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); - new LiteralAssemblerCode("; "); - new LiteralAssemblerCode("; // Send size of bytes"); - new LiteralAssemblerCode("; ESI = CallerESP.Value"); - new LiteralAssemblerCode("; EAX = CallerEBP.Value"); - new LiteralAssemblerCode("; EAX.Sub(ESI)"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAX\")"); - new LiteralAssemblerCode("; "); - new LiteralAssemblerCode("; // Send actual bytes"); - new LiteralAssemblerCode("; //"); - new LiteralAssemblerCode("; // Need to reload ESI, WriteAXToCompPort modifies it"); - new LiteralAssemblerCode("; ESI = CallerESP.Value"); - new LiteralAssemblerCode("; Label = \".SendByte\""); - new LiteralAssemblerCode("; ESI.Compare(CallerEBP.Value)"); - new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".Exit\")"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite8\")"); - new LiteralAssemblerCode("; Jump(\".SendByte\")"); - new LiteralAssemblerCode("; }"); - new LiteralAssemblerCode("; procedure SendMethodContext2 {"); + new LiteralAssemblerCode("; Need to reload ESI, WriteAXToCompPort modifies it"); + new Comment("X#: ESI = .CallerESP"); + new LiteralAssemblerCode("Mov ESI, [DebugStub_CallerESP]"); + new Comment("X#: SendByte:"); + new LiteralAssemblerCode("DebugStub_SendStack2_SendByte:"); + new LiteralAssemblerCode("; if ESI = CallerEBP exit"); + new Comment("X#: ComWrite8()"); + new LiteralAssemblerCode("Call DebugStub_ComWrite8"); + new Comment("X#: goto SendByte"); + new LiteralAssemblerCode("Jp DebugStub_SendStack2_SendByte"); + new Comment("X#: }"); + new LiteralAssemblerCode("DebugStub_SendStack2_Exit:"); + new LiteralAssemblerCode("Ret"); + new Comment("X#: procedure SendMethodContext2 {"); + new LiteralAssemblerCode("DebugStub_SendMethodContext2:"); new LiteralAssemblerCode("; // sends a stack value"); new LiteralAssemblerCode("; // Serial Params:"); new LiteralAssemblerCode("; // 1: x32 - offset relative to EBP"); new LiteralAssemblerCode("; // 2: x32 - size of data to send"); new LiteralAssemblerCode("; [XSharp(PreserveStack = true)]"); - new LiteralAssemblerCode("; AL = (int)Ds2Vs.MethodContext"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); + new LiteralAssemblerCode("; AL = Ds2Vs_MethodContext"); + new Comment("X#: ComWriteAL()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; // offset relative to ebp"); new LiteralAssemblerCode("; // size of data to send"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX\")"); + new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX()"); new LiteralAssemblerCode("; ECX = EAX"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX\")"); + new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX()"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; // now ECX contains size of data (count)"); new LiteralAssemblerCode("; // EAX contains relative to EBP"); @@ -89,24 +111,29 @@ namespace Cosmos.Debug.DebugStub { new LiteralAssemblerCode("; Label = \".SendByte\""); new LiteralAssemblerCode("; ECX.Compare(0)"); new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".AfterSendByte\")"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite8\")"); + new Comment("X#: ComWrite8()"); + new LiteralAssemblerCode("Call DebugStub_ComWrite8"); new LiteralAssemblerCode("; ECX--"); new LiteralAssemblerCode("; Jump(\".SendByte\")"); new LiteralAssemblerCode("; Label = \".AfterSendByte\""); - new LiteralAssemblerCode("; }"); - new LiteralAssemblerCode("; procedure SendMemory2 {"); + new Comment("X#: }"); + new LiteralAssemblerCode("DebugStub_SendMethodContext2_Exit:"); + new LiteralAssemblerCode("Ret"); + new Comment("X#: procedure SendMemory2 {"); + new LiteralAssemblerCode("DebugStub_SendMemory2:"); new LiteralAssemblerCode("; // sends a stack value"); new LiteralAssemblerCode("; // Serial Params:"); new LiteralAssemblerCode("; // 1: x32 - offset relative to EBP"); new LiteralAssemblerCode("; // 2: x32 - size of data to send"); new LiteralAssemblerCode("; [XSharp(PreserveStack = true)]"); new LiteralAssemblerCode("; procedure"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX\")"); + new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX()"); new LiteralAssemblerCode("; ECX = EAX"); - new LiteralAssemblerCode("; AL = (int)Ds2Vs.MemoryData"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); + new LiteralAssemblerCode("; AL = Ds2Vs_MemoryData"); + new Comment("X#: ComWriteAL()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("; "); - new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX\")"); + new LiteralAssemblerCode("; Call(\"DebugStub_ComReadEAX()"); new LiteralAssemblerCode("; ESI = EAX"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; // now ECX contains size of data (count)"); @@ -115,68 +142,85 @@ namespace Cosmos.Debug.DebugStub { new LiteralAssemblerCode("; Label = \"DebugStub_SendMemory_SendByte\""); new LiteralAssemblerCode("; new Compare { DestinationReg = Registers.ECX, SourceValue = 0 }"); new LiteralAssemblerCode("; JumpIf(Flags.Equal, \"DebugStub_SendMemory_After_SendByte\")"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite8\")"); + new Comment("X#: ComWrite8()"); + new LiteralAssemblerCode("Call DebugStub_ComWrite8"); new LiteralAssemblerCode("; ECX--"); new LiteralAssemblerCode("; Jump(\"DebugStub_SendMemory_SendByte\")"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; Label = \"DebugStub_SendMemory_After_SendByte\""); new LiteralAssemblerCode("; }"); - new LiteralAssemblerCode("; }"); - new LiteralAssemblerCode("; procedure SendTrace2 {"); + new Comment("X#: }"); + new LiteralAssemblerCode("DebugStub_SendMemory2_Exit:"); + new LiteralAssemblerCode("Ret"); + new Comment("X#: procedure SendTrace2 {"); + new LiteralAssemblerCode("DebugStub_SendTrace2:"); new LiteralAssemblerCode("; // Modifies: EAX, ESI"); new LiteralAssemblerCode("; DebugStatus.Value.Compare(Status.Run)"); new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".Normal\")"); - new LiteralAssemblerCode("; AL = (int)Ds2Vs.BreakPoint"); + new LiteralAssemblerCode("; AL = Ds2Vs_BreakPoint"); new LiteralAssemblerCode("; Jump(\".Type\")"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; Label = \".Normal\""); - new LiteralAssemblerCode("; AL = (int)Ds2Vs.TracePoint"); + new LiteralAssemblerCode("; AL = Ds2Vs_TracePoint"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; Label = \".Type\""); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); + new Comment("X#: ComWriteAL()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; // Send Calling EIP."); new LiteralAssemblerCode("; ESI = CallerEIP.Address"); new LiteralAssemblerCode("; DebugStub_ComWrite32()"); - new LiteralAssemblerCode("; }"); - new LiteralAssemblerCode("; procedure SendText2 {"); + new Comment("X#: }"); + new LiteralAssemblerCode("DebugStub_SendTrace2_Exit:"); + new LiteralAssemblerCode("Ret"); + new Comment("X#: procedure SendText2 {"); + new LiteralAssemblerCode("DebugStub_SendText2:"); new LiteralAssemblerCode("; // Input: Stack"); new LiteralAssemblerCode("; // Output: None"); new LiteralAssemblerCode("; // Modifies: EAX, ECX, EDX, ESI"); new LiteralAssemblerCode("; // Write the type"); - new LiteralAssemblerCode("; AL = (int)Ds2Vs.Message"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); + new LiteralAssemblerCode("; AL = Ds2Vs_Message"); + new Comment("X#: ComWriteAL()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; // Write Length"); new LiteralAssemblerCode("; ESI = EBP"); new LiteralAssemblerCode("; ESI = ESI + 12"); new LiteralAssemblerCode("; ECX = ESI[0]"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite16\")"); + new Comment("X#: ComWrite16()"); + new LiteralAssemblerCode("Call DebugStub_ComWrite16"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; // Address of string"); new LiteralAssemblerCode("; ESI = EBP[8]"); new LiteralAssemblerCode("; Label = \".WriteChar\""); new LiteralAssemblerCode("; ECX.Compare(0)"); new LiteralAssemblerCode("; JumpIf(Flags.Equal, \".Exit\")"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWrite8\")"); + new Comment("X#: ComWrite8()"); + new LiteralAssemblerCode("Call DebugStub_ComWrite8"); new LiteralAssemblerCode("; ECX--"); new LiteralAssemblerCode("; // We are storing as 16 bits, but for now I will transmit 8 bits"); new LiteralAssemblerCode("; // So we inc again to skip the 0"); new LiteralAssemblerCode("; ESI++"); new LiteralAssemblerCode("; Jump(\".WriteChar\")"); - new LiteralAssemblerCode("; }"); - new LiteralAssemblerCode("; procedure SendPtr2 {"); + new Comment("X#: }"); + new LiteralAssemblerCode("DebugStub_SendText2_Exit:"); + new LiteralAssemblerCode("Ret"); + new Comment("X#: procedure SendPtr2 {"); + new LiteralAssemblerCode("DebugStub_SendPtr2:"); new LiteralAssemblerCode("; // Input: Stack"); new LiteralAssemblerCode("; // Output: None"); new LiteralAssemblerCode("; // Modifies: EAX, ECX, EDX, ESI"); new LiteralAssemblerCode("; // Write the type"); - new LiteralAssemblerCode("; AL = (int)Ds2Vs.Pointer"); - new LiteralAssemblerCode("; Call(\"DebugStub_ComWriteAL\")"); + new LiteralAssemblerCode("; AL = Ds2Vs_Pointer"); + new Comment("X#: ComWriteAL()"); + new LiteralAssemblerCode("Call DebugStub_ComWriteAL"); new LiteralAssemblerCode("; "); new LiteralAssemblerCode("; // pointer value"); new LiteralAssemblerCode("; ESI = EBP[8]"); new LiteralAssemblerCode("; DebugStub_ComWrite32()"); - new LiteralAssemblerCode("; }"); + new Comment("X#: }"); + new LiteralAssemblerCode("DebugStub_SendPtr2_Exit:"); + new LiteralAssemblerCode("Ret"); } } } diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/CmdSend.xs b/source2/Compiler/Cosmos.Compiler.DebugStub/CmdSend.xs index c7ef407e9..d64c3d001 100644 --- a/source2/Compiler/Cosmos.Compiler.DebugStub/CmdSend.xs +++ b/source2/Compiler/Cosmos.Compiler.DebugStub/CmdSend.xs @@ -16,54 +16,54 @@ procedure SendRegisters { ComWrite32() } -//procedure SendFrame2 { -// AL = (int)Ds2Vs.Frame -// Call("DebugStub_ComWriteAL") -// -// EAX = 32 -// Call("DebugStub_ComWriteAX") -// -// ESI = CallerEBP.Value -// ESI.Add(8) // Dont transmit EIP or old EBP -// ECX = 32 -// Call("DebugStub_ComWriteX") -//} +procedure SendFrame2 { + AL = #Ds2Vs_Frame + ComWriteAL() -//procedure SendStack2 { -// AL = (int)Ds2Vs.Stack -// Call("DebugStub_ComWriteAL") -// -// // Send size of bytes -// ESI = CallerESP.Value -// EAX = CallerEBP.Value -// EAX.Sub(ESI) -// Call("DebugStub_ComWriteAX") -// -// // Send actual bytes -// // -// // Need to reload ESI, WriteAXToCompPort modifies it -// ESI = CallerESP.Value -// Label = ".SendByte" -// ESI.Compare(CallerEBP.Value) -// JumpIf(Flags.Equal, ".Exit") -// Call("DebugStub_ComWrite8") -// Jump(".SendByte") -//} + EAX = 32 + ComWriteAX() -//procedure SendMethodContext2 { + ESI = .CallerEBP + // Dont transmit EIP or old EBP + ESI + 8 + ECX = 32 + ComWriteX() +} + +procedure SendStack2 { + AL = #Ds2Vs_Stack + ComWriteAL() + + // Send size of bytes + ESI = .CallerESP + EAX = .CallerEBP + EAX - ESI + ComWriteAX() + + // Send actual bytes + // + // Need to reload ESI, WriteAXToCompPort modifies it + ESI = .CallerESP +SendByte: +// if ESI = CallerEBP exit + ComWrite8() + goto SendByte +} + +procedure SendMethodContext2 { // // sends a stack value // // Serial Params: // // 1: x32 - offset relative to EBP // // 2: x32 - size of data to send // [XSharp(PreserveStack = true)] -// AL = (int)Ds2Vs.MethodContext -// Call("DebugStub_ComWriteAL") +// AL = Ds2Vs_MethodContext + ComWriteAL() // // // offset relative to ebp // // size of data to send -// Call("DebugStub_ComReadEAX") +// Call("DebugStub_ComReadEAX() // ECX = EAX -// Call("DebugStub_ComReadEAX") +// Call("DebugStub_ComReadEAX() // // // now ECX contains size of data (count) // // EAX contains relative to EBP @@ -73,25 +73,25 @@ procedure SendRegisters { // Label = ".SendByte" // ECX.Compare(0) // JumpIf(Flags.Equal, ".AfterSendByte") -// Call("DebugStub_ComWrite8") + ComWrite8() // ECX-- // Jump(".SendByte") // Label = ".AfterSendByte" -//} +} -//procedure SendMemory2 { +procedure SendMemory2 { // // sends a stack value // // Serial Params: // // 1: x32 - offset relative to EBP // // 2: x32 - size of data to send // [XSharp(PreserveStack = true)] // procedure -// Call("DebugStub_ComReadEAX") +// Call("DebugStub_ComReadEAX() // ECX = EAX -// AL = (int)Ds2Vs.MemoryData -// Call("DebugStub_ComWriteAL") +// AL = Ds2Vs_MemoryData + ComWriteAL() // -// Call("DebugStub_ComReadEAX") +// Call("DebugStub_ComReadEAX() // ESI = EAX // // // now ECX contains size of data (count) @@ -100,68 +100,68 @@ procedure SendRegisters { // Label = "DebugStub_SendMemory_SendByte" // new Compare { DestinationReg = Registers.ECX, SourceValue = 0 } // JumpIf(Flags.Equal, "DebugStub_SendMemory_After_SendByte") -// Call("DebugStub_ComWrite8") + ComWrite8() // ECX-- // Jump("DebugStub_SendMemory_SendByte") // // Label = "DebugStub_SendMemory_After_SendByte" // } -//} +} -//procedure SendTrace2 { +procedure SendTrace2 { // // Modifies: EAX, ESI // DebugStatus.Value.Compare(Status.Run) // JumpIf(Flags.Equal, ".Normal") -// AL = (int)Ds2Vs.BreakPoint +// AL = Ds2Vs_BreakPoint // Jump(".Type") // // Label = ".Normal" -// AL = (int)Ds2Vs.TracePoint +// AL = Ds2Vs_TracePoint // // Label = ".Type" -// Call("DebugStub_ComWriteAL") + ComWriteAL() // // // Send Calling EIP. // ESI = CallerEIP.Address // DebugStub_ComWrite32() -//} +} -//procedure SendText2 { +procedure SendText2 { // // Input: Stack // // Output: None // // Modifies: EAX, ECX, EDX, ESI // // Write the type -// AL = (int)Ds2Vs.Message -// Call("DebugStub_ComWriteAL") +// AL = Ds2Vs_Message + ComWriteAL() // // // Write Length // ESI = EBP // ESI = ESI + 12 // ECX = ESI[0] -// Call("DebugStub_ComWrite16") + ComWrite16() // // // Address of string // ESI = EBP[8] // Label = ".WriteChar" // ECX.Compare(0) // JumpIf(Flags.Equal, ".Exit") -// Call("DebugStub_ComWrite8") + ComWrite8() // ECX-- // // We are storing as 16 bits, but for now I will transmit 8 bits // // So we inc again to skip the 0 // ESI++ // Jump(".WriteChar") -//} +} -//procedure SendPtr2 { +procedure SendPtr2 { // // Input: Stack // // Output: None // // Modifies: EAX, ECX, EDX, ESI // // Write the type -// AL = (int)Ds2Vs.Pointer -// Call("DebugStub_ComWriteAL") +// AL = Ds2Vs_Pointer + ComWriteAL() // // // pointer value // ESI = EBP[8] // DebugStub_ComWrite32() -//} +} diff --git a/source2/Compiler/Cosmos.XSharp/TokenPatterns.cs b/source2/Compiler/Cosmos.XSharp/TokenPatterns.cs index 2c796e0a7..062fd53c7 100644 --- a/source2/Compiler/Cosmos.XSharp/TokenPatterns.cs +++ b/source2/Compiler/Cosmos.XSharp/TokenPatterns.cs @@ -195,12 +195,12 @@ namespace Cosmos.Compiler.XSharp { AddPattern(new string[] { //0 1 2 3 4 5 - "if _REG < 123 goto _ABC", "if _REG < 123 exit", - "if _REG > 123 goto _ABC", "if _REG > 123 exit", - "if _REG = 123 goto _ABC", "if _REG = 123 exit", - "if _REG != 123 goto _ABC", "if _REG != 123 exit", - "if _REG <= 123 goto _ABC", "if _REG <= 123 exit", - "if _REG >= 123 goto _ABC", "if _REG >= 123 exit" + "if _REG < 123 goto _ABC", "if _REG < 123 exit", "if _REG < _REG goto _ABC", "if _REG < _REG exit", + "if _REG > 123 goto _ABC", "if _REG > 123 exit", "if _REG > _REG goto _ABC", "if _REG > _REG exit", + "if _REG = 123 goto _ABC", "if _REG = 123 exit", "if _REG = _REG goto _ABC", "if _REG = _REG exit", + "if _REG != 123 goto _ABC", "if _REG != 123 exit", "if _REG != _REG goto _ABC", "if _REG != _REG exit", + "if _REG <= 123 goto _ABC", "if _REG <= 123 exit", "if _REG <= _REG goto _ABC", "if _REG <= _REG exit", + "if _REG >= 123 goto _ABC", "if _REG >= 123 exit", "if _REG >= _REG goto _ABC", "if _REG >= _REG exit" }, delegate(TokenList aTokens, ref List rCode) { rCode.Add("Cmp {1}, {3}"); @@ -340,8 +340,14 @@ namespace Cosmos.Compiler.XSharp { }); // TODO: Allow asm to optimize these to Inc/Dec - AddPattern("_REG + 1", "Add {0}, {2}"); - AddPattern("_REG - 1", "Sub {0}, {2}"); + AddPattern(new string[] { + "_REG + 1", + "_REG + _REG" + }, "Add {0}, {2}"); + AddPattern(new string[] { + "_REG - 1", + "_REG - _REG" + }, "Sub {0}, {2}"); AddPattern("_REG++", "Inc {0}"); AddPattern("_REG--", "Dec {0}"); diff --git a/source2/Tests/XSharpCompilerTester/MainForm.cs b/source2/Tests/XSharpCompilerTester/MainForm.cs index efba369c7..eecdf64ff 100644 --- a/source2/Tests/XSharpCompilerTester/MainForm.cs +++ b/source2/Tests/XSharpCompilerTester/MainForm.cs @@ -40,6 +40,7 @@ namespace XSharpCompilerTester { Test("CmdAsmBreak.xs"); Test("Main.xs"); Test("CmdProcess.xs"); + Test("CmdSend.xs"); } } }