• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Khatharr

Some MASM questions

4 posts in this topic

Dunno if there's assembly people here, but I figured I'd ask a couple questions and see what happens. Here goes...

1) Looking at the documentation in the "Intel 80386 Reference Programmer's Manual" I see that for some instructions (ie "xor m32,imm32") there's no +m documented on the cycle count. Is the instruction sent to the bus to be executed remotely?

2) While studying stack behavior in the VS debugger I compiled the following:

[CODE]
int func(int arg, int artoo) {
int a = 0xAAAAAAAA;
int b = 0xBBBBBBBB;
int c = 0xCCCCCCCC;
int d = 0xDDDDDDDD;
//breakpoint
return 12;
}


[/CODE]at the break I expected ESP to point to the sequence:

"DDDDDDDD CCCCCCCC BBBBBBBB AAAAAAAA"

but instead I got:

"CCCCCCCC DDDDDDDD BBBBBBBB AAAAAAAA"

is there some kind of reason for re-arranging the variable order? I mean it's not erroneous, since the vars are referenced at the correct addresses, but why re-arrange them?

Thanks to anyone that takes the time to respond. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Khatharr
0

Share this post


Link to post
Share on other sites
I'm pretty sure there is no reason for it in this case. It just happens to turn out that way. The compiler probably places all variables in some sort of list in no particular order, removes those that are unused, orders them and transforms many times over depending on any number of factors, and then outputs the result, having forgot any original order many steps earlier. When you write a small test-case this leads to something that doesn't have relevance to much of anything. Edited by Erik Rufelt
0

Share this post


Link to post
Share on other sites
It just struck me as strange that something like that would be done. I mean I can see how if there's no standard then the compiler would likely just compose and dump the list as quickly as possible, ignoring order, but seeing how the stack arrangement is already moderately complex I guess I'm just surprised that there's no standard. It means that I can't look at the var declaration order in the C(++) and infer the correct stack positions in inline asm (Although that would be a pretty arcane thing to need, since I can just refer to the actual variable name, I guess.), so I was wondering if it was something that was done deliberately in order to gain some form of run-time benefit.

Thanks for your reply. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Any clue about question 1 though? That's the one that's really been puzzling me. I was optimizing a tight inner-loop the other day and I was counting cycles to compare between the compiler code and the optimized code (optimized code - 9 cycles per loop; compiler code 80+2m cycles per innerloop, lol - that was a damn good optimization - saves about 20 sec per execution on my 2.41 ghz cpu) and I noticed that operations that write to memory don't have +m cycles, but just a flat cycle count. Does the system bus do some of the work here or something? I'm just wondering if this is an error in the documentation or if the CPU actually does not need to fetch the memory value in order to apply a modification to it. Edited by Khatharr
0

Share this post


Link to post
Share on other sites
Did you compile that with full optimizations and release build?
The compiler is usually quite good at optimizing...

If the code you posted before is the exact code then for there to be any ASM left I guess you built that part in debug, which will compile code to be easily stepped through. There might be some rule to the order to the variables in debug, but again it probably won't be predictable and could change for any number of reasons.

When building in release variables can be changed quite significantly. I've had constants used in integer arithmetic be changed to completely different constants as the compiler realized they would give the same answer if the operations were also changed. So the actual output ASM used a completely different mathematical representation of the function I was calculating, but with a provably equal answer.
The compiler can also change the size of you variables, if it sees a constant could fit in 16 bits or if it thinks it's faster to make it 64 bits or something else.


As for your other question, I don't know. Independent instructions are usually executed in parallel with memory fetches, if that's what you mean.
0

Share this post


Link to post
Share on other sites
[quote name='Erik Rufelt' timestamp='1351117307' post='4993578']Did you compile that with full optimizations and release build?[/quote]

Nah, that one was with everything turned off. It clipped the vars in opt modes because they're not referenced.

[quote name='Erik Rufelt' timestamp='1351117307' post='4993578']As for your other question, I don't know. Independent instructions are usually executed in parallel with memory fetches, if that's what you mean.[/quote]

What I mean is uh... Let's see...

...

Actually, now that I'm looking at it again there's some stuff here that doesn't make sense. Like 'JMP rel16' is 7+m, which it shouldn't be since JMP rel just changes the value of EIP (unless this is assuming the wait time for fetching the instructions at the new EIP address). I guess I'm misunderstanding the convention the book is using. I assumed that +m meant that a bus wait was included in the execution time.

I've only had the actual instruction reference pages until now. I just downloaded the full text last night, so I'll read through the rest and see if I can figure out what's going on.

Thanks again for replying. :D Edited by Khatharr
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0