Code Corner - More Switch Goodness

Jul 04, 2005 19:45

What happens when there are gaps in your enums?

Read more... )

Leave a comment

Comments 4

Assembly hardgeus July 5 2005, 13:11:30 UTC
So what's with the assembly? Are you having to get that close to the metal with your Console programming now?

Reply

Re: Assembly illomen July 5 2005, 18:37:33 UTC
It's more of a learning thing really. I haven't had the chance to work on much performace critcal code, lately, but would like to. But just in general, it's a good idea to know the size/performance trade-offs of different C & C++ constructs, and the only way to know what's really going on is to look at the generated code.

Reply


epiphaniesrus July 5 2005, 21:27:22 UTC
I'm not getting what's going on in the first couple lines of assembly - where did the 33 comparison come from, and why would you want it? The enum goes up to 127, yet it's jumping past the switch statement if there are any input values above 33?

It must be that I'm not getting what _arg$[ esp-4 ] means, as it looks like it's reading an offset subsection of arg? Man, it must be too long since I've looked at assembly.

Reply

illomen July 5 2005, 22:10:09 UTC
Good catch that 33 was a type-o. Originally I was working with an enum that went from 0,33. So that was basically checking if the value was greater then the last enum value then jumping to end.

As for the _arg$[ esp-4 ] thing, I'm a bit fuzzy with the .asm syntax myself, but I'm pretty sure it's reading 4 off the stack pointer, where the first argument is stored.

Reply


Leave a comment

Up