mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-27 19:53:42 +02:00
151 lines
2.9 KiB
PHP
151 lines
2.9 KiB
PHP
(*******************************************************************
|
|
*
|
|
* TTCalc4.Inc 1.2
|
|
*
|
|
* Arithmetic and Vectorial Computations (inline assembly)
|
|
* This version is used for i386 FreePascal
|
|
*
|
|
* Copyright 1996 David Turner, Robert Wilhelm and Werner Lemberg
|
|
*
|
|
* This file is part of the FreeType project, and may only be used
|
|
* modified and distributed under the terms of the FreeType project
|
|
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
|
* this file you indicate that you have read the license and
|
|
* understand and accept it fully.
|
|
*
|
|
* NOTES : All vector operations were moved to the interpreter
|
|
*
|
|
******************************************************************)
|
|
|
|
(**********************************************************)
|
|
(* *)
|
|
(* The following routines are inline assembly, they are *)
|
|
(* thus processor and bitness specific. Replace them *)
|
|
(* with your own if you want to port the TrueType Engine *)
|
|
|
|
(**********************************************************)
|
|
(* 64 Bit Addition *)
|
|
|
|
procedure Add64( var X, Y, Z : Int64 );// assembler;
|
|
begin
|
|
X := Y + Z;
|
|
end;
|
|
{asm
|
|
push %ebx
|
|
push %edx
|
|
|
|
mov X,%ebx
|
|
mov (%ebx) ,%eax
|
|
mov 4(%ebx) ,%edx
|
|
|
|
mov Y,%ebx
|
|
add (%ebx) ,%eax
|
|
adc 4(%ebx) ,%edx
|
|
|
|
mov Z,%ebx
|
|
mov %eax, (%ebx)
|
|
mov %edx, 4(%ebx)
|
|
|
|
pop %edx
|
|
pop %ebx
|
|
end;}
|
|
|
|
|
|
(**********************************************************)
|
|
(* 64 Bit Substraction *)
|
|
|
|
procedure Sub64( var X, Y, Z : Int64 );// assembler;
|
|
begin
|
|
X := Y - Z;
|
|
end;
|
|
{asm
|
|
push %ebx
|
|
push %edx
|
|
|
|
mov X,%ebx
|
|
mov (%ebx) ,%eax
|
|
mov 4(%ebx) ,%edx
|
|
|
|
mov Y,%ebx
|
|
sub (%ebx) ,%eax
|
|
sbb 4(%ebx) ,%edx
|
|
|
|
mov Z,%ebx
|
|
mov %eax, (%ebx)
|
|
mov %edx, 4(%ebx)
|
|
|
|
pop %edx
|
|
pop %ebx
|
|
end;}
|
|
|
|
|
|
(**********************************************************)
|
|
(* Multiply two Int32 to an Int64 *)
|
|
|
|
procedure MulTo64( X, Y : Int32; out Z : Int64 );// assembler;
|
|
begin
|
|
Z := int64(X) * int64(Y);
|
|
end;
|
|
{asm
|
|
push %ebx
|
|
push %edx
|
|
|
|
mov X,%eax
|
|
imull Y
|
|
|
|
mov Z,%ebx
|
|
mov %eax, (%ebx)
|
|
mov %edx, 4(%ebx)
|
|
|
|
pop %edx
|
|
pop %ebx
|
|
end;}
|
|
|
|
|
|
(**********************************************************)
|
|
(* Divide an Int64 by an Int32 *)
|
|
|
|
function Div64by32( X : Int64; Y : Int32 ) : Int32;// assembler;
|
|
begin
|
|
Result := X div Y;
|
|
end;
|
|
{asm
|
|
push %ebx
|
|
push %edx
|
|
|
|
mov X,%ebx
|
|
mov (%ebx) ,%eax
|
|
mov 4(%ebx) ,%edx
|
|
idivl Y
|
|
|
|
pop %edx
|
|
pop %ebx
|
|
end;}
|
|
|
|
|
|
procedure DivMod64by32( X : Int64; Y : Int32; out Q, R : Int32 );
|
|
// assembler;
|
|
begin
|
|
Q := X div Y;
|
|
R := X mod Y;
|
|
end;
|
|
{asm
|
|
push %ebx
|
|
push %edx
|
|
|
|
mov X,%ebx
|
|
mov (%ebx) ,%eax
|
|
mov 4(%ebx) ,%edx
|
|
idivl Y
|
|
|
|
mov Q, %ebx
|
|
mov %eax, (%ebx)
|
|
|
|
mov R, %ebx
|
|
mov %edx, (%ebx)
|
|
|
|
pop %edx
|
|
pop %ebx
|
|
end;}
|
|
|