computer programming language
计算机编程语言
机器指令
汇编语言
高级语言
机器指令
(以下来自wikipedia 的instruction set)
Machine language[edit]
Machine language is built up from discrete statements or instructions. On the processing architecture, a given instruction may specify:
- Particular registers for arithmetic, addressing, or control functions
- Particular memory locations or offsets
- Particular addressing modes used to interpret the operands
More complex operations are built up by combining these simple instructions, which are executed sequentially, or as otherwise directed by control flow instructions.
Instruction types[edit]
Examples of operations common to many instruction sets include:
Data handling and memory operations[edit]
- Set a register to a fixed constant value.
- Copy data from a memory location to a register, or vice-versa (a machine instruction is often called move, however the term is misleading). Used to store the contents of a register, result of a computation, or to retrieve stored data to perform a computation on it later.
- Read and write data from hardware devices.
Arithmetic and logic operations[edit]
- Add, subtract, multiply, or divide the values of two registers, placing the result in a register, possibly setting one or more condition codes in a status register.
- Perform bitwise operations, e.g., taking the conjunction and disjunction of corresponding bits in a pair of registers, taking the negation of each bit in a register.
- Compare two values in registers (for example, to see if one is less, or if they are equal).
Control flow operations[edit]
- Branch to another location in the program and execute instructions there.
- Conditionally branch to another location if a certain condition holds.
- Indirectly branch to another location.
- Call another block of code, while saving the location of the next instruction as a point to return to.
汇编语言
汇编语言(assembly language)是一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。在汇编语言中,用助记符(Mnemonics)代替机器指令的操作码,用地址符号(Symbol)或标号(Label)代替指令或操作数的地址。在不同的设备中,汇编语言对应着不同的机器语言指令集,通过汇编过程转换成机器指令。普遍地说,特定的汇编语言和特定的机器语言指令集是一一对应的,不同平台之间不可直接移植。[1]
(以下来自于wikipedia assembly language)
An assembly language (or assembler language[1]) is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture's machine code instructions. Each assembly language is specific to a particular computer architecture, in contrast to most high-level programming languages, which are generally portable across multiple architectures, but require interpreting or compiling.
10110000 01100001
This binary computer code can be made more human-readable by expressing it in hexadecimal as follows.
B0 61
Here, B0
means 'Move a copy
of the following value into AL', and
61
is a hexadecimal
representation of the value 01100001, which
is 97 in decimal. Assembly language for the
8086 family provides the mnemonic MOV (an
abbreviation of move) for
instructions such as this, so the machine
code above can be written as follows in
assembly language, complete with an
explanatory comment if required, after the
semicolon. This is much easier to read and
to remember.
MOV AL, 61h ; Load AL with 97 decimal (61 hex)
高级语言
(以下来自百度百科-高级语言)
高级语言(High-level programming language)相对于机器语言(machine language,是一种指令集的体系。这种指令集,称机器码(machine code),是电脑的CPU可直接解读的数据)而言。是高度封装了的编程语言,与低级语言相对。它是以人类的日常语言为基础的一种编程语言,使用一般人易于接受的文字来表示(例如汉字、不规则英文或其他外语),从而使程序编写员编写更容易,亦有较高的可读性,以方便对电脑认知较浅的人亦可以大概明白其内容。
(以下来自wikipedia High-level programming language)
Execution modes[edit]
There are three general modes of execution for modern high-level languages:
- Interpreted
- When code written in a language is interpreted, its syntax is read and then executed directly, with no compilation stage. A program called an interpreter reads each program statement, following the program flow, then decides what to do, and does it. A hybrid of an interpreter and a compiler will compile the statement into machine code and execute that; the machine code is then discarded, to be interpreted anew if the line is executed again. Interpreters are commonly the simplest implementations of the behavior of a language, compared to the other two variants listed here.
- Compiled
- When code written in a language is
compiled, its syntax is transformed
into an executable form before running.
There are two types of compilation:
- Machine code generation
- Some compilers compile source code directly into machine code. This is the original mode of compilation, and languages that are directly and completely transformed to machine-native code in this way may be called "truly compiled" languages. See assembly language.
- Intermediate representations
- When code written in a language is compiled to an intermediate representation, that representation can be optimized or saved for later execution without the need to re-read the source file. When the intermediate representation is saved, it may be in a form such as byte code. The intermediate representation must then be interpreted or further compiled to execute it. Virtual machines that execute byte code directly or transform it further into machine code have blurred the once clear distinction between intermediate representations and truly compiled languages.
- Source-to-Source Translated or Trans-compiled
- Code written in a language may be translated into terms of a lower-level programming language for which native code compilers are already widely available. The C programming language is a common target for such translators. See Chicken Scheme and the Eiffel as examples. Specifically, the generated C and C++ code can be seen (as generated from the Eiffel programming language when using the EiffelStudio IDE) in the EIFGENs directory of any compiled Eiffel project. In Eiffel, the "Translated" process is referred to as Trans-compiling or Trans-compiled, and the Eiffel compiler as a Transcompiler.