Using the assembly code given, you can call any function or procedure with any parameters (in your case: VariableLess) indirectly by writing a helper function (in your case: Less) that has the same arguments as the function to be called plus an additional argument that points to the actual function. With this knowledge the assembly code can be analyzed: And it must not return using ret but simply continue code execution at the instruction after the inline code. The inline machine language code must pop the arguments from the stack. This means that SS:SP points to the arguments, not to the return address. In an inline function, the raw bytes given simply replace the call instruction. The function returns using retf n, which means that the function called removes all parameters from the stack. The first one is pushed first (so SS:SP points to the last function argument). I just compiled some inline function on Turbo Pascal 5 for MS-DOS to check how Turbo Pascal generates code:įor non- inline function calls, Turbo Pascal pushes all function arguments to the stack. What should I do to get this to work on a modern 64-bit machine? I realise the code is 16-bit. However, the compiler doesn't like the push statement. The code is supposed to call an external function įunction Less (var a, b Relation : POINTER) : boolean assembler While converting old Turbo Pascal units to modern Object Pascal, I ran into the following: function Less (var a, b Relation : POINTER) : boolean
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |