mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 19:29:24 +02:00
[PATCH 170/188] using FPC built int function to do arithmetical
shift-right. From 888bece97b8bb2ba160638e56ab00f21dccd0a93 Mon Sep 17 00:00:00 2001 From: Dmitry Boyarintsev <skalogryz.lists@gmail.com> Date: Fri, 27 Mar 2020 14:24:47 -0400 git-svn-id: branches/wasm@46166 -
This commit is contained in:
parent
771db4114c
commit
4a4a024eb6
@ -80,24 +80,15 @@ end;
|
||||
procedure WriteS(src: TStream; vl: Int64; bits: integer);
|
||||
var
|
||||
more : Boolean;
|
||||
negative : Boolean;
|
||||
b : byte;
|
||||
begin
|
||||
negative := vl < 0;
|
||||
|
||||
more := true;
|
||||
negative := (vl < 0);
|
||||
|
||||
if (bits < 0) then bits := sizeof(vl);
|
||||
|
||||
while more do begin
|
||||
b := (vl and $7f);
|
||||
vl := vl shr 7;
|
||||
|
||||
{ the following is only necessary if the implementation of >>= uses a
|
||||
logical shift rather than an arithmetic shift for a signed left operand }
|
||||
if (negative) then
|
||||
vl := vl or ((not 0) shl (bits - 7)); // sign extend
|
||||
vl := SarInt64(vl, 7);
|
||||
|
||||
{ sign bit of byte is second high order bit (0x40) }
|
||||
if ((vl = 0) and (b and $40 = 0))
|
||||
|
Loading…
Reference in New Issue
Block a user