fpc/tests/webtbs/tw32318.pp
Jonas Maebe 1b66995754 * factored out check to determine whether a variable can be subscripted in
inline assembly, and fixed check after r35959 (mantis #32318)
   o can also subscript parameters passed by value on the stack
   o can also subscript local variables, the parameters passed by reference
     that are subsequently copied into a local

git-svn-id: trunk@37886 -
2018-01-01 14:29:21 +00:00

55 lines
981 B
ObjectPascal

{ %cpu=i386}
{$ifdef fpc}
{$mode delphi}
{$endif fpc}
function MakeProcInstanceData(M: TMethod): Pointer;
begin
asm
MOV EAX, M.Data
MOV @RESULT, EAX
end;
end;
function MakeProcInstanceCode(M: TMethod): Pointer;
begin
asm
MOV EAX, M.Code
MOV @RESULT, EAX
end;
end;
function MakeProcInstanceDataAsm(M: TMethod): Pointer; assembler;
asm
MOV EAX, M.Data
MOV @RESULT, EAX
end;
function MakeProcInstanceCodeAsm(M: TMethod): Pointer; assembler;
asm
MOV EAX, M.Code
MOV @RESULT, EAX
end;
var
m: tmethod;
begin
m.code:=pointer(1);
m.data:=pointer(2);
if MAkeProcInstanceData(M)<>pointer(2) then
halt(1);
m.code:=pointer(1);
m.data:=pointer(2);
if MAkeProcInstanceCode(M)<>pointer(1) then
halt(2);
m.code:=pointer(1);
m.data:=pointer(2);
if MAkeProcInstanceDataAsm(M)<>pointer(2) then
halt(3);
m.code:=pointer(1);
m.data:=pointer(2);
if MAkeProcInstanceCodeAsm(M)<>pointer(1) then
halt(4);
end.