trip report: Tiny C Compiler 0.9.27 (Miscellaneous)
> 000: 89 08 mov %ecx,(%eax)> - 000: 8b 45 f8 mov -0x8(%ebp),%eax
> - 000: 89 45 f4 mov %eax,-0xc(%ebp)
> - 000: 8b 45 f8 mov -0x8(%ebp),%eax
> + 000: 8b 85 f8 ff ff ff mov -0x8(%ebp),%eax
> + 000: 89 85 f4 ff ff ff mov %eax,-0xc(%ebp)
> + 000: 8b 85 f8 ff ff ff mov -0x8(%ebp),%eax
>
> I guess i could try and figure out where those extra "ff ff ff" bytes are
> coming from.
The extra "ff ff ff" bytes are coming from i386-gen.c in the gen_modrm() function.
static void gen_modrm(int op_reg, int r, Sym *sym, int c)
{
...
if (c == (char)c) {
/* short reference */
o(0x45 | op_reg);
g(c);
} else {
oad(0x85 | op_reg, c);
}
When c = 0xfffffff8, TCC takes the "short reference" branch while Watcom takes the "else" branch. What is this if statement actually testing?
Here is the commit where the code in question came from:
https://repo.or.cz/tinycc.git?a=commit;h=21c35b94437178b4a9ee50e6688f259a6bcc26da
I can't say i completely understand it, but i've changed my sources to the following:
#ifdef __WATCOMC__
if (c == (signed char)c) {
#else
if (c == (char)c) {
#endif
/* short reference */
o(0x45 | op_reg);
g(c);
} else {
oad(0x85 | op_reg, c);
}
And now the bootstrapped compiler emits the same code as the reference compiler and it can self-host on DOS.
I'll continue testing it... Thanks for the help!
Complete thread:
- trip report: Tiny C Compiler 0.9.27 - bencollver, 04.02.2026, 17:02 (Miscellaneous)
![Open in board view [Board]](img/board_d.gif)
![Open in mix view [Mix]](img/mix_d.gif)
- trip report: Tiny C Compiler 0.9.27 - tkchia, 04.02.2026, 17:55
- trip report: Tiny C Compiler 0.9.27 - bencollver, 04.02.2026, 18:48
- trip report: Tiny C Compiler 0.9.27 - Japheth, 04.02.2026, 21:12
- trip report: Tiny C Compiler 0.9.27 - bencollver, 04.02.2026, 21:44
- trip report: Tiny C Compiler 0.9.27 - bretjohn, 05.02.2026, 22:24
- trip report: Tiny C Compiler 0.9.27 - Rugxulo, 05.02.2026, 23:09
- trip report: Tiny C Compiler 0.9.27 - bretjohn, 06.02.2026, 01:59
- trip report: Tiny C Compiler 0.9.27 - Rugxulo, 05.02.2026, 23:09
- trip report: Tiny C Compiler 0.9.27 - bencollver, 04.02.2026, 21:38
- trip report: Tiny C Compiler 0.9.27 - tkchia, 05.02.2026, 16:44
- trip report: Tiny C Compiler 0.9.27 - bencollver, 05.02.2026, 18:34
- trip report: Tiny C Compiler 0.9.27 - bencollver, 05.02.2026, 22:22
- trip report: Tiny C Compiler 0.9.27 - tkchia, 05.02.2026, 23:13
- trip report: Tiny C Compiler 0.9.27 - Rugxulo, 05.02.2026, 23:16
- trip report: Tiny C Compiler 0.9.27 - tkchia, 05.02.2026, 23:18
- trip report: Tiny C Compiler 0.9.27 - tkchia, 06.02.2026, 23:45
- trip report: Tiny C Compiler 0.9.27 - bencollver, 05.02.2026, 22:22
- trip report: Tiny C Compiler 0.9.27 - bencollver, 05.02.2026, 18:34
- trip report: Tiny C Compiler 0.9.27 - tkchia, 05.02.2026, 16:44
- trip report: Tiny C Compiler 0.9.27 - Japheth, 04.02.2026, 21:12
- trip report: Tiny C Compiler 0.9.27 - bencollver, 04.02.2026, 18:48
- trip report: Tiny C Compiler 0.9.27 - bencollver, 11.02.2026, 00:44
- trip report: Tiny C Compiler 0.9.27 - Rugxulo, 11.02.2026, 01:42
- trip report: Tiny C Compiler 0.9.27 - bencollver, 11.02.2026, 02:06
- trip report: Tiny C Compiler 0.9.27 - Rugxulo, 11.02.2026, 01:42
- trip report: Tiny C Compiler 0.9.27 - tkchia, 04.02.2026, 17:55
Mix view