News for hackers. Stuff that matters.
Re:Show HN: A simple way to write standalone C programs for ... by rwmj on Wednesday October 02, 2019 @08:45AM (#21135759)
No, he's using -m16 -march=i386 which creates 32 bit code that boots in 16 bit mode using the 32 bit size prefix on most instructions, and that will only work on 80386 and above.
Re:Show HN: A simple way to write standalone C programs for ... by jacobush on Wednesday October 02, 2019 @10:29AM (#21136822)
This is so insane, I had no idea such a thing was possible:

16 vs 32 bit It is possible to use 32-bit instructions in the real-address mode, they just need to be marked with address-size and operand-size prefixes. The -m16 option for clang/gcc, and .code16 directive in GNU assembler, do exactly that. The resulting code is 32-bit, only marked everywhere with those prefixes. It's not compatible with actual 16-bit CPUs.

"Unfortunately the 32-bit addresses still cannot exceed the boundary of the segment (65535), otherwise they'll trigger an exception. QEMU doesn't emulate this behaviour, so it's useful to occasionally test with Bochs."