• 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
lride

I need to analyze assembly code...

20 posts in this topic

I must analyze some assembly code..

Is there some kind of "assembly code analyzer"?
Or do i need to learn assembly? [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] Edited by lride
0

Share this post


Link to post
Share on other sites
I need to know how conditional statements, loops and etc translate into assembly.
Where can I learn some assembly?
0

Share this post


Link to post
Share on other sites
If you just want to see how code in one language turns into assembly, most compilers give you an option to see generated assembly. For gcc you can use the -S switch and with MSVC you can use the /FA switch.
0

Share this post


Link to post
Share on other sites
[quote name='alvaro' timestamp='1349571343' post='4987542']
If you have optimizations turned off, it should be pretty straight forward most of the time.
[/quote]

Well, I must anaylze a code with full optimization especially in a loop, so I know what kind of loop optimization(such as interchanging, unrolling) is happening.
Is optimized assembly harder to understand?
0

Share this post


Link to post
Share on other sites
[quote name='kuramayoko10' timestamp='1349572149' post='4987545']
I like to use objdump + gcc on Linux to have the assembly code with the C code commented in between.
> gcc -g test.c -o test.o> objdump -dS test.o > test.asm
On Windows, Visual Studio gives you assembly code pretty easily as well: right-click on your code and select "Show Dissasembly"
[/quote]

I did

g++ -O3 main.cpp -o main.o
objdump -dS main.o >main.asm

but I don't get c++ code commented in between.
Instead I get assembly like below instead

(excerpt)
[source lang="plain"]main.o: file format pei-i386
main.o: file format pei-i386

Disassembly of section .text:

00401000 <___mingw_CRTStartup>:
401000: 53 push %ebx
401001: 83 ec 38 sub $0x38,%esp
401004: a1 70 40 40 00 mov 0x404070,%eax
401009: 85 c0 test %eax,%eax
40100b: 74 1c je 401029 <___mingw_CRTStartup+0x29>
40100d: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp)
401014: 00
401015: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)[/source]

by the way "go to disassembly" works excellently in VC++ Edited by lride
0

Share this post


Link to post
Share on other sites
You can get the original code interleaved with the generated assembly with this command: g++ test.cpp -c -g -O3 -Wa,-ahl=test.lst

Give it a try!
1

Share this post


Link to post
Share on other sites
Thanks, it works.

I was wondering if assembly code could show if branch prediction is taking place.
0

Share this post


Link to post
Share on other sites
[quote name='lride' timestamp='1349576724' post='4987559']
I was wondering if assembly code could show if branch prediction is taking place.
[/quote]

No, that doesn't make any sense. Branch prediction is a feature of the CPU, which tries to execute the code as fast as possible, but the assembly is not instrumented in any way to enable it: The CPU will do it automatically everywhere.
2

Share this post


Link to post
Share on other sites
Thanks to everyone who answered my question!

so much to know for a science fair project...
0

Share this post


Link to post
Share on other sites
My two cents: grab a disassembler - a program which shows you the assembly of a compiled EXE or DLL file.. I used to modify all sorts of programs (while simultaneously gaining a bare-minimum awareness of assembly itself) by disassembling them, and editing their code directly using a hex editor - overwriting small bits of existing code by surmising the actual byte opcodes of the asm instructions I desired and writing them in by hand.. Also, writing programs that would do it all in memory (WriteProcessMemoryEx) so that the original file could be left alone while effecting the equivalent change in functionality once the target was running. That may or may not help you.
0

Share this post


Link to post
Share on other sites
I know it's not the same architecture (6502 is not x86), but I just wanted to throw this out there: [url="http://www.atariarchives.org/mlb/"]Machine Language for Beginners[/url]. Edited by Heath
0

Share this post


Link to post
Share on other sites
[quote name='lride' timestamp='1349570746' post='4987539']
I need to know how conditional statements, loops and etc translate into assembly.
Where can I learn some assembly?
[/quote]

You should definitely read [url="http://www.amazon.com/Code-Optimization-Effective-Memory-Usage/dp/1931769249"]Code Optimization: Effective Memory Usage[/url] by well-known code-hacker Kris Kaspersky. One of the best books on the subject you want to know.
0

Share this post


Link to post
Share on other sites
What do you need to analyze assembly code [i]for[/i]? There must be a specific question to answer. For example, I once tried to look at the relevant code for a rather inexplicable C++ bug, and I only had to look at a few symbol names and trivial push, mov and call instructions to get evidence that a class constructor was wrong enough to call itself recursively; there was absolutely no need to make modifications, predict branches, understand every line of the program, etc.

Science fair project suggestion: illustrating different ways to do something in assembly, to show which libraries and compilers are more clever and which approaches fit specific processors and use cases.
You should analyze a task that is:[list]
[*]easy to understand (to avoid losing public)
[*]non-obvious to implement, with some difficulties and tradeoffs (to find interesting differences between implementations)
[*]simple to test (because you'll have to run performance measurements)
[/list]
BLAS routines, for example dense matrix multiplication, should be good choices.
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