views:

84

answers:

2
0x042444FF; /* 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 ?

+4  A: 

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.

Mark Byers
Its also not cross OS for the most part, as you are depending on calling conventions, interupt codes etc. which are set by the OS.
James Anderson
Is `__cdecl` calling conversion windows only?
wamp
+1  A: 

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.

Delan Azabani