Преглед на файлове

* fix for inline asm of instructions with 32-bit constant operands on i8086

git-svn-id: trunk@37519 -
nickysn преди 7 години
родител
ревизия
325e66287c
променени са 4 файла, в които са добавени 47 реда и са изтрити 3 реда
  1. 1 0
      .gitattributes
  2. 5 3
      compiler/rautils.pas
  3. 8 0
      compiler/x86/aasmcpu.pas
  4. 33 0
      tests/test/cpu16/i8086/tasm16_32_1.pp

+ 1 - 0
.gitattributes

@@ -12105,6 +12105,7 @@ tests/test/cg/variants/tvarol9.pp svneol=native#text/plain
 tests/test/cg/variants/tvarol91.pp svneol=native#text/plain
 tests/test/cg/variants/tvarol94.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/tasmseg1.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

+ 5 - 3
compiler/rautils.pas

@@ -50,11 +50,13 @@ type
   TOprRec = record
     case typ:TOprType of
       OPR_NONE      : ();
-{$ifdef AVR}
+{$if defined(AVR)}
       OPR_CONSTANT  : (val:word);
-{$else AVR}
+{$elseif defined(i8086)}
+      OPR_CONSTANT  : (val:longint);
+{$else}
       OPR_CONSTANT  : (val:aint);
-{$endif AVR}
+{$endif}
       OPR_SYMBOL    : (symbol:tasmsymbol;symofs:aint;symseg:boolean;sym_farproc_entry:boolean);
       OPR_REFERENCE : (varsize:asizeint; constoffset: asizeint;ref_farproc_entry:boolean;ref:treference);
       OPR_LOCAL     : (localvarsize, localconstoffset: asizeint;localsym:tabstractnormalvarsym;localsymofs:aint;localindexreg:tregister;localscale:byte;localgetoffset,localforceref:boolean);

+ 8 - 0
compiler/x86/aasmcpu.pas

@@ -2862,7 +2862,11 @@ implementation
       }
 
       var
+{$ifdef i8086}
+        currval : longint;
+{$else i8086}
         currval : aint;
+{$endif i8086}
         currsym : tobjsymbol;
         currrelreloc,
         currabsreloc,
@@ -2932,7 +2936,11 @@ implementation
                 end;
               top_const :
                 begin
+{$ifdef i8086}
+                  currval:=longint(oper[opidx]^.val);
+{$else i8086}
                   currval:=aint(oper[opidx]^.val);
+{$endif i8086}
                   currsym:=nil;
                   currabsreloc:=RELOC_ABSOLUTE;
                   currabsreloc32:=RELOC_ABSOLUTE32;

+ 33 - 0
tests/test/cpu16/i8086/tasm16_32_1.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_1;
+
+{$asmmode intel}
+{$asmcpu 80386}
+
+var
+  lo_word, hi_word: Word;
+begin
+  asm
+    db 66h, 31h, 0c0h  { xor eax, eax }
+
+    { the actual instruction being tested: }
+    mov eax, 12345678h
+
+    db 66h, 50h  { push eax }
+    
+    pop word ptr [lo_word]
+    pop word ptr [hi_word]
+  end;
+  if (lo_word=$5678) and (hi_word=$1234) then
+    Writeln('Ok!')
+  else
+  begin
+    Writeln('Error!');
+    Halt(1);
+  end;
+end.