Note: this answer corresponds to the original question.
I am new to assembly as well so I can see where you are coming from. With that being said, there seem to be quite a few issues with the contrived code that you have posted.
Does the order of the operands matter? If yes why?
There are two different styles of human-readable mnemonics used to represent CPU instruction codes: AT&T and Intel. While the order the operands are shown in is different between Intel and AT&T syntax, the order of instruction code bytes in memory is constant.
8048074: 55 push ebp
8048075: 89 e5 mov ebp,esp
8048077: b8 00 00 00 00 mov eax,0x0
804807c: 5d pop ebp
804807d: c3 ret
8048074: 55 push %ebp
8048075: 89 e5 mov %esp,%ebp
8048077: b8 00 00 00 00 mov $0x0,%eax
804807c: 5d pop %ebp
804807d: c3 ret
The (little-endian) byte sequence
89 e5 is represented as
mov ebp,esp in Intel syntax and as
mov %esp,%ebp in AT&T syntax. Though the mnemonic representations of the operands are opposite of each other, they represent the same byte sequence. The order of the opcode mnemonics matters in that it is determined by the syntax used to represent the instruction codes.
What happens to the result after each step of code has been run?
Every line of the code posted in the question except the last contains at least one illegal operand so only that line could feasibly run.
AT&T syntax is assumed.
0x2000: cs cs cs
%cs is a segment register and, being a register, must be prefixed with the
% symbol. There are 3 operands here that are all the same register and no instruction. This is illegal. I am not sure what you envisioned would happen here.
0x2001: xor x20,(eax)
x20 is an illegal operand. Constants are immediate operands which must be prefixed with the
$ symbol, so this operand should be
%eax is a register, hence the
% prefix is required.
(eax) should instead be
0x2002: and x20,%ah
0x2003: or x20, %dh
0x2004: dec (ebi)
ebi looks like it is supposed to be a register. Did you mean
%ebx? Either way, it lacks the
0x2005: dec %si
dec instruction decrements the contents of its operand by one. So the value stored in
%si will be decremented.
Fixed up, the code would look like this:
xor $0x20, (%eax)
and $0x20, %ah
or $0x20, %dh
How do you construct some equivalent code (e.g. c++) from this assembly code?
Assuming that the corrected code is actually correct, someone with sufficient understanding could simply look at this snippet and create a roughly equivalent statement or sequence of statements in a high level language. For mere mortals, there are tools called decompilers.
Programming from the Ground Up by Jonathan Bartlett and
"Professional Assembly Language" by Richard Blum are pretty good IMO. A more technical resource is the System V Application Binary Interface Intel386 Architecture Processor Supplement, which sheds light on some of the mysteries of the processor and virtual memory. SO's x86 wiki has a list of many resources. Of course, there are also the Intel manuals.