From 96bb89aaf5628f05c8e7faeb33c9f9ba9ccbadb4 Mon Sep 17 00:00:00 2001 From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498> Date: Mon, 18 Jun 2012 15:28:54 +0000 Subject: [PATCH] X# --- .../Cosmos.Debug.DebugStub.csproj | 6 ++++++ .../Cosmos.Compiler.DebugStub/Old/Init.cs | 4 ++-- .../Cosmos.Compiler.DebugStub/Old/Screen.cs | 2 +- .../Cosmos.Compiler.DebugStub/Screen.xs | 6 +++--- source2/Compiler/Cosmos.XSharp/Parser.cs | 4 +++- source2/Compiler/Cosmos.XSharp/Token.cs | 2 +- .../Compiler/Cosmos.XSharp/TokenPatterns.cs | 18 ++++++++++++++++-- source2/Users/Kudzu/Kudzu-Notes.html | 5 ++++- source2/VSIP/Cosmos.VS.XSharp/Docs/Goals.html | 6 +++++- source2/VSIP/Cosmos.VS.XSharp/FileGenerator.cs | 3 ++- source2/VSIP/Cosmos.VS.XSharp/Scanner.cs | 1 + 11 files changed, 44 insertions(+), 13 deletions(-) diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/Cosmos.Debug.DebugStub.csproj b/source2/Compiler/Cosmos.Compiler.DebugStub/Cosmos.Debug.DebugStub.csproj index 226be5672..92b38a0f0 100644 --- a/source2/Compiler/Cosmos.Compiler.DebugStub/Cosmos.Debug.DebugStub.csproj +++ b/source2/Compiler/Cosmos.Compiler.DebugStub/Cosmos.Debug.DebugStub.csproj @@ -75,6 +75,11 @@ + + True + True + Screen.xs + True True @@ -108,6 +113,7 @@ CosmosXSharpGenerator + Screen.cs CosmosXSharpGenerator diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/Old/Init.cs b/source2/Compiler/Cosmos.Compiler.DebugStub/Old/Init.cs index 1af1e97ca..03bfc58ec 100644 --- a/source2/Compiler/Cosmos.Compiler.DebugStub/Old/Init.cs +++ b/source2/Compiler/Cosmos.Compiler.DebugStub/Old/Init.cs @@ -26,11 +26,11 @@ namespace Cosmos.Debug.DebugStub { // Called before Kernel runs. Inits debug stub, etc public class Init : CodeBlock { public override void Assemble() { - Call(); + Call("DebugStub_Cls"); Call(); Call(); Call(); - Call(); + Call("DebugStub_Cls"); } } diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/Old/Screen.cs b/source2/Compiler/Cosmos.Compiler.DebugStub/Old/Screen.cs index 91267e0f4..5148430af 100644 --- a/source2/Compiler/Cosmos.Compiler.DebugStub/Old/Screen.cs +++ b/source2/Compiler/Cosmos.Compiler.DebugStub/Old/Screen.cs @@ -11,7 +11,7 @@ namespace Cosmos.Debug.DebugStub { public partial class DebugStub : CodeGroup { protected const uint VidBase = 0xB8000; - public class Cls : CodeBlock { + public class Cls2 : CodeBlock { public override void Assemble() { ESI = VidBase; Label = "DebugStub_Cls_More"; diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/Screen.xs b/source2/Compiler/Cosmos.Compiler.DebugStub/Screen.xs index 6a01d99bc..111d66935 100644 --- a/source2/Compiler/Cosmos.Compiler.DebugStub/Screen.xs +++ b/source2/Compiler/Cosmos.Compiler.DebugStub/Screen.xs @@ -1,6 +1,6 @@ Group DebugStub -procedure Cls2 { +procedure Cls { # VidBase ESI = $B8000 @@ -17,7 +17,7 @@ BeginLoop: # End of Video Area # VidBase + 25 * 80 * 2 = B8FA0 - ESI < $B8FA0 + #ESI ? $B8FA0 #if < goto BeginLoop - # If (ESI < $B8FA0) goto .BeginLoop + If (ESI < $B8FA0) goto BeginLoop } \ No newline at end of file diff --git a/source2/Compiler/Cosmos.XSharp/Parser.cs b/source2/Compiler/Cosmos.XSharp/Parser.cs index c9a78797a..cb5288c39 100644 --- a/source2/Compiler/Cosmos.XSharp/Parser.cs +++ b/source2/Compiler/Cosmos.XSharp/Parser.cs @@ -20,7 +20,7 @@ namespace Cosmos.Compiler.XSharp { public static string[] mKeywords = ( "CALL" + ",END,EXIT" - + ",GOTO, GROUP" + + ",GOTO,GROUP" + ",IF,INTERRUPTHANDLER" + ",JUMP" + ",POPALL,PUSHALL,PROCEDURE,PORT" @@ -146,6 +146,8 @@ namespace Cosmos.Compiler.XSharp { xToken.Type = TokenType.LessThan; } else if (xString == ">") { xToken.Type = TokenType.GreaterThan; + } else if (xString == "?") { + xToken.Type = TokenType.Question; } #endregion } diff --git a/source2/Compiler/Cosmos.XSharp/Token.cs b/source2/Compiler/Cosmos.XSharp/Token.cs index eeefc6905..915efafa7 100644 --- a/source2/Compiler/Cosmos.XSharp/Token.cs +++ b/source2/Compiler/Cosmos.XSharp/Token.cs @@ -12,7 +12,7 @@ namespace Cosmos.Compiler.XSharp { // Values , ValueInt // Symbols - , Equals, BracketLeft, BracketRight, Plus, Minus, Colon, Dollar, CurlyLeft, CurlyRight, Dot, Comma, LessThan, GreaterThan + , Equals, BracketLeft, BracketRight, Plus, Minus, Colon, Dollar, CurlyLeft, CurlyRight, Dot, Comma, LessThan, GreaterThan, Question // , WhiteSpace // For now used during scanning while user is typing, but in future could be user methods we have to find etc diff --git a/source2/Compiler/Cosmos.XSharp/TokenPatterns.cs b/source2/Compiler/Cosmos.XSharp/TokenPatterns.cs index 075d9186f..e7200915e 100644 --- a/source2/Compiler/Cosmos.XSharp/TokenPatterns.cs +++ b/source2/Compiler/Cosmos.XSharp/TokenPatterns.cs @@ -88,8 +88,22 @@ namespace Cosmos.Compiler.XSharp { } ); - // TODO - Combine these to code to scan - AddPattern("_REG < 123", + AddPattern(new string[] { "if < goto .._ABC", "if < goto ._ABC", "if < goto _ABC" }, + delegate(TokenList aTokens, ref List rCode) { + string xLabel = GetLabel(aTokens, 3); + rCode.Add("new ConditionalJump {{ Condition = ConditionalTestEnum.LessThan, DestinationLabel = " + Quoted(xLabel) + " }};"); + } + ); + + AddPattern(new string[] { "if (_REG < 123) goto .._ABC", "if (_REG < 123) goto ._ABC", "if (_REG < 123) goto _ABC" }, + delegate(TokenList aTokens, ref List rCode) { + rCode.Add("new Compare {{ DestinationReg = RegistersEnum.{2}, SourceValue = {4} }};"); + string xLabel = GetLabel(aTokens, 7); + rCode.Add("new ConditionalJump {{ Condition = ConditionalTestEnum.LessThan, DestinationLabel = " + Quoted(xLabel) + " }};"); + } + ); + + AddPattern("_REG ? 123", "new Compare {{ DestinationReg = RegistersEnum.{0}, SourceValue = {2} }};" ); diff --git a/source2/Users/Kudzu/Kudzu-Notes.html b/source2/Users/Kudzu/Kudzu-Notes.html index 2f1a84ad9..adec90340 100644 --- a/source2/Users/Kudzu/Kudzu-Notes.html +++ b/source2/Users/Kudzu/Kudzu-Notes.html @@ -34,7 +34,10 @@ To Do
  • X#
      -
    • Emit X# comment source above each output
    • +
    • _LABEL
    • +
    • Combine register code
    • +
    • Find out why installer doesnt replace XSharp extension without manual uninstall + - important for user kit too
    • Complete
    • Code Completion
    diff --git a/source2/VSIP/Cosmos.VS.XSharp/Docs/Goals.html b/source2/VSIP/Cosmos.VS.XSharp/Docs/Goals.html index cde0c2573..a56bc5b00 100644 --- a/source2/VSIP/Cosmos.VS.XSharp/Docs/Goals.html +++ b/source2/VSIP/Cosmos.VS.XSharp/Docs/Goals.html @@ -14,7 +14,11 @@

    Easy to parse

    - 1:1 mapping for debugging, non disconnect

    + Close to + 1:1 mapping for debugging, non disconnect. No large compounds.

    +

    + All x86 ops have a 1:1 X# op, but there can be more X# ops which have mult x86 + ops

     

    diff --git a/source2/VSIP/Cosmos.VS.XSharp/FileGenerator.cs b/source2/VSIP/Cosmos.VS.XSharp/FileGenerator.cs index c3b28cdaa..ba9d571ce 100644 --- a/source2/VSIP/Cosmos.VS.XSharp/FileGenerator.cs +++ b/source2/VSIP/Cosmos.VS.XSharp/FileGenerator.cs @@ -32,10 +32,11 @@ namespace Cosmos.VS.XSharp { } private static string DoGenerate(string aInputFileName, string aInputFileContents, string aDefaultNamespace) { + string xClassName = Path.GetFileNameWithoutExtension(aInputFileName); using (var xInput = new StringReader(aInputFileContents)) { using (var xOutput = new StringWriter()) { var xGenerator = new Cosmos.Compiler.XSharp.Generator(); - xGenerator.Execute(aDefaultNamespace, aInputFileName, xInput, xOutput); + xGenerator.Execute(aDefaultNamespace, xClassName, xInput, xOutput); return xOutput.ToString(); } } diff --git a/source2/VSIP/Cosmos.VS.XSharp/Scanner.cs b/source2/VSIP/Cosmos.VS.XSharp/Scanner.cs index f85d2f47f..ab5abc573 100644 --- a/source2/VSIP/Cosmos.VS.XSharp/Scanner.cs +++ b/source2/VSIP/Cosmos.VS.XSharp/Scanner.cs @@ -45,6 +45,7 @@ namespace Cosmos.VS.XSharp { mTokenMap[(int)XSC.TokenType.Dollar] = new TokenData { Type = TokenType.Operator, Color = TokenColor.Text }; mTokenMap[(int)XSC.TokenType.LessThan] = new TokenData { Type = TokenType.Operator, Color = TokenColor.Text }; mTokenMap[(int)XSC.TokenType.GreaterThan] = new TokenData { Type = TokenType.Operator, Color = TokenColor.Text }; + mTokenMap[(int)XSC.TokenType.Question] = new TokenData { Type = TokenType.Operator, Color = TokenColor.Text }; mTokenMap[(int)XSC.TokenType.WhiteSpace] = new TokenData { Type = TokenType.WhiteSpace, Color = TokenColor.Text }; mTokenMap[(int)XSC.TokenType.Unknown] = new TokenData { Type = TokenType.Unknown, Color = TokenColor.Text };