Skip to content

Commit

Permalink
Comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisVanEijden committed Jun 27, 2024
1 parent 989d0a5 commit c72bceb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/Spice86.Core/Emulator/Function/IOverrideSupplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public interface IOverrideSupplier {
/// <param name="configuration">The configuration.</param>
/// <param name="programStartAddress">The start address of the program.</param>
/// <param name="machine">The emulator machine.</param>
/// <param name="loggerService"></param>
/// <returns>A dictionary containing the generated function information overrides.</returns>
public IDictionary<SegmentedAddress, FunctionInformation> GenerateFunctionInformations(
ILoggerService loggerService,
Expand Down
20 changes: 11 additions & 9 deletions src/Spice86.Core/Emulator/ReverseEngineer/ArgumentFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Spice86.Core.Emulator.ReverseEngineer;

/// <summary>
/// Helper to get function arguments from the stack.
///
/// Argument naming is based on cdecl calling convention.
/// </summary>
public class ArgumentFetcher {
private readonly Stack _stack;
Expand All @@ -30,17 +32,17 @@ public void Get(out ushort arg1, out uint arg2, out ushort arg3) {
}

public void Get(out string arg1, out short arg2, out ushort arg3) {
ushort dosPathPointerOffset = _stack.Peek16(4);
ushort stringPointerOffset = _stack.Peek16(4);
arg2 = (short)_stack.Peek16(6);
arg3 = _stack.Peek16(8);
arg1 = GetStringFromDsPointer(dosPathPointerOffset);
arg1 = GetStringFromDsPointer(stringPointerOffset);
}

public void Get(out string arg1, out ushort arg2, out short arg3) {
ushort dosPathPointerOffset = _stack.Peek16(4);
ushort stringPointerOffset = _stack.Peek16(4);
arg2 = _stack.Peek16(6);
arg3 = (short)_stack.Peek16(8);
arg1 = GetStringFromDsPointer(dosPathPointerOffset);
arg1 = GetStringFromDsPointer(stringPointerOffset);
}

public void Get(out ushort arg1, out int arg2, out ushort arg3) {
Expand Down Expand Up @@ -77,11 +79,6 @@ public void Get(out ushort arg1, out ushort arg2, out ushort arg3, out ushort ar
arg4 = _stack.Peek16(10);
}

private string GetStringFromDsPointer(ushort offset) {
uint address = MemoryUtils.ToPhysicalAddress(_state.DS, offset);
return _memory.GetZeroTerminatedString(address, int.MaxValue);
}

public void Get(out ushort arg1, out string arg2) {
arg1 = _stack.Peek16(4);
ushort arg2PointerOffset = _stack.Peek16(6);
Expand All @@ -99,4 +96,9 @@ public void Get(out uint arg1, out uint arg2, out ushort arg3) {
arg2 = _stack.Peek32(8);
arg3 = _stack.Peek16(12);
}

private string GetStringFromDsPointer(ushort offset) {
uint address = MemoryUtils.ToPhysicalAddress(_state.DS, offset);
return _memory.GetZeroTerminatedString(address, int.MaxValue);
}
}

0 comments on commit c72bceb

Please sign in to comment.