mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-21 13:28:41 +00:00
.
This commit is contained in:
parent
91d891244c
commit
8a2d8a1403
17 changed files with 98 additions and 59 deletions
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
DebugStub_AsmBreakEIP dd 0
|
||||
DebugStub_AsmOrigByte dd 0
|
||||
|
|
@ -45,8 +45,8 @@ Ret
|
|||
|
||||
|
||||
DebugStub_SetINT1_TrapFLAG:
|
||||
Push EBP
|
||||
Push EAX
|
||||
push dword EBP
|
||||
push dword EAX
|
||||
Mov EBP, [DebugStub_CallerESP]
|
||||
Sub EBP, 4
|
||||
Mov EAX, [EBP]
|
||||
|
|
@ -61,8 +61,8 @@ Ret
|
|||
|
||||
|
||||
DebugStub_ResetINT1_TrapFLAG:
|
||||
Push EBP
|
||||
Push EAX
|
||||
push dword EBP
|
||||
push dword EAX
|
||||
Mov EBP, [DebugStub_CallerESP]
|
||||
Sub EBP, 4
|
||||
Mov EAX, [EBP]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
|
||||
|
||||
DebugStub_ProcessCommand:
|
||||
Call DebugStub_ComReadAL
|
||||
Push EAX
|
||||
push dword EAX
|
||||
Cmp AL, DebugStub_Const_Vs2Ds_Noop
|
||||
JE near DebugStub_ProcessCommand_Exit
|
||||
mov dword EAX, 0x0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_SendText:
|
||||
Push EBP
|
||||
push dword EBP
|
||||
Mov EBP, ESP
|
||||
Pushad
|
||||
Mov AL, DebugStub_Const_Ds2Vs_Message
|
||||
|
|
@ -177,7 +177,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_SendSimpleNumber:
|
||||
Push EBP
|
||||
push dword EBP
|
||||
Mov EBP, ESP
|
||||
Pushad
|
||||
Mov AL, DebugStub_Const_Ds2Vs_SimpleNumber
|
||||
|
|
@ -193,7 +193,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_SendSimpleLongNumber:
|
||||
Push EBP
|
||||
push dword EBP
|
||||
Mov EBP, ESP
|
||||
Pushad
|
||||
Mov AL, DebugStub_Const_Ds2Vs_SimpleLongNumber
|
||||
|
|
@ -211,7 +211,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_SendComplexNumber:
|
||||
Push EBP
|
||||
push dword EBP
|
||||
Mov EBP, ESP
|
||||
Pushad
|
||||
Mov AL, DebugStub_Const_Ds2Vs_ComplexNumber
|
||||
|
|
@ -227,7 +227,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_SendComplexLongNumber:
|
||||
Push EBP
|
||||
push dword EBP
|
||||
Mov EBP, ESP
|
||||
Pushad
|
||||
Mov AL, DebugStub_Const_Ds2Vs_ComplexLongNumber
|
||||
|
|
@ -278,7 +278,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_SendInterruptOccurred:
|
||||
Push EAX
|
||||
push dword EAX
|
||||
Mov AL, DebugStub_Const_Ds2Vs_InterruptOccurred
|
||||
Call DebugStub_ComWriteAL
|
||||
Pop EAX
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
|
||||
DebugStub_Const_Signature equ 427034631
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
DebugStub_CallerEBP dd 0
|
||||
DebugStub_CallerEIP dd 0
|
||||
|
|
@ -17,7 +17,7 @@ Call DebugStub_ComReadEAX
|
|||
Mov ECX, EAX
|
||||
mov dword EAX, 0x0
|
||||
Call DebugStub_ComReadAL
|
||||
Push EAX
|
||||
push dword EAX
|
||||
Mov EBX, DebugStub_DebugBPs
|
||||
shl dword EAX, 0x2
|
||||
Add EBX, EAX
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
DebugStub_MaxBPId dd 0
|
||||
|
||||
|
|
@ -41,7 +41,6 @@ mov byte AL, 0x0
|
|||
Call DebugStub_ComWriteAL
|
||||
mov byte AL, 0x0
|
||||
Call DebugStub_ComWriteAL
|
||||
Push dword DebugStub_Const_Signature
|
||||
Mov ESI, ESP
|
||||
Call DebugStub_ComWrite32
|
||||
Pop EAX
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
|
||||
%ifndef Exclude_IOPort_Based_SerialInit
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
|
||||
|
||||
|
|
@ -48,8 +48,8 @@ Ret
|
|||
|
||||
|
||||
DebugStub_ComWriteAL:
|
||||
Push ESI
|
||||
Push EAX
|
||||
push dword ESI
|
||||
push dword EAX
|
||||
Mov ESI, ESP
|
||||
Call DebugStub_ComWrite8
|
||||
Pop EAX
|
||||
|
|
@ -61,7 +61,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_ComWriteAX:
|
||||
Push EAX
|
||||
push dword EAX
|
||||
Mov ESI, ESP
|
||||
Call DebugStub_ComWrite16
|
||||
Pop EAX
|
||||
|
|
@ -72,7 +72,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_ComWriteEAX:
|
||||
Push EAX
|
||||
push dword EAX
|
||||
Mov ESI, ESP
|
||||
Call DebugStub_ComWrite32
|
||||
Pop EAX
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
DebugStub_ComAddr dd 1016
|
||||
|
||||
%ifndef Exclude_IOPort_Based_Serial
|
||||
|
||||
DebugStub_WriteRegister:
|
||||
Push EDX
|
||||
push dword EDX
|
||||
Add DX, 0x03F8
|
||||
out DX, AL
|
||||
Pop EDX
|
||||
|
|
@ -16,7 +16,7 @@ Ret
|
|||
|
||||
|
||||
DebugStub_ReadRegister:
|
||||
Push EDX
|
||||
push dword EDX
|
||||
Add DX, 0x03F8
|
||||
in byte AL, DX
|
||||
Pop EDX
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; Generated at 6/12/2016 9:24:33 AM
|
||||
; Generated at 6/12/2016 9:42:10 AM
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -140,8 +140,6 @@ namespace XSharp.Compiler {
|
|||
/// <returns>The resulting target assembler content. The returned object contains
|
||||
/// a code and a data block.</returns>
|
||||
protected void ProcessLine(string aLine, int lineNumber) {
|
||||
Assembler xAsm;
|
||||
|
||||
aLine = aLine.Trim();
|
||||
if (String.IsNullOrEmpty(aLine) || aLine == "//") {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -233,6 +233,20 @@ namespace XSharp.Compiler {
|
|||
return GetRef(xList, ref xIdx, true);
|
||||
}
|
||||
|
||||
private RegisterSize GetSize(Token aToken)
|
||||
{
|
||||
switch (aToken.RawValue)
|
||||
{
|
||||
case "byte":
|
||||
return RegisterSize.Int32;
|
||||
case "word":
|
||||
return RegisterSize.Short16;
|
||||
case "dword":
|
||||
return RegisterSize.Int32;
|
||||
default:
|
||||
throw new Exception($"Invalid size '{aToken.RawValue}'");
|
||||
}
|
||||
}
|
||||
protected string GetRef(List<Token> aTokens, ref int rIdx, bool onlySingleTokenRefs = false) {
|
||||
var xToken1 = aTokens[rIdx];
|
||||
Token xToken2 = null;
|
||||
|
|
@ -486,7 +500,8 @@ namespace XSharp.Compiler {
|
|||
idx = 0;
|
||||
val = GetRef(xParser.Tokens, ref idx);
|
||||
if (val != "@ret_on_stack@") {
|
||||
XS.PushLiteral(val);
|
||||
//XS.PushLiteral(val);
|
||||
throw new Exception();
|
||||
} else {
|
||||
//aAsm += GetPatternCode(xParser.Tokens).GetCode(false);
|
||||
throw new NotImplementedException("Didn't get converted yet!");
|
||||
|
|
@ -704,17 +719,18 @@ namespace XSharp.Compiler {
|
|||
});
|
||||
|
||||
AddPattern("+123", delegate(TokenList aTokens) {
|
||||
XS.PushLiteral(GetSimpleRef(aTokens[0]));
|
||||
XS.Push(aTokens[0].IntValue, RegisterSize.Int32);
|
||||
});
|
||||
AddPattern(new string[] {
|
||||
"+123 as byte",
|
||||
"+123 as word",
|
||||
"+123 as dword"
|
||||
}, delegate(TokenList aTokens) {
|
||||
XS.PushLiteral(GetSimpleRef(aTokens[3]) + " " + GetSimpleRef(aTokens[1]));
|
||||
var xSize = GetSize(aTokens[1]);
|
||||
XS.Push(aTokens[1].IntValue, xSize);
|
||||
});
|
||||
AddPattern("+_REG", delegate(TokenList aTokens) {
|
||||
XS.PushLiteral(GetSimpleRef(aTokens[1]));
|
||||
XS.Push(aTokens[1].Register);
|
||||
});
|
||||
AddPattern(new string[] {
|
||||
//0 1 2 3
|
||||
|
|
@ -723,11 +739,11 @@ namespace XSharp.Compiler {
|
|||
"+#_ABC as word",
|
||||
"+#_ABC as dword"
|
||||
}, delegate(TokenList aTokens) {
|
||||
string xSize = "dword ";
|
||||
RegisterSize xSize = RegisterSize.Int32;
|
||||
if (aTokens.Count > 2) {
|
||||
xSize = aTokens[3].RawValue + " ";
|
||||
xSize = GetSize(aTokens[3]);
|
||||
}
|
||||
XS.PushLiteral(xSize + ConstLabel(aTokens[1]));
|
||||
XS.Push(ConstLabel(aTokens[1]), size: xSize);
|
||||
});
|
||||
AddPattern("+All", delegate(TokenList aTokens) {
|
||||
XS.PushAllGeneralRegisters();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Cosmos.Assembler;
|
||||
using System;
|
||||
using Cosmos.Assembler;
|
||||
using static XSharp.Compiler.XSRegisters;
|
||||
|
||||
namespace XSharp.Compiler
|
||||
|
|
@ -10,7 +11,6 @@ namespace XSharp.Compiler
|
|||
new LiteralAssemblerCode(code);
|
||||
}
|
||||
|
||||
|
||||
public static void AddLiteral(string left, string right)
|
||||
{
|
||||
LiteralCode("Add " + left + ", " + right);
|
||||
|
|
@ -46,40 +46,35 @@ namespace XSharp.Compiler
|
|||
LiteralCode("xor " + left + ", " + right);
|
||||
}
|
||||
|
||||
public static void PushLiteral(string value)
|
||||
{
|
||||
new LiteralAssemblerCode("Push " + value);
|
||||
}
|
||||
|
||||
public static void PopLiteral(string value)
|
||||
{
|
||||
new LiteralAssemblerCode("Pop " + value);
|
||||
LiteralCode("Pop " + value);
|
||||
}
|
||||
|
||||
public static void IntegerMultiplyLiteral(string left, string right)
|
||||
{
|
||||
new LiteralAssemblerCode("imul " + left + ", " + right);
|
||||
LiteralCode("imul " + left + ", " + right);
|
||||
}
|
||||
|
||||
public static void SetLiteral(string destination, string source)
|
||||
{
|
||||
new LiteralAssemblerCode("Mov " + destination + ", " + source);
|
||||
LiteralCode("Mov " + destination + ", " + source);
|
||||
}
|
||||
|
||||
public static void SetLiteral(string size, string destination, string source)
|
||||
{
|
||||
new LiteralAssemblerCode("Mov " + size + " " + destination + ", " + source);
|
||||
LiteralCode("Mov " + size + " " + destination + ", " + source);
|
||||
}
|
||||
|
||||
public static void CompareLiteral(string size, string destination, string source)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(size))
|
||||
{
|
||||
new LiteralAssemblerCode($"Cmp {destination}, {source}");
|
||||
LiteralCode($"Cmp {destination}, {source}");
|
||||
}
|
||||
else
|
||||
{
|
||||
new LiteralAssemblerCode($"Cmp {size} {destination}, {source}");
|
||||
LiteralCode($"Cmp {size} {destination}, {source}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,15 +82,12 @@ namespace XSharp.Compiler
|
|||
{
|
||||
if (string.IsNullOrWhiteSpace(size))
|
||||
{
|
||||
new LiteralAssemblerCode($"Test {destination}, {source}");
|
||||
LiteralCode($"Test {destination}, {source}");
|
||||
}
|
||||
else
|
||||
{
|
||||
new LiteralAssemblerCode($"Test {size} {destination}, {source}");
|
||||
LiteralCode($"Test {size} {destination}, {source}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,6 +149,40 @@ namespace XSharp.Compiler
|
|||
};
|
||||
}
|
||||
|
||||
public static void Push(Register value)
|
||||
{
|
||||
new Push
|
||||
{
|
||||
DestinationReg = value.RegEnum
|
||||
};
|
||||
}
|
||||
|
||||
public static void Push(uint value, RegisterSize size)
|
||||
{
|
||||
new Push
|
||||
{
|
||||
DestinationValue = value,
|
||||
Size = (byte)size
|
||||
};
|
||||
}
|
||||
|
||||
public static void Push(string label, bool isIndirect = false, RegisterSize size = RegisterSize.Int32)
|
||||
{
|
||||
new Push
|
||||
{
|
||||
DestinationRef = ElementReference.New(label),
|
||||
DestinationIsIndirect = isIndirect,
|
||||
Size = (byte)size
|
||||
};
|
||||
}
|
||||
|
||||
public static void Pop(Register value)
|
||||
{
|
||||
new Pop
|
||||
{
|
||||
DestinationReg = value.RegEnum
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue