Skip to content

Commit

Permalink
Merge branch 'main' into 4.0.0-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TollyH committed May 28, 2024
2 parents 2fcb812 + 28c1987 commit 855308e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 42 deletions.
24 changes: 12 additions & 12 deletions AssemblerWarnings.Groups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ public partial class AssemblerWarnings
{ new Opcode(0x06, 0x72), new[] { 1 } }, // FSYS_GMT reg, adr
{ new Opcode(0x06, 0x74), new[] { 1 } }, // FSYS_GAT reg, adr
{ new Opcode(0x06, 0x80), new[] { 0 } }, // FSYS_SCT adr, reg
{ new Opcode(0x06, 0x82), new[] { 0 } }, // FSYS_SCT adr, lit
{ new Opcode(0x06, 0x81), new[] { 0 } }, // FSYS_SCT adr, lit
{ new Opcode(0x06, 0x84), new[] { 0 } }, // FSYS_SMT adr, reg
{ new Opcode(0x06, 0x86), new[] { 0 } }, // FSYS_SMT adr, lit
{ new Opcode(0x06, 0x85), new[] { 0 } }, // FSYS_SMT adr, lit
{ new Opcode(0x06, 0x88), new[] { 0 } }, // FSYS_SAT adr, reg
{ new Opcode(0x06, 0x8A), new[] { 0 } }, // FSYS_SAT adr, lit
{ new Opcode(0x06, 0x89), new[] { 0 } }, // FSYS_SAT adr, lit

{ new Opcode(0x07, 0x22), new[] { 0 } }, // TERM_SCY adr
{ new Opcode(0x07, 0x26), new[] { 0 } }, // TERM_SCX adr
Expand Down Expand Up @@ -452,11 +452,11 @@ public partial class AssemblerWarnings
{ new Opcode(0x06, 0x71), new[] { 1 } },
{ new Opcode(0x06, 0x73), new[] { 1 } },
{ new Opcode(0x06, 0x75), new[] { 1 } },
{ new Opcode(0x06, 0x81), new[] { 0 } },
{ new Opcode(0x06, 0x82), new[] { 0 } },
{ new Opcode(0x06, 0x83), new[] { 0 } },
{ new Opcode(0x06, 0x85), new[] { 0 } },
{ new Opcode(0x06, 0x86), new[] { 0 } },
{ new Opcode(0x06, 0x87), new[] { 0 } },
{ new Opcode(0x06, 0x89), new[] { 0 } },
{ new Opcode(0x06, 0x8A), new[] { 0 } },
{ new Opcode(0x06, 0x8B), new[] { 0 } },

{ new Opcode(0x00, 0x86), new[] { 0 } },
Expand Down Expand Up @@ -741,11 +741,11 @@ public partial class AssemblerWarnings

new Opcode(0x04, 0x32), // ASMX_CAL lit

new Opcode(0x06, 0x82), // FSYS_SCT adr, lit
new Opcode(0x06, 0x81), // FSYS_SCT adr, lit
new Opcode(0x06, 0x83), // FSYS_SCT ptr, lit
new Opcode(0x06, 0x86), // FSYS_SMT adr, lit
new Opcode(0x06, 0x85), // FSYS_SMT adr, lit
new Opcode(0x06, 0x87), // FSYS_SMT ptr, lit
new Opcode(0x06, 0x8A), // FSYS_SAT adr, lit
new Opcode(0x06, 0x89), // FSYS_SAT adr, lit
new Opcode(0x06, 0x8B), // FSYS_SAT ptr, lit
};
/// <summary>
Expand All @@ -764,11 +764,11 @@ public partial class AssemblerWarnings
new Opcode(0x01, 0x61), // SIGN_WFN lit
new Opcode(0x01, 0x65), // SIGN_WFB lit

new Opcode(0x06, 0x82), // FSYS_SCT adr, lit
new Opcode(0x06, 0x81), // FSYS_SCT adr, lit
new Opcode(0x06, 0x83), // FSYS_SCT ptr, lit
new Opcode(0x06, 0x86), // FSYS_SMT adr, lit
new Opcode(0x06, 0x85), // FSYS_SMT adr, lit
new Opcode(0x06, 0x87), // FSYS_SMT ptr, lit
new Opcode(0x06, 0x8A), // FSYS_SAT adr, lit
new Opcode(0x06, 0x89), // FSYS_SAT adr, lit
new Opcode(0x06, 0x8B), // FSYS_SAT ptr, lit
};
/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -791,20 +791,20 @@ public static class Data

// FSYS_SCT (Set Creation Time of File or Directory)
{ ("FSYS_SCT", new OperandType[2] { OperandType.Address, OperandType.Register }), new Opcode(0x06, 0x80) },
{ ("FSYS_SCT", new OperandType[2] { OperandType.Pointer, OperandType.Register }), new Opcode(0x06, 0x81) },
{ ("FSYS_SCT", new OperandType[2] { OperandType.Address, OperandType.Literal }), new Opcode(0x06, 0x82) },
{ ("FSYS_SCT", new OperandType[2] { OperandType.Address, OperandType.Literal }), new Opcode(0x06, 0x81) },
{ ("FSYS_SCT", new OperandType[2] { OperandType.Pointer, OperandType.Register }), new Opcode(0x06, 0x82) },
{ ("FSYS_SCT", new OperandType[2] { OperandType.Pointer, OperandType.Literal }), new Opcode(0x06, 0x83) },

// FSYS_SMT (Set Modification Time of File or Directory)
{ ("FSYS_SMT", new OperandType[2] { OperandType.Address, OperandType.Register }), new Opcode(0x06, 0x84) },
{ ("FSYS_SMT", new OperandType[2] { OperandType.Pointer, OperandType.Register }), new Opcode(0x06, 0x85) },
{ ("FSYS_SMT", new OperandType[2] { OperandType.Address, OperandType.Literal }), new Opcode(0x06, 0x86) },
{ ("FSYS_SMT", new OperandType[2] { OperandType.Address, OperandType.Literal }), new Opcode(0x06, 0x85) },
{ ("FSYS_SMT", new OperandType[2] { OperandType.Pointer, OperandType.Register }), new Opcode(0x06, 0x86) },
{ ("FSYS_SMT", new OperandType[2] { OperandType.Pointer, OperandType.Literal }), new Opcode(0x06, 0x87) },

// FSYS_SAT (Set Access Time of File or Directory)
{ ("FSYS_SAT", new OperandType[2] { OperandType.Address, OperandType.Register }), new Opcode(0x06, 0x88) },
{ ("FSYS_SAT", new OperandType[2] { OperandType.Pointer, OperandType.Register }), new Opcode(0x06, 0x89) },
{ ("FSYS_SAT", new OperandType[2] { OperandType.Address, OperandType.Literal }), new Opcode(0x06, 0x8A) },
{ ("FSYS_SAT", new OperandType[2] { OperandType.Address, OperandType.Literal }), new Opcode(0x06, 0x89) },
{ ("FSYS_SAT", new OperandType[2] { OperandType.Pointer, OperandType.Register }), new Opcode(0x06, 0x8A) },
{ ("FSYS_SAT", new OperandType[2] { OperandType.Pointer, OperandType.Literal }), new Opcode(0x06, 0x8B) },
#endif

Expand Down
5 changes: 5 additions & 0 deletions Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,11 @@ private bool ProcessReplInput(string userInput)
{
throw new LabelNameException(string.Format(Strings_Debugger.REPL_Error_Label_Not_Exists, labelName));
}
#if DISPLACEMENT
// Any displacement has already been written to the program,
// read it back and add it to the resolved label address
address += BinaryPrimitives.ReadUInt64LittleEndian(new ReadOnlySpan<byte>(newBytes)[(int)addressOffset..]);
#endif
BinaryPrimitives.WriteUInt64LittleEndian(newBytes.AsSpan()[(int)addressOffset..], address);
}

Expand Down
36 changes: 18 additions & 18 deletions Processor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3785,16 +3785,16 @@ is not (ulong)StatusFlags.Sign and not (ulong)StatusFlags.Overflow)
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + 8)));
Registers[(int)Register.rpo] += 9;
break;
case 0x1: // FSYS_SCT ptr, reg
File.SetCreationTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + byteCount)));
Registers[(int)Register.rpo] += byteCount + 1;
break;
case 0x2: // FSYS_SCT adr, lit
case 0x1: // FSYS_SCT adr, lit
File.SetCreationTimeUtc(ReadMemoryPointedString(operandStart),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryQWord(operandStart + 8)));
Registers[(int)Register.rpo] += 16;
break;
case 0x2: // FSYS_SCT ptr, reg
File.SetCreationTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + byteCount)));
Registers[(int)Register.rpo] += byteCount + 1;
break;
case 0x3: // FSYS_SCT ptr, lit
File.SetCreationTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryQWord(operandStart + byteCount)));
Expand All @@ -3805,16 +3805,16 @@ is not (ulong)StatusFlags.Sign and not (ulong)StatusFlags.Overflow)
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + 8)));
Registers[(int)Register.rpo] += 9;
break;
case 0x5: // FSYS_SMT ptr, reg
File.SetLastWriteTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + byteCount)));
Registers[(int)Register.rpo] += byteCount + 1;
break;
case 0x6: // FSYS_SMT adr, lit
case 0x5: // FSYS_SMT adr, lit
File.SetLastWriteTimeUtc(ReadMemoryPointedString(operandStart),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryQWord(operandStart + 8)));
Registers[(int)Register.rpo] += 16;
break;
case 0x6: // FSYS_SMT ptr, reg
File.SetLastWriteTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + byteCount)));
Registers[(int)Register.rpo] += byteCount + 1;
break;
case 0x7: // FSYS_SMT ptr, lit
File.SetLastWriteTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryQWord(operandStart + byteCount)));
Expand All @@ -3825,16 +3825,16 @@ is not (ulong)StatusFlags.Sign and not (ulong)StatusFlags.Overflow)
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + 8)));
Registers[(int)Register.rpo] += 9;
break;
case 0x9: // FSYS_SAT ptr, reg
File.SetLastAccessTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + byteCount)));
Registers[(int)Register.rpo] += byteCount + 1;
break;
case 0xA: // FSYS_SAT adr, lit
case 0x9: // FSYS_SAT adr, lit
File.SetLastAccessTimeUtc(ReadMemoryPointedString(operandStart),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryQWord(operandStart + 8)));
Registers[(int)Register.rpo] += 16;
break;
case 0xA: // FSYS_SAT ptr, reg
File.SetLastAccessTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryRegister(operandStart + byteCount)));
Registers[(int)Register.rpo] += byteCount + 1;
break;
case 0xB: // FSYS_SAT ptr, lit
File.SetLastAccessTimeUtc(ReadMemoryRegisterPointedString(operandStart, out byteCount),
DateTime.UnixEpoch.AddSeconds((long)ReadMemoryQWord(operandStart + byteCount)));
Expand Down
12 changes: 6 additions & 6 deletions Test/ProcessorTests/FullOpcodeTest.FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ public void FSYS_SCT_Pointer_Register()
Processor testProcessor = new(2046);
testProcessor.Registers[(int)Register.rg7] = (ulong)randomTimestamp;
testProcessor.Registers[(int)Register.rg8] = 0x140;
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x81, (int)Register.rg8, (int)Register.rg7 });
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x82, (int)Register.rg8, (int)Register.rg7 });
testProcessor.WriteMemoryString(0x140, "copyfile");
_ = testProcessor.Execute(false);
Assert.AreEqual(randomTimestamp, (int)(File.GetCreationTimeUtc("copyfile") - DateTime.UnixEpoch).TotalSeconds, "Instruction did not produce correct result");
Expand All @@ -982,7 +982,7 @@ public void FSYS_SCT_Address_Literal()
int randomTimestamp = rng.Next(int.MinValue, int.MaxValue);

Processor testProcessor = new(2046);
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x82, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x81, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
testProcessor.WriteMemoryQWord(11, (ulong)randomTimestamp);
testProcessor.WriteMemoryString(0x140, "copyfile");
_ = testProcessor.Execute(false);
Expand Down Expand Up @@ -1035,7 +1035,7 @@ public void FSYS_SMT_Pointer_Register()
Processor testProcessor = new(2046);
testProcessor.Registers[(int)Register.rg7] = (ulong)randomTimestamp;
testProcessor.Registers[(int)Register.rg8] = 0x140;
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x85, (int)Register.rg8, (int)Register.rg7 });
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x86, (int)Register.rg8, (int)Register.rg7 });
testProcessor.WriteMemoryString(0x140, "copyfile");
_ = testProcessor.Execute(false);
Assert.AreEqual(randomTimestamp, (int)(File.GetLastWriteTimeUtc("copyfile") - DateTime.UnixEpoch).TotalSeconds, "Instruction did not produce correct result");
Expand All @@ -1049,7 +1049,7 @@ public void FSYS_SMT_Address_Literal()
int randomTimestamp = rng.Next(int.MinValue, int.MaxValue);

Processor testProcessor = new(2046);
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x86, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x85, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
testProcessor.WriteMemoryQWord(11, (ulong)randomTimestamp);
testProcessor.WriteMemoryString(0x140, "copyfile");
_ = testProcessor.Execute(false);
Expand Down Expand Up @@ -1097,7 +1097,7 @@ public void FSYS_SAT_Pointer_Register()
Processor testProcessor = new(2046);
testProcessor.Registers[(int)Register.rg7] = (ulong)randomTimestamp;
testProcessor.Registers[(int)Register.rg8] = 0x140;
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x89, (int)Register.rg8, (int)Register.rg7 });
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x8A, (int)Register.rg8, (int)Register.rg7 });
testProcessor.WriteMemoryString(0x140, "copyfile");
_ = testProcessor.Execute(false);
Assert.AreEqual(randomTimestamp, (int)(File.GetLastAccessTimeUtc("copyfile") - DateTime.UnixEpoch).TotalSeconds, "Instruction did not produce correct result");
Expand All @@ -1111,7 +1111,7 @@ public void FSYS_SAT_Address_Literal()
int randomTimestamp = rng.Next(int.MinValue, int.MaxValue);

Processor testProcessor = new(2046);
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x8A, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
testProcessor.LoadProgram(new byte[] { 0xFF, 0x06, 0x89, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
testProcessor.WriteMemoryQWord(11, (ulong)randomTimestamp);
testProcessor.WriteMemoryString(0x140, "copyfile");
_ = testProcessor.Execute(false);
Expand Down

0 comments on commit 855308e

Please sign in to comment.