|
This was discovered while trying some fasmg work with ai, and the report is written by ai.
Subject: 80386.inc assembles POPFD as 9Ch (PUSHFD's opcode)
fasmg version g.l8vn (repository state 126aaa2, 2026-07-19).
In the 80386 instruction set include, POPFD is listed with opcode 9Ch,
which is PUSHFD's opcode. It should be 9Dh.
Where:
core/examples/x86/include/80386.inc, line 2166
packages/x86/include/cpu/80386.inc, line 2192
Both lines read:
iterate <instr,opcode>, cwde,98h, cdq,99h, iretd,0CFh, pushad,60h,
popad,61h, pushfd,9Ch, popfd,9Ch, \
x64.inc (line 2826) and x86-2.inc (line 3171) have popfd,9Dh, which is
correct.
To see it:
include '80386.inc'
use32
pushfd
popfd
pushf
popf
use16
popfd
Bytes produced:
9C 9C 9C 9D 66 9C
Expected:
9C 9D 9C 9D 66 9D
Effect: code that saves the flags with PUSHFD and restores them with
POPFD pushes them a second time instead, so the flags are never
restored and the stack is off by 4 bytes. Writing POPF in 32-bit code
works around it (it gives 9Dh, which pops 32 bits there).
Suggested fix: change popfd,9Ch to popfd,9Dh on both lines.
|