瀏覽代碼

+ added test for 'DW/DD OFFSET xx' on i8086

git-svn-id: trunk@38154 -
nickysn 7 年之前
父節點
當前提交
70cbb8c326
共有 2 個文件被更改,包括 52 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 51 0
      tests/test/tasm17.pp

+ 1 - 0
.gitattributes

@@ -12492,6 +12492,7 @@ tests/test/tasm14f.pp svneol=native#text/plain
 tests/test/tasm15.pp svneol=native#text/plain
 tests/test/tasm15a.pp svneol=native#text/plain
 tests/test/tasm16.pp svneol=native#text/plain
+tests/test/tasm17.pp svneol=native#text/plain
 tests/test/tasm2.inc svneol=native#text/plain
 tests/test/tasm2.pp svneol=native#text/plain
 tests/test/tasm2a.pp svneol=native#text/plain

+ 51 - 0
tests/test/tasm17.pp

@@ -0,0 +1,51 @@
+{ %CPU=i8086 }
+program tasm17;
+
+{ This test is TP7 compatible }
+
+{$ifndef FPC}
+type
+  CodePointer = Pointer;
+{$endif}
+
+var
+  xx: word;
+
+const
+  expect1: array [0..6] of word =
+    (Ofs(xx),Ofs(xx),Ofs(xx),Seg(xx),Ofs(xx),0,$aa55);
+
+procedure test1; assembler;
+asm
+  dw xx
+  dw offset xx
+  dd xx
+  dd offset xx
+  db 55h, 0aah
+end;
+
+procedure Error;
+begin
+  Writeln('Error!');
+  Halt(1);
+end;
+
+{ This version works in all i8086 memory models }
+function CompareCode(cp: CodePointer; dp: Pointer; sz: Integer): Boolean;
+var
+  I: Integer;
+begin
+  for I := 0 to sz - 1 do
+    if Mem[Seg(cp^):Ofs(cp^) + I] <> Mem[Seg(dp^):Ofs(dp^) + I] then
+    begin
+      CompareCode := False;
+      exit;
+    end;
+  CompareCode := True;
+end;
+
+begin
+  if not CompareCode(CodePointer(@test1), @expect1, SizeOf(expect1)) then
+    Error;
+  Writeln('Ok!');
+end.