From 64ddf22e1b77cea0a29d13f5bcd1e09e8bb17ebf Mon Sep 17 00:00:00 2001 From: Yuriy Sydorov Date: Mon, 16 Aug 2021 00:40:06 +0300 Subject: [PATCH] * TP compatibility: For retro CPUs always copy the function result to the register(s) on function exit if assembler blocks are present. --- compiler/pstatmnt.pas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas index 1fd8146e77..89bc9ddb6e 100644 --- a/compiler/pstatmnt.pas +++ b/compiler/pstatmnt.pas @@ -1085,7 +1085,13 @@ implementation { Mark procedure that it has assembler blocks } include(current_procinfo.flags,pi_has_assembler_block); - +{$if defined(cpu8bitalu) or defined(cpu16bitalu)} + { We assume the function result is always used in the TP mode } + if (m_tp7 in current_settings.modeswitches) and + not (po_assembler in current_procinfo.procdef.procoptions) and + assigned(current_procinfo.procdef.funcretsym) then + current_procinfo.procdef.funcretsym.IncRefCount; +{$endif} { Read first the _ASM statement } consume(_ASM);