Modify test to take into account the specific prologue for Huge model

git-svn-id: trunk@34016 -
This commit is contained in:
pierre 2016-06-24 15:13:37 +00:00
parent 7efce7f121
commit dfeadf89e9

View File

@ -15,6 +15,7 @@
{$endif}
{$ifdef FPC_MM_HUGE}
{$define TEST_ENABLED}
{$define NEED_POP_DS}
{$endif}
{$ELSE FPC}
{$define TEST_ENABLED}
@ -33,12 +34,12 @@ var
SavedSP: Word;
Bug: Boolean;
procedure CheckBug;
procedure CheckBug(i : byte);
begin
if Bug then
begin
Writeln('FAIL!!!');
halt(1);
halt(i);
end
else
Writeln('OK');
@ -46,14 +47,31 @@ end;
procedure farretproc; assembler;
asm
{ Huge mode generates:
push ds
mov ax,TFARCAL1_DATA
mov ds,ax
sequence }
{$ifdef NEED_POP_DS}
pop ds
{$endif def NEED_POP_DS}
{ hardcode it with db, because the compiler could generate a near ret, due
to some bug }
db $CB { RETF }
end;
procedure farretproc2; assembler; {$ifdef FPC} nostackframe;{$endif FPC}
asm
{ hardcode it with db, because the compiler could generate a near ret, due
to some bug }
{ For huge mode, the sequence described above
is not generated here }
db $CB { RETF }
end;
procedure testfarcall;
label
NoBug;
NoBug1, NoBug2;
begin
Write('Testing call farretproc...');
asm
@ -70,15 +88,39 @@ begin
xor ax, ax
cmp SavedSP, sp
je NoBug
je NoBug1
mov sp, SavedSP { restore the broken SP }
inc ax
NoBug:
NoBug1:
mov Bug, al
pop bx { pop the saved CS }
sti
end;
CheckBug;
CheckBug(1);
Write('Testing call farretproc2 with nostackframe modifier ...');
asm
cli
{ in case of a near call, the retf will pop this word and we'll detect the
bug without crashing }
push cs
mov SavedSP, sp
{ this should emit a far call }
call farretproc2
xor ax, ax
cmp SavedSP, sp
je NoBug2
mov sp, SavedSP { restore the broken SP }
inc ax
NoBug2:
mov Bug, al
pop bx { pop the saved CS }
sti
end;
CheckBug(2);
end;
begin