Skip to content

Commit bdaff8f

Browse files
string ops with symbolic memory operands did ignore assumes
1 parent 4674d9e commit bdaff8f

7 files changed

+28
-11
lines changed

History.txt

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
(ES:), a source without override was rejected; see string4.asm.
1414
- string operation MOVSx with operands: destination with override
1515
!= ES wasn't rejected; see string5.asm.
16+
- string operations with symbolic memory operands did ignore assumes, thus
17+
no segment prefix was created; see string8.asm.
1618

1719
03/14/2020, v2.13:
1820

Regression/Regression.zip

1.53 KB
Binary file not shown.

bin/JWasm_v214pre2_dos.zip

-604 KB
Binary file not shown.

bin/JWasm_v214pre2_win32.zip

-333 KB
Binary file not shown.

bin/JWasm_v214pre3_dos.zip

604 KB
Binary file not shown.

bin/JWasm_v214pre3_win32.zip

333 KB
Binary file not shown.

src/parser.c

+26-11
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ static void seg_override( struct code_info *CodeInfo, int seg_reg, const struct
398398
//if ( InstrTable[optable_idx[CodeInfo->token]].allowed_prefix == AP_REP ||
399399
// InstrTable[optable_idx[CodeInfo->token]].allowed_prefix == AP_REPxx )
400400
if ( CodeInfo->pinstr->allowed_prefix == AP_REP ||
401-
CodeInfo->pinstr->allowed_prefix == AP_REPxx )
402-
return;
401+
CodeInfo->pinstr->allowed_prefix == AP_REPxx )
402+
return;
403403

404404
if( CodeInfo->token == T_LEA ) {
405405
CodeInfo->prefix.RegOverride = ASSUME_NOTHING; /* skip segment override */
@@ -2154,7 +2154,7 @@ static void HandleStringInstructions( struct code_info *CodeInfo, const struct e
21542154
case T_CMPSQ:
21552155
#endif
21562156
/* cmps allows prefix for the first operand (=source) only */
2157-
if ( CodeInfo->prefix.RegOverride != EMPTY ) {
2157+
if ( CodeInfo->prefix.RegOverride != ASSUME_NOTHING ) {
21582158
if ( opndx[OPND2].override != NULL ) {
21592159
if ( CodeInfo->prefix.RegOverride == ASSUME_ES ) {
21602160
/* content of LastRegOverride is valid if
@@ -2168,10 +2168,14 @@ static void HandleStringInstructions( struct code_info *CodeInfo, const struct e
21682168
DebugMsg1(("HandleStringInstructions: CMPS: CodeInfo->RegOverride=%X, opndx->override=%s\n", CodeInfo->prefix.RegOverride, opndx[OPND2].override->string_ptr ));
21692169
EmitError( INVALID_INSTRUCTION_OPERANDS );
21702170
}
2171-
} else if ( CodeInfo->prefix.RegOverride == ASSUME_DS ) {
2172-
/* prefix for first operand? */
2173-
CodeInfo->prefix.RegOverride = ASSUME_NOTHING;/* v2.12: EMPTY -> ASSUME_NOTHING to avoid warning */
21742171
}
2172+
} else { /* v2.14 */
2173+
if ( opndx[OPND1].override == NULL && opndx[OPND1].sym ) {
2174+
check_assume( CodeInfo, opndx[OPND1].sym, ASSUME_DS );
2175+
}
2176+
}
2177+
if ( CodeInfo->prefix.RegOverride == ASSUME_DS ) {
2178+
CodeInfo->prefix.RegOverride = ASSUME_NOTHING;/* v2.12: EMPTY -> ASSUME_NOTHING to avoid warning */
21752179
}
21762180
break;
21772181
#if AVXSUPP
@@ -2198,10 +2202,10 @@ static void HandleStringInstructions( struct code_info *CodeInfo, const struct e
21982202
* there's only one place to store the register override in CodeInfo,
21992203
* so it's a problem if both operands have an override; to be improved.
22002204
*/
2201-
if ( CodeInfo->prefix.RegOverride != ASSUME_NOTHING )/* v2.12: EMPTY -> ASSUME_NOTHING to avoid warning */
2202-
#if 1 /* v2.14*/
2205+
if ( CodeInfo->prefix.RegOverride != ASSUME_NOTHING ) {/* v2.12: EMPTY -> ASSUME_NOTHING to avoid warning */
2206+
#if 1 /* v2.14: destination must be ES: */
22032207
if ( opndx[OPND1].override && opndx[OPND1].override->token == T_REG && opndx[OPND1].override->tokval != T_ES ) {
2204-
DebugMsg1(("HandleStringInstructions: CMPS: CodeInfo->RegOverride=%X, opndx->override=%s\n", CodeInfo->prefix.RegOverride, opndx[OPND1].override->string_ptr ));
2208+
DebugMsg1(("HandleStringInstructions: MOVS: CodeInfo->RegOverride=%X, opndx->override=%s\n", CodeInfo->prefix.RegOverride, opndx[OPND1].override->string_ptr ));
22052209
EmitError( INVALID_INSTRUCTION_OPERANDS );
22062210
} else
22072211
#endif
@@ -2213,8 +2217,16 @@ static void HandleStringInstructions( struct code_info *CodeInfo, const struct e
22132217
DebugMsg(("HandleStringInstructions: MOVS: override==NULL for second operand\n" ));
22142218
EmitError( INVALID_INSTRUCTION_OPERANDS );
22152219
}
2216-
} else if ( CodeInfo->prefix.RegOverride == ASSUME_DS )
2217-
CodeInfo->prefix.RegOverride = ASSUME_NOTHING;/* v2.12: EMPTY -> ASSUME_NOTHING to avoid warning */
2220+
} //else if ( CodeInfo->prefix.RegOverride == ASSUME_DS )
2221+
// CodeInfo->prefix.RegOverride = ASSUME_NOTHING;/* v2.12: EMPTY -> ASSUME_NOTHING to avoid warning */
2222+
}
2223+
else { /* v2.14 */
2224+
if ( opndx[OPND2].override == NULL && opndx[OPND2].sym ) {
2225+
check_assume( CodeInfo, opndx[OPND2].sym, ASSUME_DS );
2226+
}
2227+
}
2228+
if ( CodeInfo->prefix.RegOverride == ASSUME_DS )
2229+
CodeInfo->prefix.RegOverride = ASSUME_NOTHING;/* v2.12: EMPTY -> ASSUME_NOTHING to avoid warning */
22182230
break;
22192231
case T_OUTS:
22202232
case T_OUTSB:
@@ -2232,6 +2244,9 @@ static void HandleStringInstructions( struct code_info *CodeInfo, const struct e
22322244
#if AMD64_SUPPORT
22332245
case T_LODSQ:
22342246
#endif
2247+
/* v2.14 */
2248+
if ( opndx[OPND1].override == NULL && opndx[OPND1].sym )
2249+
check_assume( CodeInfo, opndx[OPND1].sym, ASSUME_DS );
22352250
/* v2.10: remove unnecessary DS prefix ( Masm-compatible ) */
22362251
if ( CodeInfo->prefix.RegOverride == ASSUME_DS )
22372252
CodeInfo->prefix.RegOverride = ASSUME_NOTHING;/* v2.12: EMPTY -> ASSUME_NOTHING to avoid warning */

0 commit comments

Comments
 (0)