Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't see any assembly code for a self-hosting compiler #91

Open
0decimal0 opened this issue Sep 11, 2017 · 4 comments
Open

Can't see any assembly code for a self-hosting compiler #91

0decimal0 opened this issue Sep 11, 2017 · 4 comments

Comments

@0decimal0
Copy link

A self-hosting compiler involves writing a rudimentary compiler for a language X(Here C) in another language (Suppose assembly), I can't find any assembly or any other language used for compiling a code . I have been googling my wits out to find at least a simple guide to write a compiler in assembly for C language . Your blog is the closest one I found but still I don't see any .

@andrewchambers
Copy link
Contributor

it needs to be bootstrapped with an existing compiler, once that is done you can use 8cc to compile 8cc and can forget about the existing compiler. that is what is meant by self hosted.

@moon-chilled
Copy link

Here's an idea. Write a compiler for a very simple, minimal language in asm. Then use that language to write a compiler for a slightly more complex language with more abstractions. Then write your C compiler in that. The way 8cc can be bootstrapped, is by using gcc or clang, since those already exist. You could also ask this guy.

@0decimal0
Copy link
Author

Thanks Elronnd. I knew this way , was just looking for assembly code(using which a c compiler has been implemented) to read . There are a lot of self hosted compiler code but I could not find in an assembly lang.

@cardiffman
Copy link

@0decimal0 Your definition of self-hosting is not the one I have seen for years [https://en.wikipedia.org/wiki/Self-hosting_(compilers)](Wikipedia definition and history of the term). Bootstrapping is the name of the process for getting a compiler to run on and for a target machine. Sometimes people bootstrap starting with assembly, others start by cross-compiling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants