I think Fordy has it backwards. Learn ASM first then C++. IMO C++ is fifty times harder than assembly language. Assembly is simple because everything is broken down into small steps. But it is also cumbersome because there is no way to skip steps or provide structure to the code. After awhile even well commented assembler turns into a large jumbled mess.
If you can understand this, then you can do assembly. Say you want to do this:
y*[width]+x
Here it is:
Code:
;Put y value into eax
mov eax,[y]
;Put width value into ebx
mov ebx,[width]
;multiply eax by ebx leaving result in eax
mul eax,ebx
;add x value to eax
add eax,[x]
And that's just one of a million ways you could do it. Here's another way.
If you wanted to break 320 down into 2 base 2 values you could do this.
320 is essentially 256+64. Since those are both base 2 we can do this:
(y<<8)+(y<<6)+x
or
y*(2^8)+y*(2^6)+x
y*(128)+y*(64)+x
After all (y*128)+(y*64)+x is the same as y*(128+64)+x or y*320+x.
Here is the asm code:
Code:
;put y value into eax
mov eax,[y]
;shift left by 8 -> multiplies by 2^8 or by 128
shl eax,8
;put y value into ebx
mov ebx,[y]
;shift left by 6 -> multiplies by 2^6 or by 64
shl ebx,6
;add ebx to eax, leave result in eax
add eax,ebx
;add x value to eax, leave result in eax
add eax,[x]