Jump to content
  • Advertisement

Archived

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

Tree Penguin

Asm in release?

This topic is 5217 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

Hi, i am learning asm a bit and the first thing i dit was replacing a for loop with this: WORD z2=g_h*g_d*g_w; WORD index2=0; _asm { push cx mov cx,z2 _drawvertexloop: mov index2,cx }; vertices[index2].DrawVertex(); _asm { mov cx,index2 loop _drawvertexloop pop cx }; The for version works fine in both debug and release mode but the asm version causes access violation. Is there any reason for that? I use VC++6.0, no optimisations. edit: i added the push/pop cx lines to see if that fixed it but it didn't. 2nd edit: i know this is probably very dumb and n00b-like code but it's the first i ever did in asm, and it already runs faster in debug mode so it's not totally crap i guess. [edited by - Tree Penguin on June 10, 2004 4:11:26 PM]

Share this post


Link to post
Share on other sites
Advertisement
Well, that fixes the error but no matter where i put it only one point is drawn, where should i put it (in case i for some reason forgot a place) and what else could it be? (i guess i should put it before mov index2,cx).

EDIT: i also don't see why that would help because the cx register is automatically decreased right?

[edited by - Tree Penguin on June 10, 2004 4:34:19 PM]

Share this post


Link to post
Share on other sites
Use ecx.

Windows is 32-bit, use a 32-bit reg. Using 16 bit reg gets a prefix byte that will increase the size of you program.

And use DWORD.

push cx unbalances the stack, Windows likes it 4 byte aligned.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Also, the ''loop'' instruction while in 32-bit mode works with ecx and since the upper 16-bits of ecx are undefined here, this could end up being one huge loop. Clearly that would likely GPF if ECX = &hFFFF0002 for example (3 vertices but upper bits all set by previous code)

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!