diff --git a/Users/Matthijs/DebugCompiler/MyEngine.cs b/Users/Matthijs/DebugCompiler/MyEngine.cs
index c9b535fdb..0dfa91da0 100644
--- a/Users/Matthijs/DebugCompiler/MyEngine.cs
+++ b/Users/Matthijs/DebugCompiler/MyEngine.cs
@@ -17,7 +17,7 @@ namespace DebugCompiler
var xEngine = new Engine();
// Sets the time before an error is registered. For example if set to 60 then if a kernel runs for more than 60 seconds then
// that kernel will be marked as a failiure and terminated
- xEngine.AllowedSecondsInKernel = 600;
+ xEngine.AllowedSecondsInKernel = 30;
// If you want to test only specific platforms, add them to the list, like next line. By default, all platforms are run.
xEngine.RunTargets.Add(RunTargetEnum.Bochs);
diff --git a/source/Cosmos.Debug.DebugStub/AsmBreak.asm b/source/Cosmos.Debug.DebugStub/AsmBreak.asm
index fc9146c51..206c0e7de 100644
--- a/source/Cosmos.Debug.DebugStub/AsmBreak.asm
+++ b/source/Cosmos.Debug.DebugStub/AsmBreak.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
DebugStub_AsmBreakEIP dd 0
DebugStub_AsmOrigByte dd 0
diff --git a/source/Cosmos.Debug.DebugStub/CmdMisc.asm b/source/Cosmos.Debug.DebugStub/CmdMisc.asm
index 46bd98d1a..a07929443 100644
--- a/source/Cosmos.Debug.DebugStub/CmdMisc.asm
+++ b/source/Cosmos.Debug.DebugStub/CmdMisc.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
diff --git a/source/Cosmos.Debug.DebugStub/CmdProcess.asm b/source/Cosmos.Debug.DebugStub/CmdProcess.asm
index a91413faa..246135b07 100644
--- a/source/Cosmos.Debug.DebugStub/CmdProcess.asm
+++ b/source/Cosmos.Debug.DebugStub/CmdProcess.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
diff --git a/source/Cosmos.Debug.DebugStub/CmdSend.asm b/source/Cosmos.Debug.DebugStub/CmdSend.asm
index c4b76c5c2..f293729f0 100644
--- a/source/Cosmos.Debug.DebugStub/CmdSend.asm
+++ b/source/Cosmos.Debug.DebugStub/CmdSend.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
diff --git a/source/Cosmos.Debug.DebugStub/Consts.asm b/source/Cosmos.Debug.DebugStub/Consts.asm
index 93305d65b..8db78d946 100644
--- a/source/Cosmos.Debug.DebugStub/Consts.asm
+++ b/source/Cosmos.Debug.DebugStub/Consts.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
DebugStub_Const_Signature equ 427034631
diff --git a/source/Cosmos.Debug.DebugStub/DebugStub.asm b/source/Cosmos.Debug.DebugStub/DebugStub.asm
index 859b95057..ac29f48a5 100644
--- a/source/Cosmos.Debug.DebugStub/DebugStub.asm
+++ b/source/Cosmos.Debug.DebugStub/DebugStub.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
DebugStub_CallerEBP dd 0
DebugStub_CallerEIP dd 0
diff --git a/source/Cosmos.Debug.DebugStub/Init.asm b/source/Cosmos.Debug.DebugStub/Init.asm
index af24919a4..ad7076dca 100644
--- a/source/Cosmos.Debug.DebugStub/Init.asm
+++ b/source/Cosmos.Debug.DebugStub/Init.asm
@@ -1,66 +1,2 @@
-; Generated at 6/12/2016 3:34:04 PM
-DebugStub_MaxBPId dd 0
-
-DebugStub_DebugBPs: TIMES 256 dd 0
-
-DebugStub_Init:
-Call DebugStub_Cls
-Call DebugStub_DisplayWaitMsg
-Call DebugStub_InitSerial
-Call DebugStub_WaitForDbgHandshake
-Call DebugStub_Cls
-
-DebugStub_Init_Exit:
-mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], DebugStub_Init_Exit
-Ret
-
-
-DebugStub_WaitForSignature:
-mov dword EBX, 0x0
-
-DebugStub_WaitForSignature_Block1_Begin:
-cmp dword EBX, DebugStub_Const_Signature
-JE near DebugStub_WaitForSignature_Block1_End
-Call DebugStub_ComReadAL
-mov byte BL, AL
-ror dword EBX, 0x8
-Jmp DebugStub_WaitForSignature_Block1_Begin
-
-DebugStub_WaitForSignature_Block1_End:
-
-DebugStub_WaitForSignature_Exit:
-mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], DebugStub_WaitForSignature_Exit
-Ret
-
-
-DebugStub_WaitForDbgHandshake:
-mov byte AL, 0x0
-Call DebugStub_ComWriteAL
-mov byte AL, 0x0
-Call DebugStub_ComWriteAL
-mov byte AL, 0x0
-Call DebugStub_ComWriteAL
-push dword DebugStub_Const_Signature
-mov dword ESI, ESP
-Call DebugStub_ComWrite32
-pop dword EAX
-mov byte AL, DebugStub_Const_Ds2Vs_Started
-Call DebugStub_ComWriteAL
-Call DebugStub_WaitForSignature
-Call DebugStub_ProcessCommandBatch
-Call DebugStub_Hook_OnHandshakeCompleted
-
-DebugStub_WaitForDbgHandshake_Exit:
-mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], DebugStub_WaitForDbgHandshake_Exit
-Ret
-
-%ifndef Exclude_Dummy_Hooks
-
-DebugStub_Hook_OnHandshakeCompleted:
-
-DebugStub_Hook_OnHandshakeCompleted_Exit:
-mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], DebugStub_Hook_OnHandshakeCompleted_Exit
-Ret
-
-%endif
+Object reference not set to an instance of an object.
diff --git a/source/Cosmos.Debug.DebugStub/Screen.asm b/source/Cosmos.Debug.DebugStub/Screen.asm
index 389dc29e0..acc92ef0d 100644
--- a/source/Cosmos.Debug.DebugStub/Screen.asm
+++ b/source/Cosmos.Debug.DebugStub/Screen.asm
@@ -1,47 +1,49 @@
-; Generated at 6/12/2016 3:34:04 PM
-
-DebugWaitMsg db 96, 87, 97, 105, 116, 105, 110, 103, 32, 102, 111, 114, 32, 100, 101, 98, 117, 103, 103, 101, 114, 32, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 46, 46, 46, 96, 0
-
-%ifndef Exclude_Memory_Based_Console
-DebugStub_Const_VidBase equ 753664
-
-DebugStub_Cls:
-mov dword ESI, DebugStub_Const_VidBase
-
-DebugStub_Cls_Block1_Begin:
-cmp dword ESI, 0xB8FA0
-JNB near DebugStub_Cls_Block1_End
-mov dword [ESI], 0x0
-inc dword ESI
-mov dword [ESI], 0xA
-inc dword ESI
-Jmp DebugStub_Cls_Block1_Begin
-
-DebugStub_Cls_Block1_End:
-
-DebugStub_Cls_Exit:
-mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], DebugStub_Cls_Exit
-Ret
+; Generated at 14-6-2016 12:37:38
-DebugStub_DisplayWaitMsg:
-mov dword ESI, DebugWaitMsg
-mov dword EDI, DebugStub_Const_VidBase
-add dword EDI, 0x668
+ DebugWaitMsg db 87, 97, 105, 116, 105, 110, 103, 32, 102, 111, 114, 32, 100, 101, 98, 117, 103, 103, 101, 114, 32, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 46, 46, 46, 0
-DebugStub_DisplayWaitMsg_Block1_Begin:
-cmp dword [ESI], 0x0
-JE near DebugStub_DisplayWaitMsg_Block1_End
-mov byte AL, [ESI]
-mov byte [EDI], AL
-inc dword ESI
-add dword EDI, 0x2
-Jmp DebugStub_DisplayWaitMsg_Block1_Begin
+ %ifndef Exclude_Memory_Based_Console
+ DebugStub_Const_VidBase equ 753664
-DebugStub_DisplayWaitMsg_Block1_End:
+ DebugStub_Cls:
+ mov dword ESI, DebugStub_Const_VidBase
-DebugStub_DisplayWaitMsg_Exit:
-mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], DebugStub_DisplayWaitMsg_Exit
-Ret
+ DebugStub_Cls_Block1_Begin:
+ cmp dword ESI, 0xB8FA0
+ JNB near DebugStub_Cls_Block1_End
+ mov dword [ESI], 0x0
+ inc dword ESI
+ mov dword [ESI], 0xA
+ inc dword ESI
+ Jmp DebugStub_Cls_Block1_Begin
+
+ DebugStub_Cls_Block1_End:
+
+ DebugStub_Cls_Exit:
+ mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], DebugStub_Cls_Exit
+ Ret
+
+
+ DebugStub_DisplayWaitMsg:
+ mov dword ESI, DebugWaitMsg
+ mov dword EDI, DebugStub_Const_VidBase
+ add dword EDI, 0x668
+
+ DebugStub_DisplayWaitMsg_Block1_Begin:
+ cmp byte [ESI], 0x0
+ JE near DebugStub_DisplayWaitMsg_Block1_End
+ mov byte AL, [ESI]
+ mov byte [EDI], AL
+ inc dword ESI
+ add dword EDI, 0x2
+ Jmp DebugStub_DisplayWaitMsg_Block1_Begin
+
+ DebugStub_DisplayWaitMsg_Block1_End:
+
+ DebugStub_DisplayWaitMsg_Exit:
+ mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], DebugStub_DisplayWaitMsg_Exit
+ Ret
+
+ %endif
-%endif
diff --git a/source/Cosmos.Debug.DebugStub/Screen.xs b/source/Cosmos.Debug.DebugStub/Screen.xs
index 87a8df697..d081da5cf 100644
--- a/source/Cosmos.Debug.DebugStub/Screen.xs
+++ b/source/Cosmos.Debug.DebugStub/Screen.xs
@@ -8,7 +8,7 @@ const VidBase = $B8000
function Cls {
ESI = #VidBase
-
+
// End of Video Area
// VidBase + 25 * 80 * 2 = B8FA0
while ESI < $B8FA0 {
@@ -38,4 +38,4 @@ function DisplayWaitMsg {
}
}
-! %endif
\ No newline at end of file
+! %endif
diff --git a/source/Cosmos.Debug.DebugStub/Serial.asm b/source/Cosmos.Debug.DebugStub/Serial.asm
index c684f3055..3bd23b8bc 100644
--- a/source/Cosmos.Debug.DebugStub/Serial.asm
+++ b/source/Cosmos.Debug.DebugStub/Serial.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
%ifndef Exclude_IOPort_Based_SerialInit
diff --git a/source/Cosmos.Debug.DebugStub/SerialHelpers.asm b/source/Cosmos.Debug.DebugStub/SerialHelpers.asm
index 46baff53a..ac326a0f9 100644
--- a/source/Cosmos.Debug.DebugStub/SerialHelpers.asm
+++ b/source/Cosmos.Debug.DebugStub/SerialHelpers.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
diff --git a/source/Cosmos.Debug.DebugStub/SerialIO.asm b/source/Cosmos.Debug.DebugStub/SerialIO.asm
index 33f837c82..fd9b17023 100644
--- a/source/Cosmos.Debug.DebugStub/SerialIO.asm
+++ b/source/Cosmos.Debug.DebugStub/SerialIO.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
DebugStub_ComAddr dd 1016
diff --git a/source/Cosmos.Debug.DebugStub/TracerEntry.asm b/source/Cosmos.Debug.DebugStub/TracerEntry.asm
index 7810807b3..190298e3d 100644
--- a/source/Cosmos.Debug.DebugStub/TracerEntry.asm
+++ b/source/Cosmos.Debug.DebugStub/TracerEntry.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
diff --git a/source/Cosmos.Debug.DebugStub/Utilities.asm b/source/Cosmos.Debug.DebugStub/Utilities.asm
index 8ef7b5773..c0bdcce77 100644
--- a/source/Cosmos.Debug.DebugStub/Utilities.asm
+++ b/source/Cosmos.Debug.DebugStub/Utilities.asm
@@ -1,4 +1,4 @@
-; Generated at 6/12/2016 3:34:04 PM
+; Generated at 6/14/2016 12:11:29 PM
diff --git a/source/XSharp.Compiler/Program.cs b/source/XSharp.Compiler/Program.cs
index 999b111f9..aa0ce5eea 100644
--- a/source/XSharp.Compiler/Program.cs
+++ b/source/XSharp.Compiler/Program.cs
@@ -13,28 +13,27 @@ namespace XSharp.Compiler {
var xGenerator = new AsmGenerator();
- string[] xFiles;
- if (Directory.Exists(xSrc))
- {
- xFiles = Directory.GetFiles(xSrc, "*.xs");
- }
- else
- {
- xFiles = new string[] { xSrc };
- }
- foreach (var xFile in xFiles)
- {
- xGenerator.GenerateToFiles(xFile);
- }
-
- // var xAsm = new Assembler();
- // var xStreamReader = new StringReader(@"namespace Test
- // var CallerEBP
- // while ESI != .CallerEBP {
- // ! nop
+ //string[] xFiles;
+ //if (Directory.Exists(xSrc))
+ //{
+ // xFiles = Directory.GetFiles(xSrc, "*.xs");
//}
- // ");
- // var xResult = xGenerator.Generate(xStreamReader);
+ //else
+ //{
+ // xFiles = new string[] { xSrc };
+ //}
+ //foreach (var xFile in xFiles)
+ //{
+ // xGenerator.GenerateToFiles(xFile);
+ //}
+
+ var xAsm = new Assembler();
+ var xStreamReader = new StringReader(@"namespace Test
+ while byte ESI[0] != 0 {
+ ! nop
+ }
+ ");
+ var xResult = xGenerator.Generate(xStreamReader);
Console.WriteLine("done");
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
diff --git a/source/XSharp.Compiler/TokenPatterns.cs b/source/XSharp.Compiler/TokenPatterns.cs
index be94657ba..dbf37efd1 100644
--- a/source/XSharp.Compiler/TokenPatterns.cs
+++ b/source/XSharp.Compiler/TokenPatterns.cs
@@ -240,7 +240,7 @@ namespace XSharp.Compiler {
switch (value)
{
case "byte":
- return RegisterSize.Int32;
+ return RegisterSize.Byte8;
case "word":
return RegisterSize.Short16;
case "dword":
@@ -450,12 +450,6 @@ namespace XSharp.Compiler {
#region Handle all comparisons
foreach (var xSize in xSizes)
{
- RegisterSize? xTypedSize = null;
- if (xSize != "")
- {
- xTypedSize = GetSize(xSize);
- }
-
foreach (var xComparison in mCompareOps)
{
var xComparisonToken = new Token(-1);
@@ -467,8 +461,10 @@ namespace XSharp.Compiler {
(tokenOffset, tokenList) =>
{
var xOffset = tokenOffset;
+ RegisterSize? xTypedSize = null;
if (tokenList[xOffset].Type != TokenType.Register)
{
+ xTypedSize = GetSize(tokenList[xOffset]);
xOffset += 1;
}
XS.Compare(tokenList[xOffset + 0].Register, tokenList[xOffset + 2].IntValue, size: xTypedSize);
@@ -478,8 +474,10 @@ namespace XSharp.Compiler {
(tokenOffset, tokenList) =>
{
var xOffset = tokenOffset;
+ RegisterSize? xTypedSize = null;
if (tokenList[xOffset].Type != TokenType.Register)
{
+ xTypedSize = GetSize(tokenList[xOffset]);
xOffset += 1;
}
XS.Compare(tokenList[xOffset + 0].Register, tokenList[xOffset + 2].Register);
@@ -533,8 +531,10 @@ namespace XSharp.Compiler {
(tokenOffset, tokenList) =>
{
var xOffset = tokenOffset;
+ RegisterSize? xTypedSize = null;
if (tokenList[xOffset].Type != TokenType.Register)
{
+ xTypedSize = GetSize(tokenList[xOffset]);
xOffset += 1;
}
XS.Compare(tokenList[xOffset + 0].Register, tokenList[xOffset + 5].IntValue, destinationDisplacement: (int)tokenList[xOffset + 2].IntValue, size: xTypedSize);
@@ -544,8 +544,10 @@ namespace XSharp.Compiler {
(tokenOffset, tokenList) =>
{
var xOffset = tokenOffset;
+ RegisterSize? xTypedSize = null;
if (tokenList[xOffset].Type != TokenType.Register)
{
+ xTypedSize = GetSize(tokenList[xOffset]);
xOffset += 1;
}
XS.Compare(tokenList[xOffset + 0].Register, tokenList[xOffset + 2].IntValue, destinationDisplacement: -(int)tokenList[xOffset + 1].IntValue, size: xTypedSize);
@@ -577,8 +579,10 @@ namespace XSharp.Compiler {
(tokenOffset, tokenList) =>
{
var xOffset = tokenOffset;
+ RegisterSize? xTypedSize = null;
if (tokenList[xOffset].Type != TokenType.Register)
{
+ xTypedSize = GetSize(tokenList[xOffset]);
xOffset += 1;
}
XS.Compare(tokenList[xOffset + 0].Register, ConstLabel(tokenList[xOffset + 2]), destinationDisplacement: (int)tokenList[xOffset + 1].IntValue, sourceIsIndirect: true, size: xTypedSize);
@@ -588,8 +592,10 @@ namespace XSharp.Compiler {
(tokenOffset, tokenList) =>
{
var xOffset = tokenOffset;
+ RegisterSize? xTypedSize = null;
if (tokenList[xOffset].Type != TokenType.Register)
{
+ xTypedSize = GetSize(tokenList[xOffset]);
xOffset += 1;
}
XS.Compare(tokenList[xOffset + 0].Register, ConstLabel(tokenList[xOffset + 2]), destinationDisplacement: (int)tokenList[xOffset + 1].IntValue, size: xTypedSize);
@@ -599,8 +605,10 @@ namespace XSharp.Compiler {
(tokenOffset, tokenList) =>
{
var xOffset = tokenOffset;
- if (tokenList[xOffset + 2].Type != TokenType.Register)
+ RegisterSize? xTypedSize = null;
+ if (tokenList[xOffset].Type != TokenType.Register)
{
+ xTypedSize = GetSize(tokenList[xOffset]);
xOffset += 1;
}
XS.Compare(GetLabel(tokenList[xOffset + 0]), tokenList[xOffset + 2].IntValue, destinationIsIndirect: true, size: xTypedSize.GetValueOrDefault(RegisterSize.Int32));
@@ -621,8 +629,10 @@ namespace XSharp.Compiler {
(tokenOffset, tokenList) =>
{
var xOffset = tokenOffset;
- if (tokenList[xOffset + 2].Type != TokenType.Register)
+ RegisterSize? xTypedSize = null;
+ if (tokenList[xOffset].Type != TokenType.Register)
{
+ xTypedSize = GetSize(tokenList[xOffset]);
xOffset += 1;
}
XS.Compare(GetSimpleRef(tokenList[xOffset + 0]), ConstLabel(tokenList[xOffset + 3]), destinationIsIndirect: true, size: xTypedSize.GetValueOrDefault(RegisterSize.Int32));
diff --git a/source/XSharp.Compiler/XS.cs b/source/XSharp.Compiler/XS.cs
index 57904100a..8875baa70 100644
--- a/source/XSharp.Compiler/XS.cs
+++ b/source/XSharp.Compiler/XS.cs
@@ -379,7 +379,7 @@ namespace XSharp.Compiler
public static void DataMember(string name, string value)
{
- Assembler.CurrentInstance.DataMembers.Add(new DataMember(name, "`" + value + "`"));
+ Assembler.CurrentInstance.DataMembers.Add(new DataMember(name, value));
}
public static void DataMember(string name, uint elementCount, string size, string value)
diff --git a/source/XSharp.VS/XSharp.VS.csproj b/source/XSharp.VS/XSharp.VS.csproj
index aa84c2cf3..fe2df3080 100644
--- a/source/XSharp.VS/XSharp.VS.csproj
+++ b/source/XSharp.VS/XSharp.VS.csproj
@@ -108,6 +108,10 @@
+
+ {1116130E-28E0-428A-A597-F4B3B676C0CA}
+ Cosmos.Assembler
+
{A281A1B1-C718-4BCB-A7BE-ED840A70449A}
XSharp.Compiler
diff --git a/source/XSharp.VS/XsToAsmFileGenerator.cs b/source/XSharp.VS/XsToAsmFileGenerator.cs
index cfef02bdf..229aa6e46 100644
--- a/source/XSharp.VS/XsToAsmFileGenerator.cs
+++ b/source/XSharp.VS/XsToAsmFileGenerator.cs
@@ -6,6 +6,7 @@ using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio;
using System.Runtime.InteropServices;
using System.IO;
+using Cosmos.Assembler;
namespace XSharp.VS {
// This class generates .asm files from .xs files.
@@ -26,13 +27,22 @@ namespace XSharp.VS {
string xResult;
using (var xInput = new StringReader(aInputFileContents)) {
using (var xOut = new StringWriter()) {
- try {
- var xGen = new XSharp.Compiler.AsmGenerator();
- xGen.Generate(xInput, xOut);
- xResult =
- "; Generated at " + DateTime.Now.ToString() + "\r\n"
- + "\r\n"
- + xOut.ToString() + "\r\n";
+ try
+ {
+ new Assembler();
+ try
+ {
+ var xGen = new XSharp.Compiler.AsmGenerator();
+ xGen.Generate(xInput, xOut);
+ xResult =
+ "; Generated at " + DateTime.Now.ToString() + "\r\n"
+ + "\r\n"
+ + xOut.ToString() + "\r\n";
+ }
+ finally
+ {
+ Assembler.ClearCurrentInstance();
+ }
} catch (Exception ex) {
var xSB = new StringBuilder();
xSB.Append(xOut);