Recent

Author Topic: [SOLVED] Static variable in the function  (Read 287 times)

julkas

  • Hero Member
  • *****
  • Posts: 518
  • KISS principle / Lazarus 2.0.6 / FPC 3.0.4
[SOLVED] Static variable in the function
« on: October 10, 2019, 05:59:58 pm »
How implement C like static variable in the function in FPC 3.0.4. ?
« Last Edit: October 10, 2019, 07:41:07 pm by julkas »
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;

Cyrax

  • Hero Member
  • *****
  • Posts: 771
Re: Static variable in the function
« Reply #1 on: October 10, 2019, 06:18:54 pm »
Code: Pascal  [Select]
  1. procedure Static;
  2. const
  3.   StaticVariable : Integer = 0;
  4. begin
  5. end;

Thaddy

  • Hero Member
  • *****
  • Posts: 9399
Re: Static variable in the function
« Reply #2 on: October 10, 2019, 06:30:32 pm »
Maybe to be sure:
Code: Pascal  [Select]
  1. procedure Static;
  2. {$push} {$J+}
  3. const
  4.   StaticVariable : Integer = 0;
  5. {$pop}
  6. begin
  7. end;
also related to equus asinus.

julkas

  • Hero Member
  • *****
  • Posts: 518
  • KISS principle / Lazarus 2.0.6 / FPC 3.0.4
Re: Static variable in the function
« Reply #3 on: October 10, 2019, 07:39:54 pm »
Thanks all. Working.
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;