Instruction
FIST
Converts ST(0) to a 16- or 32-bit signed integer, rounded as the control word says, and stores it in memory.
- Extensions
- Forms
- 2 (2 Legacy)
- Data
- Intel XED v2026.08.23
FIST converts ST(0) to a signed 16- or 32-bit integer and stores it, leaving the register stack as it was. FISTP does the same and pops, and only FISTP has a 64-bit form. Both round as RC says, to nearest even unless code changes it, and both store the integer indefinite when the value does not fit; FISTP’s page covers casts, which truncate, and the out-of-range rules.
When the value stays
Compilers emit FIST where ST(0) is still needed after the store. With
-fno-math-errno, GCC 14 at -O2 compiles *a = __builtin_irintl(x); *b = x; on a long double to FLD of x, fist DWORD PTR [rdi] and
fstp TBYTE PTR [rsi]. A 64-bit long from lrintl cannot use it:
in the same code GCC and Clang 23 copy the register with fld st(0)
and store the copy with fistp QWORD PTR. In 32-bit code, where long
has 32 bits, both use fist DWORD PTR there.
Rounding and C1
Zen 5 stored 2 for 2.5 and -2 for -2.5 under rounding to nearest, and 0 for -0.5, since an integer has no -0. Each of these set PE. C1 says whether the magnitude was rounded up: 1.5 to 2 and -1.5 to -2 set it, 2.5 to 2 left it clear, and so did -0.5 to 0.
The ends of the range
Whether a value fits is decided after rounding, so RC matters at the edges. 2147483647.5 rounds to 2^31 under rounding to nearest, which does not fit, and gave the indefinite 80000000H with IE; toward zero it gave 2147483647. -2147483648.5 went the other way: -2147483648 with PE to nearest, the indefinite with IE when rounding down. The 16-bit form did the same with 32767.5 and -32768.5.
With IE masked, an empty ST(0) also stores the indefinite, with SF set. With IE unmasked, nothing is stored. An unmasked PE does not stop the store: Zen 5 stored 2 for 2.5, and the #MF came at the FWAIT that the probe runs after each x87 case.
AMD’s Zen 5 guide lists FIST as two macro-ops, one per cycle.
Forms
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
if empty(st0):
underflow()
v = INDEFINITE
else:
v = st0
r = cvt_int(v, dest.bits) # rounded by RC; a NaN, an
# infinity or a number out of
# range gives the integer
# indefinite, with IE
dest.write(r)
c0 = c2 = c3 = UNDEFINEDRun on AMD Zen 5 (EPYC 9645): 64 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
FIST m16int FIST m32int | ||
m16/32int | explicit | write |
x87 status word | implicit | write |
Flags
| C0 | C1 | C2 | C3 |
|---|---|---|---|
| All forms | |||
| U | M | U | U |
Attributes
What else XED records about the forms. How to read.
- All forms
- may abort a TSX transaction
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
X87 | FPU | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More x87 instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-347 (FIST/
FISTP) - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 5: 64-Bit Media and x87 Floating-Point Instructions (26569, rev. 3.16, November 2021), Wayback Machine copy of AMD's PDF
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The text is our own.