Skip to content

Commit

Permalink
Int21h get current directory (#387)
Browse files Browse the repository at this point in the history
* Fix Test

- Because DS isn't part of the REGS struct, the assumption is it is set prior to the call
- Added Assert to check the value being saved

* Fixes

- Fixed to Match Documentation (DS:DI vs. DS:SI)

* Fixed missing closing parin when in debug
  • Loading branch information
enusbaum authored Jan 30, 2021
1 parent 9601b6b commit bb40eb3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions MBBSEmu.Tests/ExportedModules/Majorbbs/intdos_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ public void intdos_0x47_GetCurrentDirectory_Test()
var testRegisters = new CpuRegisters {AH = 0x47};

var dirPointer = mbbsEmuMemoryCore.AllocateVariable("DIR-POINTER", 10);
testRegisters.DS = dirPointer.Segment;
testRegisters.SI = dirPointer.Offset;
mbbsEmuCpuRegisters.DS = dirPointer.Segment;
testRegisters.DI = dirPointer.Offset;

//Allocate some memory to hold the test data
var testRegistersArrayData = testRegisters.ToRegs();
Expand All @@ -316,8 +316,9 @@ public void intdos_0x47_GetCurrentDirectory_Test()
//Verify Results
Assert.Equal(0, testRegisters.AX);
Assert.Equal(0, testRegisters.DL);
Assert.Equal(4096, testRegisters.DS);
Assert.Equal(40238, testRegisters.SI);
Assert.Equal(dirPointer.Segment, mbbsEmuCpuRegisters.DS);
Assert.Equal(dirPointer.Offset, testRegisters.DI);
Assert.Equal("BBSV6\\", Encoding.ASCII.GetString(mbbsEmuMemoryCore.GetString(testRegisters.DS, testRegisters.DI, true)));
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion MBBSEmu/DOS/Interrupts/Int21h.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ DOS 2+ - GET CURRENT DIRECTORY
AX = error code
Note: the returned path does not include the initial backslash
*/
_memory.SetArray(_registers.DS, _registers.SI, Encoding.ASCII.GetBytes("BBSV6\\\0"));
_memory.SetArray(_registers.DS, _registers.DI, Encoding.ASCII.GetBytes("BBSV6\\\0"));
_registers.AX = 0;
_registers.DL = 0;
_registers.F = _registers.F.ClearFlag((ushort)EnumFlags.CF);
Expand Down
2 changes: 1 addition & 1 deletion MBBSEmu/HostProcess/ExportedModules/ExportedModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ private protected ReadOnlySpan<byte> ProcessTextVariables(ReadOnlySpan<byte> out
var resultRegisters = Module.Execute(variableEntryPoint, ChannelNumber, true, true, null, 0xF100);
var variableData = Module.Memory.GetString(resultRegisters.DX, resultRegisters.AX, true);
#if DEBUG
_logger.Debug(($"({Module.ModuleIdentifier}) Processing Text Variable {textVariableName} ({variableEntryPoint}): {BitConverter.ToString(variableData.ToArray()).Replace("-", " ")}");
_logger.Debug(($"({Module.ModuleIdentifier}) Processing Text Variable {textVariableName} ({variableEntryPoint}): {BitConverter.ToString(variableData.ToArray()).Replace("-", " ")}"));
#endif
newOutputBuffer.Write(variableData);
break;
Expand Down

0 comments on commit bb40eb3

Please sign in to comment.