Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6064009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:14:00+00:00 2026-05-23T09:14:00+00:00

I was looking up the pypy project (Python in Python), and started pondering the

  • 0

I was looking up the pypy project (Python in Python), and started pondering the issue of what is running the outer layer of python? Surely, I conjectured, it can’t be as the old saying goes “turtles all the way down”! Afterall, python is not valid x86 assembly!

Soon I remembered the concept of bootstrapping, and looked up compiler bootstrapping. “Ok”, I thought, “so it can be either written in a different language or hand compiled from assembly”. In the interest of performance, I’m sure C compilers are just built up from assembly.

This is all well, but the question still remains, how does the computer get that assembly file?!

Say I buy a new cpu with nothing on it. During the first operation I wish to install an OS, which runs C. What runs the C compiler? Is there a miniature C compiler in the BIOS?

Can someone explain this to me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:14:00+00:00Added an answer on May 23, 2026 at 9:14 am

    Say I buy a new cpu with nothing on it. During the first operation I wish to install an OS, which runs C. What runs the C compiler? Is there a miniature C compiler in the BIOS?

    I understand what you’re asking… what would happen if we had no C compiler and had to start from scratch?

    The answer is you’d have to start from assembly or hardware. That is, you can either build a compiler in software or hardware. If there were no compilers in the whole world, these days you could probably do it faster in assembly; however, back in the day I believe compilers were in fact dedicated pieces of hardware. The wikipedia article is somewhat short and doesn’t back me up on that, but never mind.

    The next question I guess is what happens today? Well, those compiler writers have been busy writing portable C for years, so the compiler should be able to compile itself. It’s worth discussing on a very high level what compilation is. Basically, you take a set of statements and produce assembly from them. That’s it. Well, it’s actually more complicated than that – you can do all sorts of things with lexers and parsers and I only understand a small subset of it, but essentially, you’re looking to map C to assembly.

    Under normal operation, the compiler produces assembly code matching your platform, but it doesn’t have to. It can produce assembly code for any platform you like, provided it knows how to. So the first step in making C work on your platform is to create a target in an existing compiler, start adding instructions and get basic code working.

    Once this is done, in theory, you can now cross compile from one platform to another. The next stages are: building a kernel, bootloader and some basic userland utilities for that platform.

    Then, you can have a go at compiling the compiler for that platform (once you’ve got a working userland and everything you need to run the build process). If that succeeds, you’ve got basic utilities, a working kernel, userland and a compiler system. You’re now well on your way.

    Note that in the process of porting the compiler, you probably needed to write an assembler and linker for that platform too. To keep the description simple, I omitted them.

    If this is of interest, Linux from Scratch is an interesting read. It doesn’t tell you how to create a new target from scratch (which is significantly non trivial) – it assumes you’re going to build for an existing known target, but it does show you how you cross compile the essentials and begin building up the system.

    Python does not actually assemble to assembly. For a start, the running python program keeps track of counts of references to objects, something that a cpu won’t do for you. However, the concept of instruction-based code is at the heart of Python too. Have a play with this:

    >>> def hello(x, y, z, q):
    ...     print "Hello, world"
    ...     q()
    ...     return x+y+z
    ... 
    >>> import dis
    dis.dis(hello)
    
    
      2           0 LOAD_CONST               1 ('Hello, world')
                  3 PRINT_ITEM          
                  4 PRINT_NEWLINE       
    
      3           5 LOAD_FAST                3 (q)
                  8 CALL_FUNCTION            0
                 11 POP_TOP             
    
      4          12 LOAD_FAST                0 (x)
                 15 LOAD_FAST                1 (y)
                 18 BINARY_ADD          
                 19 LOAD_FAST                2 (z)
                 22 BINARY_ADD          
                 23 RETURN_VALUE
    

    There you can see how Python thinks of the code you entered. This is python bytecode, i.e. the assembly language of python. It effectively has its own “instruction set” if you like for implementing the language. This is the concept of a virtual machine.

    Java has exactly the same kind of idea. I took a class function and ran javap -c class to get this:

    invalid.site.ningefingers.main:();
      Code:
       0:   aload_0
       1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
       4:   return
    public static void main(java.lang.String[]);
      Code:
       0:   iconst_0
       1:   istore_1
       2:   iconst_0
       3:   istore_1
       4:   iload_1
       5:   aload_0
       6:   arraylength
       7:   if_icmpge   57
       10:  getstatic   #2; 
       13:  new #3; 
       16:  dup
       17:  invokespecial   #4; 
       20:  ldc #5; 
       22:  invokevirtual   #6; 
       25:  iload_1
       26:  invokevirtual   #7; 
       //.......
    }
    

    I take it you get the idea. These are the assembly languages of the python and java worlds, i.e. how the python interpreter and java compiler think respectively.

    Something else that would be worth reading up on is JonesForth. This is both a working forth interpreter and a tutorial and I can’t recommend it enough for thinking about “how things get executed” and how you write a simple, lightweight language.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for resources that can help getting 'into' the Linux code. Could not get
Looking for an structure of how to build a group inside pool of a
Looking for this session identifier for logging purposes...
Looking at developing an iphone app for the first time upon Windows. I have
looking for a large file upload solution on MVC3. There's a few examples in
Looking for a way to wrap words that have been enterd in a text
Looking for a jQuery ninja's assistance. My jQuery below works but I have a
looking a way to make a toggle on doubleclick, this is my code: $('#mydiv').toggle(function()
Looking for a code optimization in c# that allows me to both define an
Looking at this CoffeeScript tutorial : http://jashkenas.github.com/coffee-script/ I don't quite see what the Splats

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.