+ added range checking for the imm4 operand of NEC V20/V30's instructions

'EXT reg8,imm4' and 'INS reg8,imm4'

git-svn-id: trunk@33321 -
This commit is contained in:
nickysn 2016-03-24 15:45:23 +00:00
parent be83ae47b9
commit 0be6d062ac
3 changed files with 13 additions and 6 deletions

View File

@ -13004,7 +13004,7 @@
ops : 2;
optypes : (ot_reg8,ot_immediate,ot_none,ot_none);
code : #2#15#59#128#21;
flags : if_nec or if_sb or if_16bitonly
flags : if_nec or if_sb or if_imm4 or if_16bitonly
),
(
opcode : A_INS;
@ -13018,7 +13018,7 @@
ops : 2;
optypes : (ot_reg8,ot_immediate,ot_none,ot_none);
code : #2#15#57#128#21;
flags : if_nec or if_sb or if_16bitonly
flags : if_nec or if_sb or if_imm4 or if_16bitonly
),
(
opcode : A_NOT1;

View File

@ -480,6 +480,7 @@ implementation
{ added flags }
IF_PRE = $40000000; { it's a prefix instruction }
IF_PASS2 = $80000000; { if the instruction can change in a second pass }
IF_IMM4 = $100000000; { immediate operand is a nibble (must be in range [0..15]) }
type
TInsTabCache=array[TasmOp] of longint;
@ -2968,8 +2969,14 @@ implementation
&24,&25,&26,&27 :
begin
getvalsym(c-&24);
if (currval<0) or (currval>255) then
Message2(asmw_e_value_exceeds_bounds,'unsigned byte',tostr(currval));
if (insentry^.flags and IF_IMM4)<>0 then
begin
if (currval<0) or (currval>15) then
Message2(asmw_e_value_exceeds_bounds,'unsigned nibble',tostr(currval));
end
else
if (currval<0) or (currval>255) then
Message2(asmw_e_value_exceeds_bounds,'unsigned byte',tostr(currval));
if assigned(currsym) then
objdata_writereloc(currval,1,currsym,currabsreloc)
else

View File

@ -5038,14 +5038,14 @@ void \2\x0F\x26 NEC,16
[EXT]
(Ch_All, Ch_None, Ch_None)
reg8,reg8 \2\x0F\x33\101 NEC,16BITONLY
reg8,imm \2\x0F\x3B\200\25 NEC,SB,16BITONLY
reg8,imm \2\x0F\x3B\200\25 NEC,SB,IMM4,16BITONLY
;[FPO2]
[INS]
(Ch_All, Ch_None, Ch_None)
reg8,reg8 \2\x0F\x31\101 NEC,16BITONLY
reg8,imm \2\x0F\x39\200\25 NEC,SB,16BITONLY
reg8,imm \2\x0F\x39\200\25 NEC,SB,IMM4,16BITONLY
[NOT1]
(Ch_Mop2, Ch_Rop1, Ch_None)