While converting old Turbo Pascal units to modern Object Pascal, I ran into the following:
function Less (var a, b; Relation : POINTER) : boolean;
inline($5B/$59/$0E/$E8/$00/$00/$58/$05/$08/$00/$50/$51/$53/$CB);
The code is supposed to call an external function {$F+} function VariableLess(var a, b : Index) : boolean; {$F-}
, collect the result and pass it to the calling function. The function is used in a unit that provides binary trees for untyped data
procedure InsVarBBTree(var B: BBTree; var E; S: word; A: pointer; var ok: boolean);
{ puts variable E of size S into tree B. The order relation address is A. }
Therefore, the unit itself cannot provide a comparison function, that is the job of the unit that defines the payload.
Using an online disassembler I found out that this corresponds to:
{$ASMMODE intel}
function Less (var a, b; Relation : POINTER) : boolean; assembler;
asm
pop bx
pop cx
push cs
call 6
pop ax
add ax, 8
push ax
push cx
push bx
retf
end;
However, the compiler doesn't like the push
statement. What should I do to get this to work on a modern 64-bit machine? I realise the code is 16-bit.