1procedure error(const s: string);
2begin
3  writeln('error: ',s);
4  halt(1);
5end;
6
7procedure testlohiword;
8var
9  w: word;
10  i: smallint;
11begin
12  w := $1234;
13  i := $1234;
14  if lo(w) <> (w and 255) then
15    error('lo word');
16  if lo(i) <> (i and 255) then
17    error('lo integer');
18
19  if hi(w) <> (w shr 8) then
20    error('hi word');
21  if hi(i) <> (i shr 8) then
22    error('hi integer');
23end;
24
25
26procedure testlohilong;
27var
28  w: cardinal;
29  i: longint;
30begin
31  w := $12345678;
32  i := $12345678;
33  if lo(w) <> (w and $ffff) then
34    error('lo cardinal');
35  if lo(i) <> (i and $ffff) then
36    error('lo longint');
37
38  if hi(w) <> (w shr 16) then
39    error('hi cardinal');
40  if hi(i) <> (i shr 16) then
41    error('hi longint');
42end;
43
44
45procedure testlohiqword;
46var
47  w: qword;
48  i: int64;
49begin
50  w := $12345678;
51  w := w shl 32;
52  w := w or $98765432;
53  i := int64(w);
54  if lo(w) <> (cardinal(w)) then
55    error('lo qword');
56  if longint(lo(i)) <> (longint(w)) then
57    error('lo int64');
58
59  if hi(w) <> (w shr 32) then
60    error('hi qword');
61  if hi(i) <> (i shr 32) then
62    error('hi int64');
63end;
64
65begin
66  testlohiword;
67  testlohilong;
68  testlohiqword;
69end.
70