Ein paar Änderungen am Disammbler (Anzeige
This commit is contained in:
@ -41,8 +41,16 @@ class Program {
|
||||
|
||||
ushort nVars = r.ReadUInt16();
|
||||
Console.WriteLine($"Vars: {nVars}");
|
||||
var varTypes = new byte[nVars];
|
||||
for (int i = 0; i < nVars; i++) { varTypes[i] = r.ReadByte(); Console.WriteLine($" Var[{i}] type = {varTypes[i]}"); }
|
||||
var varTypes = new VarType[nVars];
|
||||
for (int i = 0; i < nVars; i++) {
|
||||
byte tb = r.ReadByte();
|
||||
var vt = (VarType)tb;
|
||||
varTypes[i] = vt;
|
||||
if (Enum.IsDefined(typeof(VarType), vt))
|
||||
Console.WriteLine($" Var[{i}] type = {vt}");
|
||||
else
|
||||
Console.WriteLine($" Var[{i}] type = {tb} (unknown)");
|
||||
}
|
||||
|
||||
ushort codeLen = r.ReadUInt16();
|
||||
Console.WriteLine($"CodeLen: {codeLen} bytes");
|
||||
@ -53,15 +61,15 @@ class Program {
|
||||
while (ip < code.Length) {
|
||||
int addr = ip;
|
||||
byte op = code[ip++];
|
||||
Console.Write($"{addr:0000}: 0x{op:X2} {Bytecode.OpName(op)} ");
|
||||
Console.Write($"{addr:0000}: 0x{op:X2} ");
|
||||
switch (op) {
|
||||
case Bytecode.OpCodes.NOP: Console.WriteLine("NOP"); break;
|
||||
case Bytecode.OpCodes.PUSH_CONST: { ushort ci = ReadU16(code, ref ip); Console.WriteLine($"PUSH_CONST {ci} ({consts[ci]})"); break; }
|
||||
case Bytecode.OpCodes.PUSH_REAL_CONST: { ushort ci = ReadU16(code, ref ip); Console.WriteLine($"PUSH_REAL_CONST {ci} ({consts[ci]})"); break; }
|
||||
case Bytecode.OpCodes.LOAD_VAR: { ushort vi = ReadU16(code, ref ip); Console.WriteLine($"LOAD_VAR {vi}"); break; }
|
||||
case Bytecode.OpCodes.STORE_VAR: { ushort vi = ReadU16(code, ref ip); Console.WriteLine($"STORE_VAR {vi}"); break; }
|
||||
case Bytecode.OpCodes.JZ: { ushort target = ReadU16(code, ref ip); Console.WriteLine($"JZ addr={target}"); break; }
|
||||
case Bytecode.OpCodes.JMP: { ushort target = ReadU16(code, ref ip); Console.WriteLine($"JMP addr={target}"); break; }
|
||||
case Bytecode.OpCodes.JZ: { ushort target = ReadU16(code, ref ip); Console.WriteLine($"JZ addr={target:0000}"); break; }
|
||||
case Bytecode.OpCodes.JMP: { ushort target = ReadU16(code, ref ip); Console.WriteLine($"JMP addr={target:0000}"); break; }
|
||||
case Bytecode.OpCodes.HALT: Console.WriteLine("HALT"); break;
|
||||
default: Console.WriteLine($"{Bytecode.OpName(op)}"); break;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("STCompiler.Disassembler")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bdee19419dc879274e82afdd621b54e1923e0940")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d6c0c1ee3d20a8c9c034ddc1705666c59490293b")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("STCompiler.Disassembler")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("STCompiler.Disassembler")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@ -1 +1 @@
|
||||
e512ea89251f2295a76007dc4f99ce92f19bc2813739fd32e9bf7233cc288310
|
||||
464c162666b4bc2ea38f251b8581cce943c86b051338cfd40945bd712973ca04
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user