hexratcc/baremetal — reverse-engineered prompt
Reverse engineered prompt
Build me a basic but serious x64 assembler in C++ with a small command line tool and tests. I want it to handle most normal x64 instructions plus AVX and AVX 512, and the syntax and instruction choices should feel very close to Nasm. It should support labels, memory defines, and out of order symbol definitions, then pick good encodings automatically.
Please include the main passes for optimization and emission, especially control flow graph analysis, instruction size minimization, symbolic size minimization, raw binary output, and a Graphviz style CFG dump. ELF output can be started but it is okay if it is clearly marked as work in progress.
Set it up so I can generate build files, compile it, and run a test suite easily, with a few example assembly cases in the tests. If some encoding tests need Nasm to verify output, wire that in too. Keep the code organized and make the error messages reasonably helpful. Look up current docs online if you need to.
Want more depth? Deep Reverse