Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Inline assembler question...

This topic is 6964 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You don't need to use shl,2 because *4 works good (and faster) too.

some errors here:
mov eax,array[ebx*4] <- you get array alement here, but you need it's address.
mov [eax],value <- intel processors does not support mem-to-mem moving

Try to enclose parameters in square brackets, like this:
mov ebx,[index]
mov edx,[value]
lea eax,[array + ebx*4] <- get address of an element
mov [eax],edx

Also, leave these uptimizations for compiler, i think it can jenerate code better.


Share this post

Link to post
Share on other sites
What's wrong here:

void SetValue( int* array, int index, int value )
MOV EBX, index
MOV EAX, array [EBX*4]
MOV [EAX], value

I realize that this is a usless function really, but I'm just starting to learn assembly. I'm using VC++ 6 (hence EBX and EAX instead of BX and AX). I multiply by 4 because intigers in VC++ are 4 bytes.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!