如果需要做到跨平台操作,我们首先要判断的就是自己在什么平台上。
比如我们用uname -s查看操作系统,用uname -p查看处理器类别等。
实际上我们要确定的就是指令集体系结构。
只要指令集一致,不论操作系统、cpu怎样,相同的一个二进制执行文件(机器码)都是可以正常运行的
下面是对指令集体系结构、微处理器体系结构的介绍,资源来自维基百科。
Instruction (指令)
In computer science, an instruction is a single operation of a processor defined by an instruction set architecture. In a broader sense, an "instruction" may be any representation of an element of an executable program, such as a bytecode.
instruction set architecture (指令集体系结构)
An instruction set, or instruction set architecture (ISA), is the part of the computer architecture related to programming, including the native data types, instructions, registers, addressing modes, memory architecture, interrupt and exception handling, and external I/O. An ISA includes a specification of the set of opcodes (machine language), the native commands implemented by a particular processor.
Instruction set architecture is distinguished from the microarchitecture, which is the set of processor design techniques used to implement the instruction set. Computers with different microarchitectures can share a common instruction set. For example, the Intel Pentium and the AMD Athlon implement nearly identical versions of the x86 instruction set, but have radically different internal designs.
microarchitecture (微处理器体系结构)
In computer engineering, microarchitecture (sometimes abbreviated to µarch or uarch) is the way a given instruction set architecture (ISA) is implemented on a processor. A given ISA may be implemented with different microarchitectures.[1] Implementations might vary due to different goals of a given design or due to shifts in technology.[2] Computer architecture is the combination of microarchitecture and instruction set design.
ISAs implemented in hardware
- Alpha
- ARM
- Burroughs B5000/B6000/B7000 series
- eSi-RISC
- IA-64 (Itanium)
- Mico32
- MIPS
- Motorola 68k
- PA-RISC
- IBM 700/7000 series
- System/360 and upwards compatible successors
- Power Architecture
- PDP-11
- SPARC
- SuperH
- Tricore
- Transputer
- UNIVAC 1100/2200 series
- x86
- EISC (AE32K)
ISAs commonly implemented in software with hardware incarnations
- p-Code (UCSD p-System Version III on Western Digital Pascal MicroEngine)
- Java virtual machine (ARM Jazelle, picoJava, JOP)
- FORTH