]> granicus.if.org Git - yasm/commitdiff
Fix bug in 32-bit displacement with no registers.
authorPeter Johnson <peter@tortall.net>
Sun, 17 Mar 2002 10:06:44 +0000 (10:06 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 17 Mar 2002 10:06:44 +0000 (10:06 -0000)
svn path=/trunk/yasm/; revision=517

modules/arch/x86/x86expr.c
src/arch/x86/x86expr.c

index 49ab69ba93dff249be7d3b31d1d43f013d77b5f4..64c10605b5fbdb5499091636ace55a0cc31650e6 100644 (file)
@@ -618,11 +618,12 @@ x86_expr_checkea(expr **ep, unsigned char *addrsize, unsigned char bits,
 
        /* First determine R/M (Mod is later determined from disp size) */
        *n_modrm = 1;   /* we always need ModRM */
-       if (basereg == REG32_NONE) {
-           /* disp32[index] */
+       if (basereg == REG32_NONE && indexreg == REG32_NONE) {
+           /* just a disp32 */
            *modrm |= 5;
-           /* we must have a SIB */
-           *n_sib = 1;
+           *sib = 0;
+           *v_sib = 0;
+           *n_sib = 0;
        } else if (indexreg == REG32_NONE) {
            /* basereg only */
            *modrm |= basereg;
@@ -635,7 +636,7 @@ x86_expr_checkea(expr **ep, unsigned char *addrsize, unsigned char bits,
                *n_sib = 0;
            }
        } else {
-           /* both base AND index */
+           /* index or both base and index */
            *modrm |= 4;
            *n_sib = 1;
        }
index 49ab69ba93dff249be7d3b31d1d43f013d77b5f4..64c10605b5fbdb5499091636ace55a0cc31650e6 100644 (file)
@@ -618,11 +618,12 @@ x86_expr_checkea(expr **ep, unsigned char *addrsize, unsigned char bits,
 
        /* First determine R/M (Mod is later determined from disp size) */
        *n_modrm = 1;   /* we always need ModRM */
-       if (basereg == REG32_NONE) {
-           /* disp32[index] */
+       if (basereg == REG32_NONE && indexreg == REG32_NONE) {
+           /* just a disp32 */
            *modrm |= 5;
-           /* we must have a SIB */
-           *n_sib = 1;
+           *sib = 0;
+           *v_sib = 0;
+           *n_sib = 0;
        } else if (indexreg == REG32_NONE) {
            /* basereg only */
            *modrm |= basereg;
@@ -635,7 +636,7 @@ x86_expr_checkea(expr **ep, unsigned char *addrsize, unsigned char bits,
                *n_sib = 0;
            }
        } else {
-           /* both base AND index */
+           /* index or both base and index */
            *modrm |= 4;
            *n_sib = 1;
        }