Skip to content

Commit fa09a1c

Browse files
authored
bugfix: Calling an override is not the same as calling an asm function, no return instruction is expected. (#2145)
1 parent baf34a7 commit fa09a1c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/Spice86.Core/Emulator/Function/FunctionHandler.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public void Call(CallType callType, SegmentedAddress entryAddress, SegmentedAddr
7979
/// <param name="name">Name to give to the function.</param>
8080
public void Call(CallType callType, SegmentedAddress entryAddress, SegmentedAddress? expectedReturnAddress, CfgInstruction? call, string? name) {
8181
FunctionInformation currentFunction = _functionCatalogue.GetOrCreateFunctionInformation(entryAddress, name);
82+
if (UseCodeOverride && currentFunction.HasOverride) {
83+
currentFunction.CallOverride();
84+
// No need to register the function call, no associated ret was executed.
85+
return;
86+
}
8287
FunctionCall currentFunctionCall = new(callType, entryAddress, expectedReturnAddress, CurrentStackAddress, call);
8388
_callerStack.Push(currentFunctionCall);
8489
if (_loggerService.IsEnabled(LogEventLevel.Verbose)) {
@@ -88,10 +93,6 @@ public void Call(CallType callType, SegmentedAddress entryAddress, SegmentedAddr
8893

8994
FunctionInformation? callerInfo = _functionCatalogue.GetFunctionInformation(CurrentFunctionCall);
9095
currentFunction.Enter(callerInfo);
91-
92-
if (UseCodeOverride) {
93-
currentFunction.CallOverride();
94-
}
9596
}
9697

9798
/// <summary>

0 commit comments

Comments
 (0)