Some of the concepts that are goign to follow constitute my indigenous way to program. The work was done while pursuing undergraduate degree in Physics.
Instead of giving you a mechanical way to do it, but let's discuess it from scratch. We know that we write a program in high-level language like C,C++ then we compile it, link it , and get executable code. Here you will be introduced to method by which you can write that binary executable image with out a high-level language compiler. Today CC gives binary executable directly in form of a.out, with out linking. I am not sure of very early UNIX systems, but classically most of the languages were compiled and then linked. On DOS systems after compilation we get .obj file, and after linking it we get .exe which is like a.out .
This .exe or a.out file is binary file which is bit by bit same as what we would have got if we converted our program to Assembly source code of the hardware on which we are running our program (Intel for DOS systems, Sun for Solaris Systems, Rx000 for SGI-IRIX system etc). At this Point of time it will be good if you have good understanding of Interrupts (DOS in particular).
We know that everything at an architecture level is executed by BIOS. So the Assembly (if you don't know) mostly looks like set of movements into the processor registers and then call to interrupt to do some task. Now all we have to do is to write the numeric equivalent of these Assembly instructions into a file. Next obvious question-how do we do it? We do it using copy con (copy from consol). I will give you one practical example for a DOS based system, for Intel Architecture.
There some interrupts which do not need prior register settings. Like INT 19h. For simplicity our program is just one line, one instruction: INT 19h. And what does this program do. Answer depends on what kind of system you are running it on. If you had plane old faithful DOS system, it will boot the machine. However if you are running this program in a MS-DOS Window(which is essentially a VDM-Virtual DOS Machine) on Win32 System it is like typing exit on the command prompt which you know exits from the command window and returns to the desktop. Now if you want to see the machine boot. You have to start the Windows machine in the pure DOS mode (because I am sure you don't have plane DOS based system any more, today DOS comes as a subsystem of a Win32 system. Trivia-those of you thought that latest version of DOS is 6.22, you are wrong. If fact it is 7.00 which is a subsystem of Win32, it is not sold separately anymore). To do that please read system programming projects under my work page to find out how to get into pure DOS mode, in detail. For now I might let you know briefly. To take the Win machine to pure DOS mode just press F8 when the machine boots and you will be taken to a Windows startup menu. There select command prompt only option, and you are in pure DOS mode.
With the above theory let’s get to the implementation part. Following are the steps. All of them on you numeric keypad, and not the number keys.
And you get a message saying 1 file copied. If you realize ,you just wrote a .com file, which are much powerful and compact files when compared to .exe files. Also to do this we did not use any assembler or compiler. Now just type andy on the command prompt and Lord behold the system boots. That's the power of low-level systems programming. That's why I like it. So next time some one asks you do you know language X, your answer should be-I know Assembly Sir-"The Mother Of All Languages!".
You can easily verify the program you wrote. I will tell you mechanically first and then explain. Just type debug andy.com on DOS prompt and you get a '-' prompt. On this prompt type U 100, and you will see some junk Assembly code, the first instructing in that will be INT 19, do you see that? Debug is an assembly editor and debugger, where you can execute Assembly commands. Just type? On '-' and you can see the help. U means unassembled 100 is the starting address from where unassembly has to start. 100 because debug expects input as .exe file and valid programmer instruction in a .exe file start from 256th byte which is 100 Hex. E-mail me for the reason, and I can explain it to you. First valid programmer instruction starts from 100Hex because first 256 bytes is .exe header which contains PSP, BPB and stuff. As a simple exercise you can create a text file save it and type debug followed by the text file name, now type d 100 on '-' prompt on right hand side column you can see the text which you typed with hex value on the left hand matrix. On the extreme left you see RAM location in form of Segment:Offset, because Intel architecture follows segmented memory.
Here you just had one simple example, and by now you should be convinced that knowing the code for a perticular processor instruction set, you can write any program by just using alt key and numeric keypad, with no software other than the Operating System. After few years of experience you can write binary executable programs easily if you stick to any one-processor architecture. The stuff on this page is not documented in any book as far as I know, including Microsoft Press. You can mail me for many more interrupts which don't need prior register setting, which means that our programs will be just one instruction, one line, but you can write entire programs using this method too, and you will not need any software other than the Operating System.