From e877bae4fc8e474ab81d55862a0dcff54aec21d9 Mon Sep 17 00:00:00 2001 From: nickysn Date: Fri, 8 Jan 2016 16:41:21 +0000 Subject: [PATCH] + add 'jmp rm16' and 'call rm16' before the rm32 versions on i8086, so the 16-bit version is picked up by default for opsize=S_NO. Previously the 386 version was picked on i8086, but the generated code was correct, because we don't yet generate a 0x66 prefix for "\325", which leads to many 32-bit instructions not being assembled correctly with the internal asm obj writer on the i8086 git-svn-id: trunk@32887 - --- compiler/i8086/i8086nop.inc | 2 +- compiler/i8086/i8086tab.inc | 14 ++++++++++++++ compiler/x86/x86ins.dat | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/compiler/i8086/i8086nop.inc b/compiler/i8086/i8086nop.inc index 636644c103..f36d11bb25 100644 --- a/compiler/i8086/i8086nop.inc +++ b/compiler/i8086/i8086nop.inc @@ -1,2 +1,2 @@ { don't edit, this file is generated from x86ins.dat } -1973; +1975; diff --git a/compiler/i8086/i8086tab.inc b/compiler/i8086/i8086tab.inc index 7d46120499..ce9c88300c 100644 --- a/compiler/i8086/i8086tab.inc +++ b/compiler/i8086/i8086tab.inc @@ -378,6 +378,13 @@ code : #208#2#15#186#133#21; flags : if_386 or if_sb ), + ( + opcode : A_CALL; + ops : 1; + optypes : (ot_rm_gpr or ot_bits16,ot_none,ot_none,ot_none); + code : #212#1#255#130; + flags : if_8086 or if_16bitonly + ), ( opcode : A_CALL; ops : 1; @@ -2541,6 +2548,13 @@ code : #208#1#233#52; flags : if_8086 or if_pass2 ), + ( + opcode : A_JMP; + ops : 1; + optypes : (ot_rm_gpr or ot_bits16,ot_none,ot_none,ot_none); + code : #212#1#255#132; + flags : if_8086 or if_16bitonly + ), ( opcode : A_JMP; ops : 1; diff --git a/compiler/x86/x86ins.dat b/compiler/x86/x86ins.dat index c6c90c8161..3ca4e1db92 100644 --- a/compiler/x86/x86ins.dat +++ b/compiler/x86/x86ins.dat @@ -128,6 +128,9 @@ rm16|32|64,imm \320\2\x0F\xBA\205\25 386,SB ; Compiler emits CALL/JMP with opsize=S_NO which matches any size, ; and will match the first entry in sequence. ; Therefore rm16 must be placed after rm32/rm64 +; However, on i8086, rm16 must be first, so it's repeated in the beginning +; with a 16BITONLY flag +rm16 \324\1\xFF\202 8086,16BITONLY rm32 \325\1\xFF\202 386,NOX86_64 rm64 \335\1\xFF\202 X86_64 rm16 \324\1\xFF\202 8086 @@ -887,8 +890,11 @@ imm \1\xE3\50 X86_64 [JMP,jmpX] (Ch_ROp1, Ch_None, Ch_None) ; rm16 should be after rm32/rm64, see comments for CALL. +; However, on i8086, rm16 must be first, so it's repeated in the beginning +; with a 16BITONLY flag imm8 \1\xEB\50 8086,PASS2 imm16|32 \320\1\xE9\64 8086,PASS2 +rm16 \324\1\xFF\204 8086,16BITONLY rm32 \325\1\xFF\204 386,NOX86_64 rm64 \335\1\xFF\204 X86_64 rm16 \324\1\xFF\204 8086