News for hackers. Stuff that matters.
Re:Can a LLM convert C, to ASM to specs and then to a workin... by WalterBright on Monday March 17, 2025 @01:06PM (#43390572)
I've done three major conversions of assembly to C:

1. My Empire game was written in assembler on the PDP-11. To port it to the IBM PC, I rewrote it line by line into C.

2. FutureNet's schematic editor for the IBM PC was a very large assembler program. It was written in assembler because there was no other way to make it fit on the PC. I converted it line by line into C so it would run on a Sun. It took a couple months.

3. I converted some of the Optlink linker, a 32 bit Windows linker, into C. The main difficulty, though, was there was no test suite and it was very very hard to get right. I got maybe 10% of it converted. I eventually abandoned the project because 32 bit Windows code is now obsolete. The other hard part of the project was it was not conventionally divided up into functions. Code would jump into the middle of other functions. Another problem with it was its use of macros and conditional assembly was so hard to decipher that I would assemble the code, run it through my disassembler, and use the latter as my starting point. (Macros are Spawn of the Devil.)

Re:Can a LLM convert C, to ASM to specs and then to a workin... by djmips on Tuesday March 18, 2025 @04:18AM (#43396839)
Macros are the original Spawn of the Devil and their descendants are template metaprogramming.
Re:Can a LLM convert C, to ASM to specs and then to a workin... by WalterBright on Tuesday March 18, 2025 @11:16AM (#43400461)
Template metaprogramming can be abused, too. Expression templates come to mind. You can do expression templates in D, but I have discouraged it and it has not caught on to my relief.

But templates still are a better choice than macros.

Re:Can a LLM convert C, to ASM to specs and then to a workin... by djmips on Tuesday March 18, 2025 @11:41AM (#43400772)
I would have thought so but fast forward to today and we have template abuse that cause very long build times and creates gigabytes of symbols that flood memory and crash compilers and take debuggers to their knees and create the most inscrutable code to read and debug that MACRO jockeys could never have dreamed of.

I'm working on a C++ project where maintainers have had to resort to changing namespaces to single letters as a grotesque stop gap against the symbol table explosion!