x87: doesn't model C2 change of fprem
- Dominant language
- C++
- Stars
- 8.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Subject: https://github.com/rfalke/decompiler-subjects/blob/master/from_holdec/i386_x87_fpu/ia32_elf/subject.exe
Output:
```
int32_t FPREM(int32_t a1) {
...
float80_t v1 = (int64_t)a1; // 0x804abc9
v1 %= 6.283185307179586232L;
__asm_wait();
while ((__asm_wait() & 1024) != 0) {
// 0x804abcb
v1 %= 6.283185307179586232L;
__asm_wait();
}
float64_t v2 = v1; // 0x804abd6
printf("reduced para using FPREM: should= is=%12f/%15e\n", v2, v2);
return 0;
}
```
fwait (aka __asm_wait) doesn't define the c2 flag. `fprem` does: "Set to 0 if reduction complete; set to 1 if incomplete." So the loop condition is wrong.
Source for the loop and background: http://www.website.masmforum.com/tutorials/fptute/fpuchap12.htm
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the FPREM output in the linked decompiler-subjects subject.exe example and compare the loop with the linked x87 background reference. Trace how fprem and __asm_wait are represented, then verify that the generated loop reflects fprem's C2 status and its complete/incomplete reduction meaning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- reverse-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100