Understanding What Instructions Your Old x86 CPU Supports
If you're experimenting with running software on an old x86 CPU, it helps to know precisely which instructions are available. This blog post walks through inspecting CPU instructions with a C utility, explains their significance, and clarifies which compiler flags to use so your software runs reliably.
Why CPU Instructions Matter
Modern software and operating systems increasingly rely on CPU instructions that didn't exist on older chips. For example:
- SSE/SSE2 instructions are quietly assumed by many Linux distributions and applications.
- Features like CMPXCHG8B and RDTSC are outright required by kernels and some programs.
- Missing SIMD or specific instructions can make multimedia or even standard code painfully slow.
By checking what instructions your processor supports, you avoid mysterious crashes, performance issues, or software that refuses to run.
Checking CPU Instructions with C Code
The following C program queries x86 feature bits using the CPUID instruction. It works on Linux and Windows, with either gcc or MSVC. Save it as i386cpufeatures.c:
1 | |
Example Output & What It Means
Here's output from an ancient x86 CPU:
1 | |
Let's break down the important bits:
- MMX: YES - Your CPU supports the earliest SIMD x86 instructions (late 1990s).
- SSE, SSE2: NO - Many modern Linux distros/apps require these, you don't have them.
- CMOV: YES - Essential for some security features and compilers.
- CMPXCHG8B: NO - Most 32-bit OSes (Win98/XP, modern Linux 32-bit) will not boot on this CPU.
- RDTSC: NO - Performance counters and some benchmarks will fail.
- No modern SIMD (SSE2/AVX/etc): Any modern multimedia code (audio, video, graphics) will be extremely slow.
- No POPCNT, AES-NI, AVX: No acceleration for cryptography, bit-counting, or modern scientific code.
Safe Compiler Flags for Your CPU
When building C/C++ code, choosing the right CFLAGS for your hardware prevents illegal instruction crashes. Here's a guide:
1. Minimal Safe CFLAGS
1 | |
- Targets CPUs with MMX and CMOV, but NOT SSE or SSE2.
2. Common Alternative Flags
-march=i686- Implies CMOV, but not MMX, SSE or SSE2.-march=pentium2- Safest for your old CPU: Only MMX and CMOV.-march=pentium3- Adds SSE (not supported on your CPU!)-march=pentium4- Requires SSE2 and SSE (not supported on your CPU!)
Important:
If you mistakenly use -march=pentium3 or newer, your binaries may crash with illegal instruction errors.