开发者

Producing executables within Linux (in relation to implementing a compiler)

For my university, final-year dissertation, I am going to implement a compiler for a skeletal form of the C programming language, then go about extending it until it resembles something a little more like Java with array bounds checking, type-checking and so forth.

I am relatively competent at much of the theory that relates to compiler construction, and have experience programming in MIPS assembly language, so I do understand a little of what it is to write extremely low-level code.

My main concern is that I am likely to be able to get all the way to the point where I need to produce the actual machine-code output, but then not understand enough about how machine code is executed from the perspective of the operating system running it.

So, my actual question is basically, "does anyone know the best place to read up about writing assembly to run on an intel x86-64 processor under linux?"

The main gap in my knowledge is how the machine code is actually run in practise. Is it run directly on the processor, making "syscall"s (or the x86 equivalent) when it needs services provided by开发者_C百科 the kernel, or is the assembly language somehow an encapsulated description that tells the kernel how to execute the instructions (in a manner similar to an interpreted language such as Java)?

Any help you can provide would be greatly appreciated.


This document explains how you can implement a foreign function interface to interact with other code: http://www.x86-64.org/documentation/abi.pdf


Firstly, for the machine code start here: http://www.intel.com/products/processor/manuals/

Next, I assume your question about how the machine code is run is really about how the OS loads the exe into memory and calls main()? These links may help

Linkers and loaders: http://www.linuxjournal.com/article/6463

ELF file format: http://en.wikipedia.org/wiki/Executable_and_Linkable_Format and http://www.linuxjournal.com/article/1060

Your machine code will go into the .text section of the executable

Finally, best of luck. Your project is similar to my final year project, except I targeted the JVM and compiled a subset of Visual Basic!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜