I`ve been doing some programming challenges and just discovered that I barely know the most basic things of asm... I mean I don`t know what the shr, and, or, xor, she, etc instructions do... The biggest problem I`ve been having is like converting a formula to ASM, like:

I've been reading Iczelion's tutorial but it's actually an win32 API tutorial so it hasn't been helping me at these problems... I did search for these subjects but most of my results were either way to advanced and focused only in deeply optimizating your code, or way to superficial saying only things like "The and instrunction compares the registers' bits and keep the equal ones" *???*.

`Y=X^3-(X+Y)`

`Calc macro x, y ; Y=X^3-(X+Y)`

mov edx, x ; (x+y) (at edx)

add edx, y ; ^

; how do I do x^3?

sub ebx, edx

endm

I've been reading Iczelion's tutorial but it's actually an win32 API tutorial so it hasn't been helping me at these problems... I did search for these subjects but most of my results were either way to advanced and focused only in deeply optimizating your code, or way to superficial saying only things like "The and instrunction compares the registers' bits and keep the equal ones" *???*.

You'll have to give some more information... is the "Y=X^3-(X+Y)" in math or C notation?

In math notation, X^3 means X**3, or "x raised to the power of 3". In C notation, "X^3" means "XOR x, 3".

In math notation, X^3 means X**3, or "x raised to the power of 3". In C notation, "X^3" means "XOR x, 3".

C notation...

BTW do you have any good link for my problem?

BTW do you have any good link for my problem?

try this...

and for some explanation of assembly rather than just the API, Thomas "Madwizard" Bleeker has written an okay crash course, which you can find at http://www.madwizard.org/dl.php?file=tutors.win32asm (site up again, yay :)).

Other than that, perhaps look at Randall Hyde's Art Of Assembly (even though it's for 16bit assembly), and the intel/AMD processor manuals.

mov eax, X

xor eax, 3

sub eax, X

sub eax, Y

and for some explanation of assembly rather than just the API, Thomas "Madwizard" Bleeker has written an okay crash course, which you can find at http://www.madwizard.org/dl.php?file=tutors.win32asm (site up again, yay :)).

Other than that, perhaps look at Randall Hyde's Art Of Assembly (even though it's for 16bit assembly), and the intel/AMD processor manuals.

Watch your operator precedence f0dder. XOR has lower precedence that addition and subtraction. I think the following would be closer to what C would create:

Spara

mov eax, 3

sub eax, X

sub eax, Y

xor Y, eax

Spara

Doh, ouch, *blush* et cetera :)

(no wonder I always add "superfluous" parenthesis and "logical whitespaces" :) )

(no wonder I always add "superfluous" parenthesis and "logical whitespaces" :) )

and for some explanation of assembly rather than just the API, Thomas "Madwizard" Bleeker has written an okay crash course, which you can find at http://www.madwizard.org/dl.php?file=tutors.win32asm (site up again, yay :)).

Thanks, I'm reading it.

Oh, reading back the topic I think I didn't explain well...

By X^3 I meant x to the power of 3, not x xored with 3...

Sorry... I guess the code would look like this:

Wheres the syntax error at mul edx, edx? Taken from the tutorial "mul destination, source".

By X^3 I meant x to the power of 3, not x xored with 3...

Sorry... I guess the code would look like this:

`start:`

mov eax, 1 ; eax = x

mov ebx, 1 ; ebx = y

mov ecx, 999 ; this is just to make the loop run 1000 times

loopstart:

mov edx, eax ; X (just to remain eax original value)

mul edx, edx

mul edx, edx ; X^3

add ebx, eax ; X+Y

sub edx, ebx ; X^3-(X+Y)

mov ebx, edx ; y =

inc eax

dec ecx

jnz loopstart

invoke wsprintf, addr buff, addr format, ebx

invoke MessageBox, NULL, addr buff, addr MsgBoxCaption, MB_OK

invoke ExitProcess, 0

end start

Wheres the syntax error at mul edx, edx? Taken from the tutorial "mul destination, source".

MUL only takes one operand and multiplies that operand by EDX:EAX

Spara

mov ebx, edx ; ebx = edx

mov eax, edx ; eax = edx

mul ebx ; eax = edx^2

mul ebx ; eax = edx^3

mov edx, eax

Spara