第一个计算机程序是如何创建的? [英] How was the first computer program created?

查看:129
本文介绍了第一个计算机程序是如何创建的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
第一个编译器是如何编写的?

Possible Duplicate:
How was the first compiler written?

这个问题一直困扰着我. 要编译程序,您需要一个编译器,它也是程序的一种类型,那么编译器又是什么编译器呢? 有人告诉我,第一个编译器是用汇编或机器代码编写的. 但是考虑到这一点,还不是完整的故事.毕竟,在没有操作系统和驱动程序的情况下,机器代码如何从硬盘驱动器到RAM再到CPU?必须以某种方式对驱动程序进行编程.

This question has always been bothering me. To compile a program, you need a compiler, which is also a type of program, so what compiled the compiler? Somebody told me that the first compilers were written in assembly or machine code. But thinking about that, that is still not the complete story. After all, how does the machine code go from the hard drive to RAM to the CPU without an operating system and drivers? The drivers had to have been programmed somehow.

我知道很早的计算机就有开关,并且允许您翻转开关以指示位.我想知道从开关到如何让CPU读取机器代码而不需要计算机程序告诉它的方式是如何实现的.

I know that the very early computers had switches and allowed you to flip the switch to indicate bits. I am wondering how the leap was made from switches to a way to get the CPU to read machine code without needing a computer program to tell it to do so.

推荐答案

简短的答案:第一个程序是用原始机器代码精心编写的,所有内容都是在此基础上构建的.

The short answer: the first programs were meticulously written in raw machine code, and everything was built up from there.

这个想法称为自举.假设您有一台带有处理器,一些闪存和硬盘的裸机.通常,处理器会在加电时配置为从非易失性存储器(例如CMOS或闪存)中的固定位置加载称为 bootloader 的简单操作系统.该OS非常简单,并且具有足以将计算机指向实际OS所在磁盘上的位置的功能.然后,该操作系统可以打开越来越多的设备并加载越来越复杂的程序,直到最终整个操作系统启动并运行.

The idea is called bootstrapping. Suppose that you have a bare machine with a processor, some flash memory, and a hard disk. Typically, the processor is configured on power-up to load a simple operating system called the bootloader from a fixed location in non-volatile memory (for example, CMOS or flash). This OS is extraordinarily simple and has just enough functionality to point the computer to the spot on disk where the real OS lives. This OS can then turn on more and more devices and load more and more complicated programs, until eventually the whole OS is up and running.

但是这个引导程序写的是什么?最初,这些都是用原始机器代码编写的,然后硬编码到机器中.它将运行的程序也将用机器代码编写,这将令人难以置信地缓慢且乏味.最终,有人用机器代码编写了第一个简单的汇编程序.有了该汇编程序后,就可以开始编写汇编程序,包括汇编程序本身.实际上,一旦有了一个简单的汇编程序,就无需再编写机器代码了.您可以继续编写汇编程序!

But what is this bootloader written in? Originally, these were written in raw machine code and hardcoded into the machine. The programs it would run would be written in machine code as well, which would be unbelievably slow and tedious to work with. Eventually, someone wrote the first simple assembler in machine code. Once you have this assembler, you can start writing programs in assembly, including the assembler itself. In fact, once you have a simple assembler, you never need to write machine code again. You can just keep writing the assembler in assembly!

从这一点开始,您可以通过以下方式构建更复杂的编程语言:首先使用现有工具(例如,汇编器)编写编译器,以获取足够的可用功能,以便编译器可以进行基本编程.然后,您可以使用该编译器为编程语言本身编写一个编译器,并使用相同的技巧在您以前的工作的基础上获得更大,更酷的功能.这种技术至今仍在使用-大多数编译器都是以其编译语言编写的.

From this point you can build more complex programming languages by first writing the compiler using existing tools (the assembler, for example) to get just enough functionality available so that the compiler can do basic programming. You then use that compiler to write a compiler for the programming language itself, and use the same trick to build off of your previous work to get something bigger and cooler. This technique is still used today - most compilers are written in the language they compile to.

总而言之,过去的所有事情都必须手工完成,但是由于这样做的人们的辛勤工作,我们可以在已经存在的基础上进行建设.

To summarize, everything had to be done by hand at some awful point in the past, but thanks to the hard work of the people who did this we can build off of what's already there.

这篇关于第一个计算机程序是如何创建的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆