diff --git a/.gitattributes b/.gitattributes index 7679146717..a15f8ef0e0 100644 --- a/.gitattributes +++ b/.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/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_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/tfarcal1.pp svneol=native#text/pascal tests/test/cpu16/i8086/tfarcal2.pp svneol=native#text/pascal diff --git a/compiler/x86/aasmcpu.pas b/compiler/x86/aasmcpu.pas index e1aa0b4645..76fb0d2e00 100644 --- a/compiler/x86/aasmcpu.pas +++ b/compiler/x86/aasmcpu.pas @@ -1426,10 +1426,12 @@ implementation ) then message(asmr_e_invalid_opcode_and_operand); if -{$ifndef i8086} +{$ifdef i8086} + (longint(val)>=-128) and (val<=127) then +{$else i8086} (opsize<>S_W) and -{$endif not i8086} (aint(val)>=-128) and (val<=127) then +{$endif not i8086} ot:=OT_IMM8 or OT_SIGNED else ot:=OT_IMMEDIATE or opsize_2_type[i,opsize]; diff --git a/tests/test/cpu16/i8086/tasm16_32_3.pp b/tests/test/cpu16/i8086/tasm16_32_3.pp new file mode 100644 index 0000000000..09a2fb6b22 --- /dev/null +++ b/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. diff --git a/tests/test/cpu16/i8086/tasm16_32_4.pp b/tests/test/cpu16/i8086/tasm16_32_4.pp new file mode 100644 index 0000000000..42d9df1000 --- /dev/null +++ b/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.