Explorar o código

+ added i8086-msdos tests for interrupt procs, intr, getintvec and setintvec

git-svn-id: trunk@27503 -
nickysn %!s(int64=11) %!d(string=hai) anos
pai
achega
a9cfd647ae
Modificáronse 3 ficheiros con 203 adicións e 0 borrados
  1. 2 0
      .gitattributes
  2. 79 0
      tests/test/cpu16/i8086/tintr1.pp
  3. 122 0
      tests/test/cpu16/i8086/tintr2.pp

+ 2 - 0
.gitattributes

@@ -10840,6 +10840,8 @@ tests/test/cpu16/i8086/tfarptr1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarptr2.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarptr3.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarptr4.pp svneol=native#text/pascal
+tests/test/cpu16/i8086/tintr1.pp svneol=native#text/pascal
+tests/test/cpu16/i8086/tintr2.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tptrsize.pp svneol=native#text/pascal
 tests/test/cpu16/taddint1.pp svneol=native#text/pascal
 tests/test/dumpclass.pp svneol=native#text/plain

+ 79 - 0
tests/test/cpu16/i8086/tintr1.pp

@@ -0,0 +1,79 @@
+{ %target=msdos }
+
+program tintr1;
+
+{$ifdef FPC}
+  {$mode tp}
+{$endif FPC}
+
+uses
+  Dos;
+
+{$ifndef FPC}
+type
+  FarPointer = Pointer;
+{$endif FPC}
+
+const
+  IntNo = $F0;  { some unused interrupt vector }
+
+var
+  Handled: Boolean;
+
+procedure TestFail;
+begin
+  Writeln('Failure!');
+  Halt(1);
+end;
+
+procedure OurHandler; interrupt;
+begin
+  Handled := True;
+end;
+
+var
+  regs: Registers;
+  OldHandler: FarPointer;
+begin
+  regs.DS := $BAAD;
+  regs.BP := $BEEF;
+  regs.ES := $4A11;
+  regs.AX := $1111;
+  regs.BX := $2222;
+  regs.CX := $3333;
+  regs.DX := $4444;
+  regs.SI := $5555;
+  regs.DI := $6666;
+  Handled := False;
+
+  GetIntVec(IntNo, OldHandler);
+  SetIntVec(IntNo, @OurHandler);
+
+  Intr(IntNo, regs);
+
+  SetIntVec(IntNo, OldHandler);
+
+  if not Handled then
+    TestFail;
+
+  if regs.DS <> $BAAD then
+    TestFail;
+  if regs.BP <> $BEEF then
+    TestFail;
+  if regs.ES <> $4A11 then
+    TestFail;
+  if regs.AX <> $1111 then
+    TestFail;
+  if regs.BX <> $2222 then
+    TestFail;
+  if regs.CX <> $3333 then
+    TestFail;
+  if regs.DX <> $4444 then
+    TestFail;
+  if regs.SI <> $5555 then
+    TestFail;
+  if regs.DI <> $6666 then
+    TestFail;
+
+  Writeln('Success!')
+end.

+ 122 - 0
tests/test/cpu16/i8086/tintr2.pp

@@ -0,0 +1,122 @@
+{ %target=msdos }
+
+program tintr2;
+
+{$ifdef FPC}
+  {$mode tp}
+{$endif FPC}
+
+uses
+  Dos;
+
+{$ifndef FPC}
+type
+  FarPointer = Pointer;
+{$endif FPC}
+
+const
+  IntNo = $F0;  { some unused interrupt vector }
+
+var
+  Handled: Boolean;
+  HandledRegs: Registers;
+  HandledCS, HandledIP: Word;
+
+procedure TestFail;
+begin
+  Writeln('Failure!');
+  Halt(1);
+end;
+
+procedure OurHandler(Flags, CS, IP, AX, BX, CX, DX, SI, DI, DS, ES, BP: Word); interrupt;
+begin
+  Handled := True;
+  HandledRegs.Flags := Flags;
+  HandledCS := CS;
+  HandledIP := IP;
+  HandledRegs.AX := AX;
+  HandledRegs.BX := BX;
+  HandledRegs.CX := CX;
+  HandledRegs.DX := DX;
+  HandledRegs.SI := SI;
+  HandledRegs.DI := DI;
+  HandledRegs.DS := DS;
+  HandledRegs.ES := ES;
+  HandledRegs.BP := BP;
+
+  DS := $DAAB;
+  BP := $FEEB;
+  ES := $11A4;
+  AX := $FFFF;
+  BX := $EEEE;
+  CX := $DDDD;
+  DX := $CCCC;
+  SI := $BBBB;
+  DI := $AAAA;
+end;
+
+var
+  regs: Registers;
+  OldHandler: FarPointer;
+begin
+  regs.DS := $BAAD;
+  regs.BP := $BEEF;
+  regs.ES := $4A11;
+  regs.AX := $1111;
+  regs.BX := $2222;
+  regs.CX := $3333;
+  regs.DX := $4444;
+  regs.SI := $5555;
+  regs.DI := $6666;
+  Handled := False;
+
+  GetIntVec(IntNo, OldHandler);
+  SetIntVec(IntNo, @OurHandler);
+
+  Intr(IntNo, regs);
+
+  SetIntVec(IntNo, OldHandler);
+
+  if not Handled then
+    TestFail;
+
+  if HandledRegs.DS <> $BAAD then
+    TestFail;
+  if HandledRegs.BP <> $BEEF then
+    TestFail;
+  if HandledRegs.ES <> $4A11 then
+    TestFail;
+  if HandledRegs.AX <> $1111 then
+    TestFail;
+  if HandledRegs.BX <> $2222 then
+    TestFail;
+  if HandledRegs.CX <> $3333 then
+    TestFail;
+  if HandledRegs.DX <> $4444 then
+    TestFail;
+  if HandledRegs.SI <> $5555 then
+    TestFail;
+  if HandledRegs.DI <> $6666 then
+    TestFail;
+
+  if regs.DS <> $DAAB then
+    TestFail;
+  if regs.BP <> $FEEB then
+    TestFail;
+  if regs.ES <> $11A4 then
+    TestFail;
+  if regs.AX <> $FFFF then
+    TestFail;
+  if regs.BX <> $EEEE then
+    TestFail;
+  if regs.CX <> $DDDD then
+    TestFail;
+  if regs.DX <> $CCCC then
+    TestFail;
+  if regs.SI <> $BBBB then
+    TestFail;
+  if regs.DI <> $AAAA then
+    TestFail;
+
+  Writeln('Success!')
+end.