Browse Source

* fixed another i8086 inline asm 32-bit constant bug (e.g. in 'or eax, 80000001h')

git-svn-id: trunk@37521 -
nickysn 7 years ago
parent
commit
8a0d8f025b

+ 2 - 0
.gitattributes

@@ -12107,6 +12107,8 @@ tests/test/cg/variants/tvarol94.pp svneol=native#text/plain
 tests/test/cg/variants/tvarol96.pp svneol=native#text/plain
 tests/test/cg/variants/tvarol96.pp svneol=native#text/plain
 tests/test/cpu16/i8086/tasm16_32_1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tasm16_32_1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tasm16_32_2.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tasm16_32_2.pp svneol=native#text/pascal
+tests/test/cpu16/i8086/tasm16_32_3.pp svneol=native#text/pascal
+tests/test/cpu16/i8086/tasm16_32_4.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tasmseg1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tasmseg1.pp svneol=native#text/pascal
 tests/test/cpu16/i8086/tfarcal1.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/tfarcal2.pp svneol=native#text/pascal

+ 4 - 2
compiler/x86/aasmcpu.pas

@@ -1426,10 +1426,12 @@ implementation
                       ) then
                       ) then
                       message(asmr_e_invalid_opcode_and_operand);
                       message(asmr_e_invalid_opcode_and_operand);
                     if
                     if
-{$ifndef i8086}
+{$ifdef i8086}
+                       (longint(val)>=-128) and (val<=127) then
+{$else i8086}
                        (opsize<>S_W) and
                        (opsize<>S_W) and
-{$endif not i8086}
                        (aint(val)>=-128) and (val<=127) then
                        (aint(val)>=-128) and (val<=127) then
+{$endif not i8086}
                       ot:=OT_IMM8 or OT_SIGNED
                       ot:=OT_IMM8 or OT_SIGNED
                     else
                     else
                       ot:=OT_IMMEDIATE or opsize_2_type[i,opsize];
                       ot:=OT_IMMEDIATE or opsize_2_type[i,opsize];

+ 33 - 0
tests/test/cpu16/i8086/tasm16_32_3.pp

@@ -0,0 +1,33 @@
+{ %cpu=i8086 }
+
+{ i8086 test for correct assembly of 32-bit instructions on the i8086 target }
+
+{ this one tests an instruction with a 32-bit const operand }
+
+program tasm16_32_3;
+
+{$asmmode intel}
+{$asmcpu 80386}
+
+var
+  lo_word, hi_word: Word;
+begin
+  asm
+    db 66h, 31h, 0c0h  { xor eax, eax }
+
+    { the actual instruction being tested: }
+    or eax, 80000001h
+
+    db 66h, 50h  { push eax }
+    
+    pop word ptr [lo_word]
+    pop word ptr [hi_word]
+  end;
+  if (lo_word=$0001) and (hi_word=$8000) then
+    Writeln('Ok!')
+  else
+  begin
+    Writeln('Error!');
+    Halt(1);
+  end;
+end.

+ 33 - 0
tests/test/cpu16/i8086/tasm16_32_4.pp

@@ -0,0 +1,33 @@
+{ %cpu=i8086 }
+
+{ i8086 test for correct assembly of 32-bit instructions on the i8086 target }
+
+{ this one tests an instruction with a 32-bit const operand }
+
+program tasm16_32_4;
+
+{$asmmode att}
+{$asmcpu 80386}
+
+var
+  lo_word, hi_word: Word;
+begin
+  asm
+    .byte 0x66, 0x31, 0xc0  { xor eax, eax }
+
+    { the actual instruction being tested: }
+    orl $0x80000001, %eax
+
+    .byte 0x66, 0x50  { push eax }
+
+    popw lo_word
+    popw hi_word
+  end;
+  if (lo_word=$0001) and (hi_word=$8000) then
+    Writeln('Ok!')
+  else
+  begin
+    Writeln('Error!');
+    Halt(1);
+  end;
+end.