Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Could you compile a program manually?

Could you compile a program manually?

Scheduled Pinned Locked Moved The Lounge
c++question
43 Posts 26 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Roger Wright

    It can be done, but it will take some time. Here's a manual[^].

    Will Rogers never met me.

    M Offline
    M Offline
    Member 110323
    wrote on last edited by
    #23

    Ah, the memories! First did this when my computer had a 16 bit address bus and 8 bit op-codes and a total of 4K of RAM. Then I discovered there was something called a "compiler" and haven't had the urge to engage in this kind of masochism since.

    R 1 Reply Last reply
    0
    • B Brandon X12000

      Is there some way to process a source-to-executable like a computer by hand? If so, could you point to some documents? Could you also compile a device driver source to ".sys" or ".vxd" (depending whether you are developing for a non-NT or NT Windows operating system)?

      Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

      N Offline
      N Offline
      Norm Powroz
      wrote on last edited by
      #24

      I used to do this all the time in my mainframe days. Operating systems used to be written in assembler, and the only way to correct bugs or add extensions on the fly was to hand-assemble the code into pure machine code. One system I supported for a number of years had an on-line patcher so you could patch the O/S while the system was up and running. I used to give the operations staff hairy fits when I did this ;) Just to show how big some leaps can be -- I went from an all-assembler O/S to a machine whose O/S was written in PL/1. An interesting leap indeed, especially since the source code of the PL/1 O/S was all on-line, so you could use parts of it in your own applications.

      1 Reply Last reply
      0
      • B Brandon X12000

        Is there some way to process a source-to-executable like a computer by hand? If so, could you point to some documents? Could you also compile a device driver source to ".sys" or ".vxd" (depending whether you are developing for a non-NT or NT Windows operating system)?

        Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

        G Offline
        G Offline
        gggustafson
        wrote on last edited by
        #25

        Many years ago, while teaching at a local college and working as an architect for a new database system, I decided to write the compiler I was requiring my students to write. At that time, I was considered a good assembler programmer. I decided to compare the output of the compiler I wrote with my own hand-coded assembly. As I recall, my assembly contained about 15 instructions; the compiler's generated assembly code contained 8 instructions. I learned a valuable lesson.

        Gus Gustafson

        1 Reply Last reply
        0
        • B Brandon X12000

          Is there some way to process a source-to-executable like a computer by hand? If so, could you point to some documents? Could you also compile a device driver source to ".sys" or ".vxd" (depending whether you are developing for a non-NT or NT Windows operating system)?

          Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

          P Offline
          P Offline
          patbob
          wrote on last edited by
          #26

          Of course you can. The act of compiling is simply a translation between the chacters you typed into a file and the sequence of binary bytes that need to get fed to the CPU for execution. The .sys or .vxd is merely a file format. All are documented. As for pointers to documents? Sorry, can't help you there.. I haven't cared about such documents for more than 20 years. Translating something like C++ to assembly is tedious at best. It would be quicker to do what the compiler cannot do -- take your knowledge of the desired behavior of the program, and write an assembly progam directly to accomplish the same task. Translating assembly to binary object code is a very simple per-instruction translation (well, it used to be.. but its a bit more complex now). The question is why? Why do you want to do that? If it is just to learn the process, its easier to take a compiler course as it'll start from basic concepts, evolving them into running code. It will be a lot easier to understand how a compiler works coming at it that way than trying to start with the 1s and 0s. You'll get lots of practice walking through all the steps of compilation along the way. Assembly is too easy to justify a course -- just grab an assembly manual for your processor of choice and read through it.

          We can program with only 1's, but if all you've got are zeros, you've got nothing.

          1 Reply Last reply
          0
          • B Brandon X12000

            Is there some way to process a source-to-executable like a computer by hand? If so, could you point to some documents? Could you also compile a device driver source to ".sys" or ".vxd" (depending whether you are developing for a non-NT or NT Windows operating system)?

            Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

            B Offline
            B Offline
            BrainiacV
            wrote on last edited by
            #27

            When I was in high school I used to hand assemble a lot of programs. We only had access to the computers during school hours. In Print Shop, I created forms to write the source code on and left myself a column to write the opcodes into as well. But then I was programming DEC PDP-8's and they used 12 bit words with the first octal digit being the opcode, the rest being addressing. The operate commands were a bit trickier, but there was a rhyme and reason for most the bit settings, the rest you memorized. Used to do the same for multi-byte 6502, but today's 80x86 (if that still the term) multi-byte commands would be much, much harder.

            Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.

            1 Reply Last reply
            0
            • _ _beauw_

              When I look at some of the pie-in-the-sky news items about things like automatic parallelization, I get the sense that we are alarmingly close to the day when an animated character in an IDE says things like "it looks like you're trying to write an OS." I think this kind of thing is an example of what I call the "Hero Anti-Pattern," in which one supposedly brilliant developer abstracts everything (garbage collection, parallelization, "plumbing" code...) away from the rest of us. My gut tells me that self-proclaimed geniuses toiling away in a vacuum will probably never really keep the rest of us from having to worry about whatever it is they're trying to fix. Instead, what results is that these people get to shape the future of development, and rake in the concomitant glory and cash, while the rest of us just end up doing the same tasks (albeit in Hero-ized form).

              S Offline
              S Offline
              SeattleC
              wrote on last edited by
              #28

              The end result of this abstraction cycle is an AI developer. You speak into the microphone, "Siri, write me an Accounts Receivable program." 'She' answers, "OK. How many accounts will you want to manage?" If anyone reading this post isn't frightened about the future of their career, or of the human race for that matter, you aren't paying attention. I'm glad I'm not just starting out my career.

              Z 1 Reply Last reply
              0
              • S SeattleC

                The end result of this abstraction cycle is an AI developer. You speak into the microphone, "Siri, write me an Accounts Receivable program." 'She' answers, "OK. How many accounts will you want to manage?" If anyone reading this post isn't frightened about the future of their career, or of the human race for that matter, you aren't paying attention. I'm glad I'm not just starting out my career.

                Z Offline
                Z Offline
                Zan Lynx
                wrote on last edited by
                #29

                There will always be a job for software people. That program written by the AI? The AI is no more able to solve the Halting Problem than you are. It cannot foresee the entire range of possible problems and world interactions. So that accounts package it just wrote will need to be fixed when it has mysteriously slow performance on your new SSD storage. It might crash on the first Tuesday after a leap second. Things will need to be fixed when the database and the web frontend disagree on the proper UTF-8 encoding. And it'll probably only work correctly when you use all Microsoft, Google or Apple products of the newest revision. God help the office that has a mixture or has to support old Windows XP desktops! I foresee AI programming making the easy things really easy, leaving us to solve the difficult problems. As an example, CPU design software has made a lot of what designers used to obsolete. But it hasn't resulted in fewer engineers: they just spend their time designing even larger and more complicated chips.

                S 1 Reply Last reply
                0
                • B Brandon X12000

                  Is there some way to process a source-to-executable like a computer by hand? If so, could you point to some documents? Could you also compile a device driver source to ".sys" or ".vxd" (depending whether you are developing for a non-NT or NT Windows operating system)?

                  Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                  E Offline
                  E Offline
                  Earl Truss
                  wrote on last edited by
                  #30

                  Yes, I suppose you could but it's not cost-effective. That's what compilers and assemblers are for. I've done it but only for very small sections of assembly code, never a high-level language. One case was where I had the binary firmware and the source code but no assembler and I had to do a patch to fix a timing problem.

                  1 Reply Last reply
                  0
                  • Z Zan Lynx

                    There will always be a job for software people. That program written by the AI? The AI is no more able to solve the Halting Problem than you are. It cannot foresee the entire range of possible problems and world interactions. So that accounts package it just wrote will need to be fixed when it has mysteriously slow performance on your new SSD storage. It might crash on the first Tuesday after a leap second. Things will need to be fixed when the database and the web frontend disagree on the proper UTF-8 encoding. And it'll probably only work correctly when you use all Microsoft, Google or Apple products of the newest revision. God help the office that has a mixture or has to support old Windows XP desktops! I foresee AI programming making the easy things really easy, leaving us to solve the difficult problems. As an example, CPU design software has made a lot of what designers used to obsolete. But it hasn't resulted in fewer engineers: they just spend their time designing even larger and more complicated chips.

                    S Offline
                    S Offline
                    SeattleC
                    wrote on last edited by
                    #31

                    Zan Lynx wrote:

                    There will always be a job for software people. The AI is no more able to solve the Halting Problem than you are.

                    Once the AI is approximately as capable as a developer, it can fix its own bugs, which of course are unstated requirements as far as the machine is concerned. Just like with human developers, the fix may introduce new problems. Just like with human developers, the quality of the code may be high or low. The AI can also tinker with its own code. In the end game, an AI can replace us; first poorly, later better, finally completely. Remind me again why anyone with sense would work on such a program. It may seem ok when the goal is far away. I hope we wise up.

                    1 Reply Last reply
                    0
                    • L Lost User

                      Brandon T. H. wrote:

                      Is there some way to process a source-to-executable like a computer by hand?

                      Yes (well duh, computers can't compute anything that humans can't, they're just faster at it), and it's not even that hard (just time-consuming). Converting whatever-language source to assembly? Piece of cake. Assembling by hand? Conceptually simple, only requires looking things up in a table. Putting it in the right executable format? Ok that one is a little tricky to get right, but also not that hard.

                      Brandon T. H. wrote:

                      If so, could you point to some documents?

                      Sure. For x86+windows: Intel manuals[^] ModRM encoding (on sandpile.org)[^] PE 101[^]

                      Brandon T. H. wrote:

                      Could you also compile a device driver source to ".sys" or ".vxd"

                      I see no reason why this should be impossible.

                      B Offline
                      B Offline
                      Brandon X12000
                      wrote on last edited by
                      #32

                      Thank you. :cool:

                      Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                      1 Reply Last reply
                      0
                      • S Sentenryu

                        remember me to get you a 5 when the vote system gets back online, you deserve it.

                        I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

                        B Offline
                        B Offline
                        Brandon X12000
                        wrote on last edited by
                        #33

                        Sentenryu wrote:

                        when the vote system gets back online

                        What happened to that thing anyways :~, even though this has nothing to do with compiling by hand. It's been a while.

                        Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                        1 Reply Last reply
                        0
                        • L Lost User

                          Yes, you just need to convert each line of source code into its object code equivalent. Once you have done that you build it into a binary file with a hex editor and, hey presto, Robert's your mother's brother.

                          One of these days I'm going to think of a really clever signature.

                          B Offline
                          B Offline
                          Brandon X12000
                          wrote on last edited by
                          #34

                          Thanks man.

                          Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                          1 Reply Last reply
                          0
                          • I Isfeasachme

                            Sage advice... Pssh. Ya junior code snot. I'm glad I'm not the only assembler dork out there. This is the sort of question asked by people who end up designing the compilers you all use.

                            B Offline
                            B Offline
                            Brandon X12000
                            wrote on last edited by
                            #35

                            My man, haha.

                            Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                            1 Reply Last reply
                            0
                            • I Isfeasachme

                              Sage advice... Pssh. Ya junior code snot. I'm glad I'm not the only assembler dork out there. This is the sort of question asked by people who end up designing the compilers you all use.

                              B Offline
                              B Offline
                              Brandon X12000
                              wrote on last edited by
                              #36

                              My man, ha ha.

                              Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                              1 Reply Last reply
                              0
                              • A AspDotNetDev

                                You have exceeded your one-silly-question-a-day-in-the-Lounge limit.

                                Thou mewling ill-breeding pignut!

                                B Offline
                                B Offline
                                Brandon X12000
                                wrote on last edited by
                                #37

                                Thanks for the info..

                                Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                                1 Reply Last reply
                                0
                                • B Brady Kelly

                                  Brandon T. H. wrote:

                                  Is there some way to process a source-to-executable like a computer by hand?

                                  Only in a Chinese Room.

                                  B Offline
                                  B Offline
                                  Brandon X12000
                                  wrote on last edited by
                                  #38

                                  Yeah, Chinese people are crazy. It's like a drill sergeant yelling at you to think out a bunch of one's and zero's, instead of them telling you to do push-ups. Still doing this a programmer's nightmare. To the average person it's hell. :laugh:

                                  Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                                  1 Reply Last reply
                                  0
                                  • P Paul Conrad

                                    You could, but why?

                                    "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

                                    B Offline
                                    B Offline
                                    Brandon X12000
                                    wrote on last edited by
                                    #39

                                    It would help be able to do anything, just think how useful it would be. You would be able do anything just about any computer or machine, and what you program, works on about almost any piece of hardware, when you boot it. Like all of a suddenly the C language dies.

                                    Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                                    P I 2 Replies Last reply
                                    0
                                    • B Brandon X12000

                                      It would help be able to do anything, just think how useful it would be. You would be able do anything just about any computer or machine, and what you program, works on about almost any piece of hardware, when you boot it. Like all of a suddenly the C language dies.

                                      Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                                      P Offline
                                      P Offline
                                      Paul Conrad
                                      wrote on last edited by
                                      #40

                                      Brandon T. H. wrote:

                                      just think how useful it would be

                                      Not really at all from the stand point of time efficiency. I do trust that you do know what a compiler is.

                                      Brandon T. H. wrote:

                                      Like all of a suddenly the C language dies

                                      And why would that be an issue? When a language becomes outdated and replaced with something new, the world still goes on, and code in any language can easily be rewritten in another language.

                                      "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

                                      1 Reply Last reply
                                      0
                                      • M Member 110323

                                        Ah, the memories! First did this when my computer had a 16 bit address bus and 8 bit op-codes and a total of 4K of RAM. Then I discovered there was something called a "compiler" and haven't had the urge to engage in this kind of masochism since.

                                        R Offline
                                        R Offline
                                        Roger Wright
                                        wrote on last edited by
                                        #41

                                        Good choice! Unfortunately, when those specs were current, I didn't have a lot of choice. I could write an operating system and assembler, or I could watch a box of electronic components grow old and useless without actually doing anything. In the end, I did what was needed, wrote an OS and assembler in machine code, and pressed into paper tape form for posterity, then got a real job. It was fun, but I wouldn't care to do it again.

                                        Will Rogers never met me.

                                        1 Reply Last reply
                                        0
                                        • B Brandon X12000

                                          It would help be able to do anything, just think how useful it would be. You would be able do anything just about any computer or machine, and what you program, works on about almost any piece of hardware, when you boot it. Like all of a suddenly the C language dies.

                                          Simple Thanks and Regards, Brandon T. H. Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst). Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison

                                          I Offline
                                          I Offline
                                          irneb
                                          wrote on last edited by
                                          #42

                                          It would help be able to do anything, Nope, you would basically only be able to do what you already can using assembly. Though you might be able to get at some accidental error in the CPU's hardware. But that's probably undocumented. just think how useful it would be. Perhaps, though I'm not to sure about "Useful for what?" Crashing a CPU through using some code which is not designed to do something "useful". You would be able do anything just about any computer or machine, Definitely NOPE! You'll need to learn each and every family of CPU's machine codes. Unless by "any computer" you mean "only those with (say) the x86 instruction set. and what you program, works on about almost any piece of hardware, when you boot it. Again: Definitely NOPE! Again unless you mean only one set of CPU's are allowed, and even then only if the rest of the hardware is not too different from your original machine (e.g. a different GPU, other HDD connection type, etc.) Like all of a suddenly the C language dies. I don't think the C language would die due to this. If that was reason enough to kill C, then assembly would have done so long ago. And yes, machine code was the programming language at one time. You needed reams of operators to turn on/off banks of switches to perform the simplest of tasks. Then ASM was "invented" to make life easier for the programmer - so (s)he could remember something like "MOV" instead of C6(11000110) as the "instruction" to move (copy) data from one location to another. And then higher level languages like C was invented when it was noticed that programmes used the exact same group of asm instructions time and again (i.e. something like check value, goto,...) What you're after seems to be a reversion back to how it was in the 40's & 50's.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups