开发者

Is assembly code cross-platform?

0x0424开发者_运维问答44FF; /* inc dword ptr [esp+4] */

0x042444FF is the machine code,while inc dword ptr [esp+4] is the assembly code, I know machine code is NOT cross-platform,as it depends on many factors.

What about assembly code, does it depends on CPU ?


Assembly code is not cross platform.

Usually there is a very direct mapping between machine instructions and assembly instructions so the assembly code depends on the architecture.

From Wikipedia:

An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other integrated circuits. It implements a symbolic representation of the binary machine codes and other constants needed to program a particular CPU architecture. This representation is usually defined by the hardware manufacturer, and is based on mnemonics that symbolize processing steps (instructions), processor registers, memory locations, and other language features. An assembly language is thus specific to a certain physical (or virtual) computer architecture. This is in contrast to most high-level languages, which are ideally portable.


Assembly code is basically a worded form of the machine code; it is designed to make writing machine code a little more convenient and readable. There is pretty much a one-to-one mapping of the two, so one assembly statement is turned into its machine code equivalent. Macine code is CPU-dependent. Assembly is therefore, also CPU-dependent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜