From cdda05918789b8b8503ba54476e09b71b220b5bb Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 2 Mar 2016 02:01:52 -0500 Subject: [PATCH 1/8] Removed version number --- sbdump/main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbdump/main.cs b/sbdump/main.cs index dce69dc..81b4c51 100644 --- a/sbdump/main.cs +++ b/sbdump/main.cs @@ -12,7 +12,7 @@ namespace arookas { static uint sTextOffset, sDataOffset, sDynsymOffset; static int sDataCount, sDynsymCount, sBssCount; - const string cTitle = "sbdump v0.1 arookas"; + const string cTitle = "sbdump arookas"; static readonly string[] sSymbolTypes = { "builtin", "function", "var", }; static readonly string[] sCommandNames = { "int", "flt", "str", "adr", "var", "nop", "inc", "dec", From 164feee3197bf56300b6db8ce063afad69ef1015 Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 2 Mar 2016 02:02:53 -0500 Subject: [PATCH 2/8] Renamed .dynsm to .sym It's not exactly an ELF binary, and it's called sym in SMS so I may as well stay consistent. --- sbdump/main.cs | 10 +++++----- sbdump/settings.cs | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sbdump/main.cs b/sbdump/main.cs index 81b4c51..dae201c 100644 --- a/sbdump/main.cs +++ b/sbdump/main.cs @@ -44,8 +44,8 @@ namespace arookas { if (sSettings.OutputData) { WriteData(); } - if (sSettings.OutputDynsym) { - WriteDynsym(); + if (sSettings.OutputSym) { + WriteSym(); } if (sSettings.OutputBss) { WriteBss(); @@ -198,9 +198,9 @@ namespace arookas { } sWriter.WriteLine(); } - static void WriteDynsym() { - Console.WriteLine("Outputting .dynsym..."); - sWriter.WriteLine(".dynsym"); + static void WriteSym() { + Console.WriteLine("Outputting .sym..."); + sWriter.WriteLine(".sym"); sReader.Goto(sDynsymOffset); for (int i = 0; i < sDynsymCount; ++i) { var symbol = new Symbol(sReader); diff --git a/sbdump/settings.cs b/sbdump/settings.cs index 189fa3a..5f5214a 100644 --- a/sbdump/settings.cs +++ b/sbdump/settings.cs @@ -4,14 +4,14 @@ using System.IO; namespace arookas { class CommandLineSettings { string mInput, mOutput; - bool mOutputHeader, mOutputText, mOutputData, mOutputDynsym, mOutputBss; + bool mOutputHeader, mOutputText, mOutputData, mOutputSym, mOutputBss; public string Input { get { return mInput; } } public string Output { get { return mOutput; } } public bool OutputHeader { get { return mOutputHeader; } } public bool OutputText { get { return mOutputText; } } public bool OutputData { get { return mOutputData; } } - public bool OutputDynsym { get { return mOutputDynsym; } } + public bool OutputSym { get { return mOutputSym; } } public bool OutputBss { get { return mOutputBss; } } public CommandLineSettings(aCommandLine cmd) { @@ -28,8 +28,8 @@ namespace arookas { case "-t": mOutputText = false; continue; case "-D": mOutputData = true; continue; case "-d": mOutputData = false; continue; - case "-S": mOutputDynsym = true; continue; - case "-s": mOutputDynsym = false; continue; + case "-S": mOutputSym = true; continue; + case "-s": mOutputSym = false; continue; case "-B": mOutputBss = true; continue; case "-b": mOutputBss = false; continue; } From 9e3597c92540c95ba88edfd5bc8880710e311127 Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 2 Mar 2016 02:09:13 -0500 Subject: [PATCH 3/8] Added quote blocks --- readme.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 16a6f25..93b8ab0 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,7 @@ # ssc ![SunScript ST3 syntax preview](http://i.imgur.com/YHChKwd.png) +> Preview of [the standard library](stdlib/talk.sun) in Sublime Text 3 using the included [syntax script](sunscript.sublime-syntax). ## Summary @@ -50,8 +51,8 @@ All dependencies must be placed in the _lib-dir_ folder (see below), unless stat |[arookas library](https://github.com/arookas/arookas)|Preferably, the library should be built in the same configuration as _ssc_ (e.g. debug, release).| |[Grammatica 1.6](http://grammatica.percederberg.net/)|Already included in the repository.| -_**Note:** A Java runtime compatible with JDK 1.5 is required for generating the Grammatica parser classes during compilation. -For more information, see Grammatica's official [installation documentation](http://grammatica.percederberg.net/doc/release/install.html)._ +> A Java runtime compatible with JDK 1.5 is required for generating the Grammatica parser classes during compilation. +> For more information, see Grammatica's official [installation documentation](http://grammatica.percederberg.net/doc/release/install.html). ### premake From f03fb8ac103248ac6b91e03defa42b0dd1c88a97 Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 2 Mar 2016 02:11:40 -0500 Subject: [PATCH 4/8] More renaming --- sbdump/main.cs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sbdump/main.cs b/sbdump/main.cs index dae201c..c05dd9c 100644 --- a/sbdump/main.cs +++ b/sbdump/main.cs @@ -9,8 +9,8 @@ namespace arookas { static CommandLineSettings sSettings; static aBinaryReader sReader; static TextWriter sWriter; - static uint sTextOffset, sDataOffset, sDynsymOffset; - static int sDataCount, sDynsymCount, sBssCount; + static uint sTextOffset, sDataOffset, sSymOffset; + static int sDataCount, sSymCount, sVarCount; const string cTitle = "sbdump arookas"; static readonly string[] sSymbolTypes = { "builtin", "function", "var", }; @@ -88,9 +88,9 @@ namespace arookas { sTextOffset = sReader.Read32(); sDataOffset = sReader.Read32(); sDataCount = sReader.ReadS32(); - sDynsymOffset = sReader.Read32(); - sDynsymCount = sReader.ReadS32(); - sBssCount = sReader.ReadS32(); + sSymOffset = sReader.Read32(); + sSymCount = sReader.ReadS32(); + sVarCount = sReader.ReadS32(); } static void WriteHeader() { Console.WriteLine("Outputting header..."); @@ -98,17 +98,17 @@ namespace arookas { sWriter.WriteLine("# .text offset : {0:X8}", sTextOffset); sWriter.WriteLine("# .data offset : {0:X8}", sDataOffset); sWriter.WriteLine("# .data count : {0}", sDataCount); - sWriter.WriteLine("# .dynsym offset : {0:X8}", sDynsymOffset); - sWriter.WriteLine("# .dynsym count : {0}", sDynsymCount); - sWriter.WriteLine("# .bss count : {0}", sBssCount); + sWriter.WriteLine("# .sym offset : {0:X8}", sSymOffset); + sWriter.WriteLine("# .sym count : {0}", sSymCount); + sWriter.WriteLine("# var count : {0}", sVarCount); sWriter.WriteLine(); } static void WriteText() { Console.WriteLine("Outputting .text..."); sWriter.WriteLine(".text"); WriteText(0u); - var symbols = new Symbol[sDynsymCount]; - for (var i = 0; i < sDynsymCount; ++i) { + var symbols = new Symbol[sSymCount]; + for (var i = 0; i < sSymCount; ++i) { symbols[i] = FetchSymbol(i); } foreach (var symbol in symbols.Where(i => i.Type == SymbolType.Function).OrderBy(i => i.Data)) { @@ -201,8 +201,8 @@ namespace arookas { static void WriteSym() { Console.WriteLine("Outputting .sym..."); sWriter.WriteLine(".sym"); - sReader.Goto(sDynsymOffset); - for (int i = 0; i < sDynsymCount; ++i) { + sReader.Goto(sSymOffset); + for (int i = 0; i < sSymCount; ++i) { var symbol = new Symbol(sReader); var name = FetchSymbolName(symbol); sWriter.WriteLine(" .{0} {1}", sSymbolTypes[(int)symbol.Type], name); @@ -212,7 +212,7 @@ namespace arookas { static void WriteBss() { Console.WriteLine("Outputting .bss..."); sWriter.WriteLine(".bss"); - for (int i = 0; i < sBssCount; ++i) { + for (int i = 0; i < sVarCount; ++i) { var symbol = FetchSymbol(j => j.Type == SymbolType.Variable && j.Data == i); if (symbol != null) { sWriter.WriteLine(" .var {0}", FetchSymbolName(symbol)); @@ -246,7 +246,7 @@ namespace arookas { } static Symbol FetchSymbol(int i) { sReader.Keep(); - sReader.Goto(sDynsymOffset + (20 * i)); + sReader.Goto(sSymOffset + (20 * i)); var symbol = new Symbol(sReader); sReader.Back(); return symbol; @@ -257,8 +257,8 @@ namespace arookas { } Symbol found = null; sReader.Keep(); - sReader.Goto(sDynsymOffset); - for (int i = 0; i < sDynsymCount; ++i) { + sReader.Goto(sSymOffset); + for (int i = 0; i < sSymCount; ++i) { var symbol = new Symbol(sReader); if (predicate(symbol)) { found = symbol; @@ -270,7 +270,7 @@ namespace arookas { } static string FetchSymbolName(Symbol symbol) { sReader.Keep(); - sReader.Goto(sDynsymOffset + (20 * sDynsymCount) + symbol.StringOffset); + sReader.Goto(sSymOffset + (20 * sSymCount) + symbol.StringOffset); var name = sReader.ReadString(); sReader.Back(); return name; From a17a6c4b8423a5824d75cd58804fcc64d0d21f64 Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 2 Mar 2016 02:44:47 -0500 Subject: [PATCH 5/8] Even more renaming WILL IT EVER STOP?! --- sbdump/main.cs | 16 ++++++++-------- sbdump/settings.cs | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sbdump/main.cs b/sbdump/main.cs index c05dd9c..550bf59 100644 --- a/sbdump/main.cs +++ b/sbdump/main.cs @@ -47,8 +47,8 @@ namespace arookas { if (sSettings.OutputSym) { WriteSym(); } - if (sSettings.OutputBss) { - WriteBss(); + if (sSettings.OutputVars) { + WriteVars(); } Console.WriteLine("Closing output file..."); } @@ -209,16 +209,16 @@ namespace arookas { } sWriter.WriteLine(); } - static void WriteBss() { - Console.WriteLine("Outputting .bss..."); - sWriter.WriteLine(".bss"); for (int i = 0; i < sVarCount; ++i) { + static void WriteVars() { + Console.WriteLine("Outputting variables..."); + sWriter.WriteLine("# variables:"); var symbol = FetchSymbol(j => j.Type == SymbolType.Variable && j.Data == i); if (symbol != null) { - sWriter.WriteLine(" .var {0}", FetchSymbolName(symbol)); + sWriter.WriteLine("# {0}", FetchSymbolName(symbol)); } else { - sWriter.WriteLine(" .var"); + sWriter.WriteLine("# (NULL)"); } } sWriter.WriteLine(); @@ -233,7 +233,7 @@ namespace arookas { } static string FetchDataValue(int i) { if (i < 0 || i >= sDataCount) { - return "null"; + return "(NULL)"; } return FetchDataValue(FetchData(i)); } diff --git a/sbdump/settings.cs b/sbdump/settings.cs index 5f5214a..e06ab2e 100644 --- a/sbdump/settings.cs +++ b/sbdump/settings.cs @@ -4,7 +4,7 @@ using System.IO; namespace arookas { class CommandLineSettings { string mInput, mOutput; - bool mOutputHeader, mOutputText, mOutputData, mOutputSym, mOutputBss; + bool mOutputHeader, mOutputText, mOutputData, mOutputSym, mOutputVars; public string Input { get { return mInput; } } public string Output { get { return mOutput; } } @@ -12,7 +12,7 @@ namespace arookas { public bool OutputText { get { return mOutputText; } } public bool OutputData { get { return mOutputData; } } public bool OutputSym { get { return mOutputSym; } } - public bool OutputBss { get { return mOutputBss; } } + public bool OutputVars { get { return mOutputVars; } } public CommandLineSettings(aCommandLine cmd) { if (cmd == null) { @@ -30,8 +30,8 @@ namespace arookas { case "-d": mOutputData = false; continue; case "-S": mOutputSym = true; continue; case "-s": mOutputSym = false; continue; - case "-B": mOutputBss = true; continue; - case "-b": mOutputBss = false; continue; + case "-V": mOutputVars = true; continue; + case "-v": mOutputVars = false; continue; } } if (mInput == null) { From da3b81cf339fe2cd0cf8e84290ab8ac7c5bf00d6 Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 2 Mar 2016 02:45:06 -0500 Subject: [PATCH 6/8] var keyword is awesome --- sbdump/main.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbdump/main.cs b/sbdump/main.cs index 550bf59..d1f9d78 100644 --- a/sbdump/main.cs +++ b/sbdump/main.cs @@ -191,7 +191,7 @@ namespace arookas { Console.WriteLine("Outputting .data..."); sWriter.WriteLine(".data"); sReader.Goto(sDataOffset); - for (int i = 0; i < sDataCount; ++i) { + for (var i = 0; i < sDataCount; ++i) { var ofs = sReader.Read32(); var data = FetchDataValue(ofs); sWriter.WriteLine(" .string \"{0}\"", data); @@ -202,17 +202,17 @@ namespace arookas { Console.WriteLine("Outputting .sym..."); sWriter.WriteLine(".sym"); sReader.Goto(sSymOffset); - for (int i = 0; i < sSymCount; ++i) { + for (var i = 0; i < sSymCount; ++i) { var symbol = new Symbol(sReader); var name = FetchSymbolName(symbol); sWriter.WriteLine(" .{0} {1}", sSymbolTypes[(int)symbol.Type], name); } sWriter.WriteLine(); } - for (int i = 0; i < sVarCount; ++i) { static void WriteVars() { Console.WriteLine("Outputting variables..."); sWriter.WriteLine("# variables:"); + for (var i = 0; i < sVarCount; ++i) { var symbol = FetchSymbol(j => j.Type == SymbolType.Variable && j.Data == i); if (symbol != null) { sWriter.WriteLine("# {0}", FetchSymbolName(symbol)); @@ -258,7 +258,7 @@ namespace arookas { Symbol found = null; sReader.Keep(); sReader.Goto(sSymOffset); - for (int i = 0; i < sSymCount; ++i) { + for (var i = 0; i < sSymCount; ++i) { var symbol = new Symbol(sReader); if (predicate(symbol)) { found = symbol; From 54f5e0162ca72e051c2b6fc9129cd154bb8f8187 Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 2 Mar 2016 02:46:13 -0500 Subject: [PATCH 7/8] Fixed: ret0 made text output quit early Now it checks if there's a jne or jmp command pointing past the current ret, ret0, or end command and, if so, keeps going. --- sbdump/main.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sbdump/main.cs b/sbdump/main.cs index d1f9d78..a5f05d9 100644 --- a/sbdump/main.cs +++ b/sbdump/main.cs @@ -120,10 +120,12 @@ namespace arookas { byte command; sReader.Keep(); sReader.Goto(sTextOffset + ofs); + var maxofs = 0u; do { var pos = sReader.Position - sTextOffset; command = sReader.Read8(); sWriter.Write(" {0:X8} {1}", pos, sCommandNames[command]); + var nextofs = 0u; switch (command) { case 0x00: sWriter.Write(" {0}", sReader.ReadS32()); break; case 0x01: sWriter.Write(" {0}", sReader.ReadF32()); break; @@ -157,12 +159,14 @@ namespace arookas { case 0x1D: sWriter.Write(" {0}, {1}", FetchSymbolName(FetchSymbol(sReader.ReadS32())), sReader.ReadS32()); break; case 0x1E: sWriter.Write(" {0}", sReader.ReadS32()); break; case 0x1F: sWriter.Write(" {0}", sReader.ReadS32()); break; - case 0x22: WriteJmp(ofs); break; - case 0x23: WriteJmp(ofs); break; + case 0x22: nextofs = WriteJmp(ofs); break; + case 0x23: nextofs = WriteJmp(ofs); break; } sWriter.WriteLine(); - - } while (command != 0x21 && command != 0x27); + if (nextofs > maxofs) { + maxofs = nextofs; + } + } while (!IsReturnCommand(command) || sReader.Position <= sTextOffset + maxofs); sWriter.WriteLine(); sReader.Back(); } @@ -275,5 +279,13 @@ namespace arookas { sReader.Back(); return name; } + + static bool IsReturnCommand(byte cmd) { + return ( + cmd == 0x20 || // ret + cmd == 0x21 || // ret0 + cmd == 0x27 // end + ); + } } } From 26d742dda59b469f5d1a6d0fc5191d0c4e1c258d Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 2 Mar 2016 02:54:48 -0500 Subject: [PATCH 8/8] Removed assembly-info files These auto-generated pieces of shit are just not important enough to keep up-to-date. --- frontend/AssemblyInfo.cs | 16 ---------------- sbdump/AssemblyInfo.cs | 15 --------------- ssc/AssemblyInfo.cs | 16 ---------------- 3 files changed, 47 deletions(-) delete mode 100644 frontend/AssemblyInfo.cs delete mode 100644 sbdump/AssemblyInfo.cs delete mode 100644 ssc/AssemblyInfo.cs diff --git a/frontend/AssemblyInfo.cs b/frontend/AssemblyInfo.cs deleted file mode 100644 index 1eb2a3f..0000000 --- a/frontend/AssemblyInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("SSC")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SSC")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ComVisible(false)] -[assembly: Guid("1e643680-49e4-44b9-be23-6df4ce5017db")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] diff --git a/sbdump/AssemblyInfo.cs b/sbdump/AssemblyInfo.cs deleted file mode 100644 index 896cf10..0000000 --- a/sbdump/AssemblyInfo.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("sbdump")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("arookas")] -[assembly: AssemblyProduct("sbdump")] -[assembly: AssemblyCopyright("Copyright © 2015 arookas")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ComVisible(false)] -[assembly: Guid("e2610ef0-cb2d-4f90-a18a-a2e7db316202")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] diff --git a/ssc/AssemblyInfo.cs b/ssc/AssemblyInfo.cs deleted file mode 100644 index 235ad97..0000000 --- a/ssc/AssemblyInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("ssc")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ssc")] -[assembly: AssemblyCopyright("Copyright © 2015 arookas")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ComVisible(false)] -[assembly: Guid("5413c8e1-aefa-43bc-9fe5-c95f221da8c5")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")]