Przeglądaj źródła

* fixed the SEG inline asm directive when used with 32-bit registers on the i8086 target

git-svn-id: trunk@37613 -
nickysn 7 lat temu
rodzic
commit
c464f7fa56
3 zmienionych plików z 61 dodań i 1 usunięć
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/x86/aasmcpu.pas
  3. 55 0
      tests/test/cpu16/i8086/tasmseg2.pp

+ 1 - 0
.gitattributes

@@ -12135,6 +12135,7 @@ tests/test/cpu16/i8086/tasmabs3.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tasmabs4.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tasmabs5.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tasmseg1.pp svneol=native#text/pascal
+tests/test/cpu16/i8086/tasmseg2.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarcal1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarcal2.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarcal3.pp svneol=native#text/plain

+ 5 - 1
compiler/x86/aasmcpu.pas

@@ -3355,7 +3355,11 @@ implementation
             &40,&41,&42 :    // 040..042
               begin
                 getvalsym(c-&40);
-                if assigned(currsym) then
+                if assigned(currsym)
+{$ifdef i8086}
+                   or (currabsreloc in [RELOC_DGROUP,RELOC_FARDATASEG])
+{$endif i8086}
+                then
                  objdata_writereloc(currval,4,currsym,currabsreloc32)
                 else
                  objdata.writebytes(currval,4);

+ 55 - 0
tests/test/cpu16/i8086/tasmseg2.pp

@@ -0,0 +1,55 @@
+{ %cpu=i8086 }
+
+program tasmseg2;
+
+{ i8086 test for the SEG inline assembler directive, when used in 32-bit
+  instructions }
+
+{$asmmode intel}
+{$asmcpu 80386}
+
+var
+  err, err2, err3: Boolean;
+begin
+  err := False;
+  asm
+    xor eax, eax
+    mov ebx, 0ffffffffh
+    mov ax, seg @data
+    mov ebx, seg @data
+    cmp eax, ebx
+    je @@ok
+    mov err, 1
+@@ok:
+  end;
+  if err then
+    Writeln('32-bit and 16-bit seg @data don''t match!');
+  err2 := False;
+  asm
+    xor eax, eax
+    mov ebx, 0ffffffffh
+    mov ax, seg @code
+    mov ebx, seg @code
+    cmp eax, ebx
+    je @@ok2
+    mov err2, 1
+@@ok2:
+  end;
+  if err2 then
+    Writeln('32-bit and 16-bit seg @code don''t match!');
+  err3 := False;
+  asm
+    xor eax, eax
+    mov ebx, 0ffffffffh
+    mov ax, seg err3
+    mov ebx, seg err3
+    cmp eax, ebx
+    je @@ok3
+    mov err3, 1
+@@ok3:
+  end;
+  if err3 then
+    Writeln('32-bit and 16-bit seg err3 don''t match!');
+  if err or err2 or err3 then
+    Halt(1);
+end.