trip report: Tiny C Compiler 0.9.27 (Miscellaneous)
> The extra "ff ff ff" bytes are coming from i386-gen.c in the gen_modrm()
> function.
I assume this is just slightly smaller assembly code using signed byte instead of full dword offset.
> 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?
In C, char literals (and char arguments to string functions) are usually "int" (to also allow EOF, aka (int)-1).
Here it's probably checking whether the byte (char) is the same as the int, that the low byte of the int is the same as the char byte.
> I can't say i completely understand it, but i've changed my sources to the
> following:
>
> [code]
> #ifdef __WATCOMC__
> if (c == (signed char)c) {
I forget what OpenWatcom and DJGPP use by default for char. It might be "signed char". (I think K&R only introduced "unsigned" for int or long first.)
There should be a cmdline switch to toggle char signedness by default. I would assume using that (and avoiding a patch) is cleaner (assuming that doesn't break anything).
> And now the bootstrapped compiler emits the same code as the reference
> compiler and it can self-host on DOS.
I only barely run TCC under HXRT when needed (with old ReactOS MSVCRT.DLL).
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