Thread: Can we talk about compilers?

  1. #31
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Debating with myself whether this is a contradiction or a paradox.
    O_o

    Enigma.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  2. #32
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Mario F. View Post
    Debating with myself whether this is a contradiction, a paradox, or a tail between the legs.
    ... or all of those at once.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #33
    Citizen of Awesometown the_jackass's Avatar
    Join Date
    Oct 2014
    Location
    Awesometown
    Posts
    269
    Looks like you all scared MutantJohn (and ME xD) with all your highbrow talk. I believe a *very basic* VM problem could have been described to him in a much more easy way. (Confession: I know next to nothing about VMs, except having made a scripting language that Really Really Sucks).

  4. #34
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    I think my fundamental question was, how do you write an executable?

    Is it really as simple as just opening a binary file and writing to it? That sounds almost too easy. I'm just curious, what do you write to it? Do you have an external table with a list of instructions available for the architecture? Like, you would parse the source and break it down and you have a basic set of instructions in a certain order. Is all you do then really just look up which assembly commands would be required and then write them to a binary file?

    That sounds kind of easy. Which is why I think I can't be right which I know sounds weird but I've learned never to trust my own brain.

  5. #35
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    It's actually only a little more complicated than that. An executable tends to have several sections, including at least the following: code, read-only static data, and read-write static data. String constants often go in read-only data, unless they are used to initialize a writable char array. The executable also includes a table, whose location is known to the operating system, that defines where in the file all these sections are. The operating system loads the table, and then loads the various sections into their appropriate regions in memory.
    Last edited by Elkvis; 10-14-2014 at 10:58 AM.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  6. #36
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    That sounds kind of easy.
    O_o

    In the early days of some "DOS" (286?) systems, you could use the keyboard to directly write a headless binary (a COM variant) file to print a smiley face character. The binary was literally six or seven bytes.

    *shrug*

    Compared to optimizing, parsing and code generation really aren't that difficult at all.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  7. #37
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by MutantJohn View Post
    I think my fundamental question was, how do you write an executable?
    See PE and ELF. In that order, since the Portable Executable article is more extensive and better describes the purpose of an executable format. In short an executable must obey a rigid file format in order for the embedded instructions to be executed by the operating system. An executable is thus a file format no different than an image file, or a PDF file format. The distinguishing factor is that the operating system recognizes that format out of the box and knows it has to map the file onto memory and process its instructions.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Do I talk too much?
    By GoodStuff in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-20-2003, 10:45 PM
  2. Who wants to talk on AIM?
    By Death Wish in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 07-05-2002, 06:29 AM