X86 coding - compiler code generation

Is there a good reference for writing code in x86 assembly. I am writing a compiler, and now I am at the stage of code generation. The language I implement is Object Oriented. For example, now I’m having trouble recording an assembly for class declarations, object mock-ups, etc ... is there any book or background information that covers this topic?

+4
source share
2 answers

architecture reference documentation is your best bet.

However, do not expect any help for class declarations or much for object mockups. The compiled language specification will have some of them, but the machine code generated for class declarations is very loosely coupled to the language and is largely the choice of the developer rather than the CPU architecture.

+2
source

There may be β€œdirect” and β€œuseful” answers to your question, and they are probably incompatible.

The direct answer is that you must combine the architecture reference (see the link in the previous answer) with the details of the specific assembler that you have chosen for this - for example. gas, nasm, yasm, fasm, masm [32], tasm, etc .; they all have links to the syntax of instructions, pseudo-instructions (like segmentation, memory allocation, etc.), implementation details, object file format ...

The helpful answer (jIMHO) is that duplicating the results of industry leaders, such as the GNU compiler compilation, Microsoft Developer Studio, etc., takes thousands of person-years, so this is a rather strange way; instead, you should use existing measures as much as possible. For example, to check the concept of your language, you can implement a converter for C code and a support library for this. Or write for a famous virtual machine and its language like Java or C #. At an advanced level, you can replace the compiler external interface with your own (like GCC and LLVM), and reuse your code generators that are well written and tuned for several purposes.

I doubt very much that you are developing something that cannot be converted to C and support library calls. Intermediate code should not look beautiful, it should work.

If you still want to make the sunset manually, please edit the question with detailed information about the target platform (Windows / Linux / etc., 16- 32- or 64-bit ...)

0
source

Source: https://habr.com/ru/post/1403274/


All Articles