call aliased routines in asm-block lazarus / 62-General ---------------------------------------------------------------------- Kays · 2019-01-24 04:34 I can't call any aliased routine from my asm-blocks. Even the example program aliases does not compile. (FPC version 3.0.4+dfsg-11) I keep getting error messages such asCode: [Select]aliases.pas(9,8) Error: Unknown identifier "DOIT" Yes, I have seen the deprecated-remark, but replacing “alias:” by “public name” does not make any difference. I've tried both {$asmMode}, without luck. Any suggestions? ---------------------------------------------------------------------- engkin · 2019-01-24 05:19 try adding: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure DOIT; external name 'DOIT'; ---------------------------------------------------------------------- Thaddy · 2019-01-24 10:21 Quote from: engkin on January 24, 2019, 06:19:31 amtry adding: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure DOIT; external name 'DOIT';Yes, but external routines are case sensitive and usually lower case..... ---------------------------------------------------------------------- marcov · 2019-01-24 10:31 External links a symbol to a routine. public is the declaration of such symbol. See e.g. rtl/linux/i386/syscall*;   syscall.inc are the declarations of functions together with their implementation and they use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler; register; [public,alias:'FPC_SYSCALL3']; This is because these functions are used in system, but not exported from system. In other units they are used (e.g. via unit syscall), and syscallh.inc declares how they are imported:  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function Do_SysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; register; external name 'FPC_SYSCALL3'; (Note that do_syscall/fpsyscall are all heavily overloaded, both the original declarations in system, as their usage elsewhere. However the assembler labels must be distinct, so the number of parameters (3 in this case) is suffixed to the asm symbol) ---------------------------------------------------------------------- Kays · 2019-01-25 13:50 Quote from: engkin on January 24, 2019, 06:19:31 amtry adding:Nope, it is not external which is missing. Anyway, I wanna use a routine that's been defined in another (Pascal) unit. I really don't wanna replicate signatures from there. Does it (the example from the reference) work anywhere? ---------------------------------------------------------------------- PascalDragon · 2019-01-25 15:00 The hint provided by engkin is the correct one. The assembler reader does not check aliases and thus it needs to be at least a procedure declaration with no parameters and the name you want to use to call it from the assembly: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Program Aliases;   Procedure Printit;alias : ’DOIT’;  begin    WriteLn (’In Printit (alias : "DOIT")’);  end;  procedure Foo; external name 'DOIT'; begin    asm    call Foo    end;  end.  Though in general I wouldn't suggest to use this scheme. Just put the procedure into the interface section and be done with it. ---------------------------------------------------------------------- Kays · 2019-01-25 17:32 Quote from: PascalDragon on January 25, 2019, 04:00:20 pmThe hint provided by engkin is the correct one. […]Whoops. Yeah, OK it works here, too. I must have copied it wrong. I don't know, I must have attempted to insertCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure printit; external name 'doit';which of course fails. I don't wanna register another mangled name for the same procedure, but just alter the assembler label and use that alteration. Quote from: PascalDragon on January 25, 2019, 04:00:20 pm[…] Just put the procedure into the interface section and be done with it. Huh, well. How? When I try:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program aliases(input, output, stderr);uses        myUnit;begin        asm                call print_it // Unknown identifier "PRINT_IT"        end;end.Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit myUnit;interfaceprocedure printIt; implementationprocedure printIt; public name 'print_it';begin        writeLn('in printIt');end;end.Only when I insertCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure print_it; external name 'print_it'; into program aliases, the program compiles. This really doesn't sound right. I shouldn't have to clone the interface of another Pascal unit, which is already included via the uses-clause. ---------------------------------------------------------------------- engkin · 2019-01-25 18:08 Quote from: Kays on January 25, 2019, 06:32:45 pmQuote from: PascalDragon on January 25, 2019, 04:00:20 pm[…] Just put the procedure into the interface section and be done with it. Huh, well. How? He meant call printit directly in your asm block instead of creating a new name. You seem to have a reason preventing you from doing that! What are you trying to solve? ---------------------------------------------------------------------- Kays · 2019-01-25 18:33 Quote from: engkin on January 25, 2019, 07:08:12 pm[…] He meant call printit directly in your asm block instead of creating a new name. You seem to have a reason preventing you from doing that! What are you trying to solve? Within a pure assembler-function I want to call a routine whose implementation resides in another Pascal unit. I want to use a readable identifier while doing so, so I want to define an alias there. Basically what my previous post already shows, except the program is yet another unit. ---------------------------------------------------------------------- Kays · 2019-01-26 16:55 OK, fixed in documentation. I missed some key aspect. The function I wanna call is overloaded Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program aliases(input, output, stderr); function identity(const r: extended): extended;begin        identity := r;end; function identity(const x: int64): int64; register;begin        identity := x;end; var        x: int64;begin        x := 42;        asm                push x              call identity        end;end.This will pick the wrong the function. (If you define the function in reverse order, it will pick the one defined first.) I mean, the compiler's so nice and prints a warning: Quotealiases.pas(19,8) Warning: Calling an overload function in assembler but I wanna avoid the situation altogether. That's why I started thinking about using the alias directive.