Absolute/ru
Deutsch · English · Español · Français · Suomi · Русский
Модификатор absolute предписывает хранить данную переменную в той же области памяти, в которой хранится и другая переменная.
// Пример для процессоров x64 с порядком расположения байт от младшего к старшему (little endian)
Uses SysUtils;
Var
anInt : Integer;
anotherInt : Integer absolute anInt;
firstByte : Byte absolute anInt;
begin
// обе целочисленные переменные расположены в одной области памяти, при этом изменение одной из них приводит к изменению другой
anInt := 20;
WriteLn(IntToStr(anInt) + ' ' + IntToStr(anotherInt)); // Выводится: 20 20
// значение 20 соответствует первому байту:
WriteLn('firstByte: ' + IntToStr(firstByte)); // Выводится: firstByte: 20
anotherInt := 333;
WriteLn(IntToStr(anInt) + ' ' + IntToStr(anotherInt)); // Выводится: 333 333
// 333 слишком большое значение, чтобы уместиться в одном байте
// little-endian x64 - младший байт идет первым в памяти (по меньшему адресу):
// 333 = 101001101 = 01001101 00000001 в памяти выглядит как = 0x4D 0x01 = десятичное значение: 77 1
WriteLn('firstByte: ' + IntToStr(firstByte)); // Выводится: firstByte: 77
end.From the Free Pascal wiki, page "Absolute/ru", as it stood on 2020-01-25 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
