summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw16700.pp
blob: 3d9d60a38e9c781677ad097fcc9c878085c7489a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ %cpu=i386 }
{ %opt=-Cg- }

{$ifdef fpc}
{$mode delphi}
{$endif}

program test;
type
  tr_rec=object
    x: integer;
    r: record
      a,b: integer;
    end;
    function f:integer;
  end;

var
  x1,a1,a2,b1: byte;
  b2: longint;

function tr_rec.f:integer;
asm
  mov dl,byte ptr [eax].tr_rec.x
  mov x1,dl
  mov dl,byte ptr [eax].tr_rec.r
  mov a1,dl
  mov dl,byte ptr [eax].tr_rec.r.a
  mov a2,dl
  mov dl,byte ptr [eax].tr_rec.r.b
  mov b1,dl
  movzx eax,byte ptr [eax].tr_rec.r.b
  mov b2,eax
  end;

var
  v: tr_rec;
begin
  v.x:=4;
  v.r.a:=10;
  v.r.b:=17;
  writeln(v.f,' (should be 17)');
  writeln(x1,' (should be 4)');
  writeln(a1,' (should be 10)');
  writeln(a2,' (should be 10)');
  writeln(b1,' (should be 17)');
  writeln(b2,' (should be 17)');
  if v.f<>17 then
    halt(1);
  if x1<>4 then
    halt(2);
  if a1<>10 then
    halt(3);
  if a2<>10 then
    halt(4);
  if b1<>17 then
    halt(5);
  if b2<>17 then
    halt(6);
end.