[Nasm-bugs] [Bug 3392480] macro CPU doesn't work as expected.

noreply-nasm at gorcunov.org noreply-nasm at gorcunov.org
Sat May 12 08:33:23 PDT 2018


https://bugzilla.nasm.us/show_bug.cgi?id=3392480

--- Comment #2 from fullofbug at gmail.com ---
I looked in to the source code of different versions and found that the stab;e
v2.14rc0 changed get_cpu() and removed any/all/other. But the newest
nasm-2.14rc0-20180508 restored it to be the same as v2.13.03. Can you please
change the function to be the following:

static iflag_t get_cpu(const char *value)
{
    iflag_t r;
    const struct cpunames *cpu;
    static const struct cpunames cpunames[] = {
        { "8086", IF_8086 },
        { "186",  IF_186  },
        { "286",  IF_286  },
        { "386",  IF_386  },
        { "486",  IF_486  },
        { "586",  IF_PENT },
        { "pentium", IF_PENT },
        { "pentiummmx", IF_PENT },
        { "686",  IF_P6 },
        { "p6",   IF_P6 },
        { "ppro", IF_P6 },
        { "pentiumpro", IF_P6 },
        { "p2", IF_P6 },        /* +MMX */
        { "pentiumii", IF_P6 },
        { "p3", IF_KATMAI },
        { "katmai", IF_KATMAI },
        { "p4", IF_WILLAMETTE },
        { "willamette", IF_WILLAMETTE },
        { "prescott", IF_PRESCOTT },
        { "nehalem", IF_NEHALEM },
        { "westmere", IF_WESTMERE },
        { "sandybridge", IF_SANDYBRIDGE },
        { "x64", IF_X86_64 },
        { "x86-64", IF_X86_64 },
        { "ia64", IF_IA64 },
        { "ia-64", IF_IA64 },
        { "itanium", IF_IA64 },
        { "itanic", IF_IA64 },
        { "merced", IF_IA64 },
        { "any", IF_PLEVEL },
        { "default", IF_PLEVEL },
        { "all", IF_PLEVEL },
        { NULL, IF_PLEVEL }     /* Error and final default entry */
    };

    iflag_clear_all(&r);

    for (cpu = cpunames; cpu->name; cpu++) {
        if (!stricmp(value, cpu->name))
            break;
    }

    if (!cpu->name) {
        nasm_error(pass0 < 2 ? ERR_NONFATAL : ERR_FATAL,
                   "unknown 'cpu' type '%s'", value);
    }

    iflag_set_cpu(&r, cpu->level);
    return r;
}

I added three more CPU IDs (nehalem, westmere and sandybridge) and made the
comparison case insensitive by changing strcmp to stricmp.
It will be nice to add Haswell as well, but it requires changing the
instruction table.
Thank you!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.


More information about the Nasm-bugs mailing list