How can I create an executable .exe PE file manually?

后端 未结 7 1429
谎友^
谎友^ 2021-01-30 22:48

All texts on how to create a compiler stop after explaining lexers and parsers. They don\'t explain how to create the machine code. I want to understand the end-to-end process.<

7条回答
  •  广开言路
    2021-01-30 23:32

    Some information about making PE files as small as possible: Tiny PE.

    The minimalistic way to mess around with code generation, if you're just looking to try a few simple things out, is to output MS-DOS .COM files, which have no header or metadata. Sadly, you'd be restricted to 16-bit code. This format is still somewhat popular for demos.

    As for the instruction format, from what I recall the x86 instruction set is variable-length, including 1-byte instructions. RISC CPUs would probably have fixed-length instructions.

提交回复
热议问题