课程

教学相长

认真教书,认真学习

第一章 概述
第二章 Nios II处理器体系结构
第三章 Avalon接口规范
第四章 SOPC软硬件开发平台
第五章 Nios II处理器常用外设
第六章 μC/OS II操作系统移植
第七章 Nios II系统深入设计
第八章 调试技术

computer programming language

计算机编程语言

 

机器指令

汇编语言

高级语言

 

机器指令

机器指令(Machine Instructions)是CPU能直接识别并执行的指令,它的表现形式是二进制编码。机器指令通常由操作码和操作数两部分组成,操作码指出该指令所要完成的操作,即指令的功能,操作数指出参与运算的对象,以及运算结果所存放的位置等。

(以下来自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.

For example, the instruction below tells an x86/IA-32(x86 is a family of backward compatible instruction set architectures based on the Intel 8086 CPU and its Intel 8088 variant. IA-32 is short for "Intel Architecture, 32-bit", sometimes also called i386.IA-32 is the 32-bit version of the x86 architecture.) processor to move an immediate 8-bit value into a register. The binary code for this instruction is 10110 followed by a 3-bit identifier for which register to use. The identifier for the AL register is 000, so the following machine code loads the AL register with the data 01100001.
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可直接解读的数据)而言。是高度封装了的编程语言,与低级语言相对。它是以人类的日常语言为基础的一种编程语言,使用一般人易于接受的文字来表示(例如汉字、不规则英文或其他外语),从而使程序编写员编写更容易,亦有较高的可读性,以方便对电脑认知较浅的人亦可以大概明白其内容。

  1. 命令式语言。这种语言的语义基础是模拟“数据存储/数据操作”的图灵机可计算模型,十分符合现代计算机体系结构的自然实现方式。其中产生操作的主要途径是依赖语句或命令产生的副作用。现代流行的大多数语言都是这一类型,比如 FortranPascalCobolCC++BasicAdaJavaC# 等,各种脚本语言也被看作是此种类型。
  2. 函数式语言。这种语言的语义基础是基于数学函数概念的值映射的λ算子可计算模型。这种语言非常适合于进行人工智能等工作的计算。典型的函数式语言如 LispHaskellMLScheme 、F#等。
  3. 逻辑式语言。这种语言的语义基础是基于一组已知规则的形式逻辑系统。这种语言主要用在专家系统的实现中。最著名的逻辑式语言是 Prolog
  4. 面向对象语言。现代语言中的大多数都提供面向对象的支持,但有些语言是直接建立在面向对象基本模型上的,语言的语法形式的语义就是基本对象操作。主要的纯面向对象语言是 Smalltalk
(以下来自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.