X# Size specifier for comparisons.

This commit is contained in:
kudzu_cp 2012-07-13 16:15:01 +00:00
parent 9a34e54d2f
commit 38912eaf6d
8 changed files with 85 additions and 67 deletions

View file

@ -51,6 +51,9 @@ namespace XSharp.Test {
}
private void MainForm_Load(object sender, EventArgs e) {
// For testing
//Test(Path.Combine(mPath, "CmdProcess.xs"));
var xFiles = Directory.GetFiles(mPath, "*.xs");
foreach (var xFile in xFiles) {
Test(xFile);

View file

@ -1,23 +1,8 @@
DebugStub_AckCommand:
DebugStub_ProcessCommand2:
Call DebugStub_ComReadAL
Push EAX
Mov AL, DebugStub_Const_Ds2Vs_CmdCompleted
Call DebugStub_ComWriteAL
Mov EAX, [DebugStub_CommandID]
Call DebugStub_ComWriteAL
DebugStub_AckCommand_Exit:
Ret
DebugStub_ProcessCommandBatch:
DebugStub_ProcessCommandBatch_Begin:
Call DebugStub_ProcessCommand
Cmp AL, 8
JNE DebugStub_ProcessCommandBatch_Begin
Call DebugStub_AckCommand
DebugStub_ProcessCommandBatch_Exit:
Ret
Line 14, Parsing error: if AL = #Vs2Ds_Noop exit

View file

@ -1,5 +1,41 @@
Group DebugStub
// Modifies: AL, DX (ComReadAL)
// Returns: AL
function ProcessCommand2 {
ComReadAL()
// Some callers expect AL to be returned, so we preserve it
// in case any commands modify AL.
// We push EAX to keep stack aligned.
+EAX
// Noop has no data at all (see notes in client DebugConnector), so skip Command ID
// Noop also does not send ACK.
if AL = #Vs2Ds_Noop return
// Read Command ID
ComReadAL()
.CommandID = EAX
// Get AL back so we can compare it, but also put it back for later
EAX = ESP[0]
//CheckCmd("TraceOff", Vs2Ds.TraceOff)
//CheckCmd("TraceOn", Vs2Ds.TraceOn)
//CheckCmd("Break", Vs2Ds.Break)
//CheckCmd("BreakOnAddress", Vs2Ds.BreakOnAddress)
//CheckCmd("SendMethodContext", Vs2Ds.SendMethodContext)
//CheckCmd("SendMemory", Vs2Ds.SendMemory)
//CheckCmd("SendRegisters", Vs2Ds.SendRegisters)
//CheckCmd("SendFrame", Vs2Ds.SendFrame)
//CheckCmd("SendStack", Vs2Ds.SendStack)
//CheckCmd("Ping", Vs2Ds.Ping)
Exit:
// Restore AL for callers who check the command and do
// further processing, or for commands not handled by this routine.
-EAX
}
function AckCommand {
// We acknowledge receipt of the command AND the processing of it.
// -In the past the ACK only acknowledged receipt.

View file

@ -111,7 +111,7 @@ Exit:
// Modifies: EAX, ESI
function SendTrace {
if .DebugStatus = #Status_Run goto Normal
if dword .DebugStatus = #Status_Run goto Normal
AL = #Ds2Vs_BreakPoint
goto Type

View file

@ -1,4 +1,5 @@
DebugWaitMsg db "Waiting for debugger connection..."
db 0
DebugStub_Const_VidBase equ 0xB8000
@ -7,7 +8,7 @@ DebugStub_Cls:
Mov ESI, DebugStub_Const_VidBase
DebugStub_Cls_Block1Begin:
Cmp dword ESI, 0xB8FA0
Cmp ESI, 0xB8FA0
JAE DebugStub_Cls_Block1End
Mov dword [ESI + 0], 0x00
Inc ESI
@ -25,15 +26,5 @@ Mov ESI, DebugWaitMsg
Mov EDI, DebugStub_Const_VidBase
Add EDI, 1640
DebugStub_DisplayWaitMsg_Block2Begin:
Cmp dword [ESI + 0], 0
JE DebugStub_DisplayWaitMsg_Block2End
Mov AL, [ESI + 0]
Mov [EDI + 0], AL
Inc ESI
Add EDI, 2
jmp DebugStub_DisplayWaitMsg_Block2Begin
DebugStub_DisplayWaitMsg_Block2End:
DebugStub_DisplayWaitMsg_Exit:
Ret
Line 30, Parsing error: while byte ESI[0] != 0 {

View file

@ -27,7 +27,7 @@ function DisplayWaitMsg {
EDI + 1640
// Read and copy string till 0 terminator
while ESI[0] != 0 {
while byte ESI[0] != 0 {
AL = ESI[0]
EDI[0] = AL
ESI++

View file

@ -23,13 +23,12 @@ namespace Cosmos.Compiler.XSharp {
+ ",BYTE"
+ ",CALL,CONST"
+ ",DWORD"
+ ",end,exit"
+ ",function"
+ ",GOTO,GROUP"
+ ",IF,INTERRUPT"
+ ",JUMP"
+ ",PORT"
+ ",RETURN,RETURNINTERRUPT,REPEAT"
+ ",return,RETURNINTERRUPT,REPEAT"
+ ",times"
+ ",var"
+ ",word,while"

View file

@ -36,25 +36,29 @@ namespace Cosmos.Compiler.XSharp {
public TokenPatterns() {
mCompareOps = "< > = != <= >= 0".Split(" ".ToCharArray());
foreach (var xComparison in mCompareOps) {
if (xComparison != "0") {
mCompares.Add("_REG " + xComparison + " 123");
mCompares.Add("_REG " + xComparison + " _REG");
mCompares.Add("_REG " + xComparison + " _REGADDR[1]");
mCompares.Add("_REG " + xComparison + " _REGADDR[-1]");
mCompares.Add("_REG " + xComparison + " _ABC");
mCompares.Add("_REG " + xComparison + " #_ABC");
//
mCompares.Add("_REGADDR[1] " + xComparison + " 123");
mCompares.Add("_REGADDR[-1] " + xComparison + " 123");
mCompares.Add("_REGADDR[1] " + xComparison + " _REG");
mCompares.Add("_REGADDR[-1] " + xComparison + " _REG");
mCompares.Add("_REGADDR[1] " + xComparison + " #_ABC");
mCompares.Add("_REGADDR[-1] " + xComparison + " #_ABC");
//
mCompares.Add("_ABC " + xComparison + " 123");
mCompares.Add("_ABC " + xComparison + " _REG");
mCompares.Add("_ABC " + xComparison + " #_ABC");
var xSizes = "byte , word , dword ".Split(",".ToCharArray()).ToList();
xSizes.Add("");
foreach (var xSize in xSizes) {
foreach (var xComparison in mCompareOps) {
if (xComparison != "0") {
mCompares.Add(xSize + "_REG " + xComparison + " 123");
mCompares.Add(xSize + "_REG " + xComparison + " _REG");
mCompares.Add(xSize + "_REG " + xComparison + " _REGADDR[1]");
mCompares.Add(xSize + "_REG " + xComparison + " _REGADDR[-1]");
mCompares.Add(xSize + "_REG " + xComparison + " _ABC");
mCompares.Add(xSize + "_REG " + xComparison + " #_ABC");
//
mCompares.Add(xSize + "_REGADDR[1] " + xComparison + " 123");
mCompares.Add(xSize + "_REGADDR[-1] " + xComparison + " 123");
mCompares.Add(xSize + "_REGADDR[1] " + xComparison + " _REG");
mCompares.Add(xSize + "_REGADDR[-1] " + xComparison + " _REG");
mCompares.Add(xSize + "_REGADDR[1] " + xComparison + " #_ABC");
mCompares.Add(xSize + "_REGADDR[-1] " + xComparison + " #_ABC");
//
mCompares.Add(xSize + "_ABC " + xComparison + " 123");
mCompares.Add(xSize + "_ABC " + xComparison + " _REG");
mCompares.Add(xSize + "_ABC " + xComparison + " #_ABC");
}
}
}
@ -86,7 +90,7 @@ namespace Cosmos.Compiler.XSharp {
return FuncLabel("Block" + mBlockLabel + aLabel);
}
protected string GetLabel(Token aToken) {
if (aToken.Type != TokenType.AlphaNum && !aToken.Matches("Exit")) {
if (aToken.Type != TokenType.AlphaNum) {
throw new Exception("Label must be AlphaNum.");
}
@ -159,8 +163,7 @@ namespace Cosmos.Compiler.XSharp {
return xResult;
}
protected string GetRef(TokenList aTokens, ref int rIdx, out bool oSizeIsKnown) {
oSizeIsKnown = false;
protected string GetRef(TokenList aTokens, ref int rIdx) {
var xToken1 = aTokens[rIdx];
Token xToken2 = null;
if (rIdx + 1 < aTokens.Count) {
@ -175,7 +178,6 @@ namespace Cosmos.Compiler.XSharp {
rIdx += 4;
return "[" + xToken1 + " + " + aTokens[rIdx - 2] + "]";
}
oSizeIsKnown = true;
rIdx += 1;
return xToken1.ToString();
@ -197,18 +199,20 @@ namespace Cosmos.Compiler.XSharp {
}
protected string GetCompare(TokenList aTokens, ref int rStart, out Token aComparison) {
bool xLeftSizeKnown;
string xLeft = GetRef(aTokens, ref rStart, out xLeftSizeKnown);
string xSize = "";
if (aTokens[rStart].Type == TokenType.Keyword) {
xSize = aTokens[rStart] + " ";
rStart++;
}
string xLeft = GetRef(aTokens, ref rStart);
aComparison = aTokens[rStart];
rStart++;
bool xRightSizeKnown;
string xRight = GetRef(aTokens, ref rStart, out xRightSizeKnown);
return "Cmp "
+ (xLeftSizeKnown || xRightSizeKnown ? "" : "dword ")
+ xLeft + ", " + xRight;
string xRight = GetRef(aTokens, ref rStart);
return "Cmp " + xSize + xLeft + ", " + xRight;
}
protected string GetJump(Token aToken) {
@ -306,7 +310,7 @@ namespace Cosmos.Compiler.XSharp {
});
AddPattern("var _ABC = 'Text'", delegate(TokenList aTokens, Assembler aAsm) {
// , 0 adds null term to our strings.
aAsm.Data.Add(GetLabel(aTokens[1]) + " db \"" + aTokens[3].Value + "\", 0");
aAsm.Data.Add(GetLabel(aTokens[1]) + " db \"" + aTokens[3].Value + "\"");
});
AddPattern(new string[] {
"var _ABC byte[123]",