assembly language...the best tool for game programming?

This is a discussion on assembly language...the best tool for game programming? within the Game Programming forums, part of the General Programming Boards category; >>For the x68 motorolla processor, I can. For anything greater, x86 etc. LOL no. But it's only cuase I haven't ...

  1. #31
    ---
    Join Date
    May 2004
    Posts
    1,379
    >>For the x68 motorolla processor, I can.
    For anything greater, x86 etc. LOL no. But it's only cuase I haven't takin any steps to learn the instruction set or the registers.

    ive looked into learning but there are different syntax for different implementations. eg. NASM is different to TASM which is different to MASM. So how am i supposed to know what to learn?

  2. #32
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    That's the reason I havent bothered to learn asm yet

  3. #33
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    ive looked into learning but there are different syntax for different implementations. eg. NASM is different to TASM which is different to MASM. So how am i supposed to know what to learn?
    Learn the AT&T syntax because it rules all the others

  4. #34
    ---
    Join Date
    May 2004
    Posts
    1,379
    would most people agree with that? or is that just a personal preference?

  5. #35
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    personal. some people swear by the Intel syntax but it looks fugly to me.

  6. #36
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    are the intel, at&t or other versions of asm vendor specific, or will they work on both amd's and intel's because they're both x86 based?

  7. #37
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    Quote Originally Posted by dbgt goten
    I think you don't have much experience programming in assembly. Trying to code and entire game in pure assembly would be.... unimaginable. It's too many lines of code, and too complex a process.

    rollercoaster tycoon, and most other games where Chris Sawyer is involved.


    edit: Chris Sawyer!
    Last edited by Brian; 06-21-2004 at 10:33 AM.

  8. #38
    Banned
    Join Date
    Dec 2003
    Posts
    367
    Yes.

    edit: I mean, yes it will work on all x86 compats as long as you don't use instructions specific to a certain processor, such as a 586 or something.

  9. #39
    Banned
    Join Date
    May 2004
    Posts
    129
    Quote Originally Posted by skorman00
    The only way to make any code faster is to use better algorithms. If you take code written in any language, and write out the corresponding assembly commands line by line, the programs will be the EXACT same.

    The only time when one should resort to assembly is when the language you are using will not allow you to use a specific algorithm, and assembly will.
    Uhh, name an algorithm that you can't implement with C/C++ ? Because I really don't believe that there are any.

    And I mean honestly, if you are doing 3D, which relatively few people are on these boards, if you've got basic spatial partitioning and relatively good culling routines, then you aren't going to need to do tons of optimizations to get basic rasterization to work at a decent framerate.

    Just because the people who work on 'bleeding edge' technology games do tons of optimizations, doesn't mean that it's even moderately appropriate for us to do it. Your time is much better spent learning new concepts and implementing them in a robust manner, unless your goal is specifically to learn assembly.

    And another thing, WHY do people think it's so totally awesome to learn assembly programming? You aren't able to actually accomplish more with that than C/C++ or other high level or scripting languages, and it's not like assembly is actually really all *that* difficult to learn. The actual instruction sets are EASY to learn. I started doing work with the floating point unit and some basic x86 stuff, and I found myself making macros to do specific repetitive jobs for me, and I found it started looking more and more like C


    So, the whole speed thing isn't really that big of an issue for our type of work (I would like to see somebody post a project where they were able to squeeze 20% speed by doing the same stuff in hand coded assembly), and x86 and FPU instruction sets aren't that hard to learn (I found it easier than C++), so why the great appeal?

  10. #40
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    (I would like to see somebody post a project where they were able to squeeze 20% speed by doing the same stuff in hand coded assembly),
    go ask CharlesB on Gamedev.net who is programming a MathLibrary whose entire core is assembler SSE/2 optimized.

    regular assembler is not where you get the huge benifits, as integer based math is fairly simple for the processor to do(however, multiplication/division is still a pain), but SSE optimizations for Floating point math can give you 1000%-2500% gains in speed, with an average gain I have seen of atleast 200%.

    However, as Bubba ,others, and I have said, most of the speed problems people have are simply because they used too many loops to load a 3DS model, or are simply beginner programmers.

    Just because the people who work on 'bleeding edge' technology games do tons of optimizations, doesn't mean that it's even moderately appropriate for us to do it.
    I thought that programmers were supposed to accept challenges to better themselves and put themselves higher in the ranks of the computer world . . . I guess I was wrong. By learning optimizations and how they work, it can give us a better understanding of our current code so that we will realize where things can be optimized for a huge gain(such as in Matrical/Quaternion operations), and where they are better left alone.

  11. #41
    ---
    Join Date
    May 2004
    Posts
    1,379
    ive been looking at masm32 which seems pretty cool but i dont think learning that would be helpful with inline asm in my c programs.
    i have no idea whether its worth learning asm or not and if so which assembler is worth learning for.

  12. #42
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    The only way to make any code faster is to use better algorithms.
    While I understand the concept this statement is not true in all cases.

  13. #43
    Banned
    Join Date
    May 2004
    Posts
    129
    go ask CharlesB on Gamedev.net who is programming a MathLibrary whose entire core is assembler SSE/2 optimized.
    I've chatted with him quite a bit before, and he hasn't posted a project with optimizations, and then the same project without optimizations, so that we could compare the two. I doubt very many people on gamedev.net will have a lot of use for his horsepower mathlib. He does know a lot about the whole optimizations thing, and his time would be better spent working on a large programming project for a company (which, maybe he is, I don't really know).

    I thought that programmers were supposed to accept challenges to better themselves and put themselves higher in the ranks of the computer world . . . I guess I was wrong.
    It is, and you can learn a lot about how the computer works, but this type of optimization takes quite a bit more work than you realize. If you are a newbie, and you are spending all this time trying to optimize your code, then it seems it would have been better to just go and implement something else.

  14. #44
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    It is, and you can learn a lot about how the computer works, but this type of optimization takes quite a bit more work than you realize. If you are a newbie, and you are spending all this time trying to optimize your code, then it seems it would have been better to just go and implement something else.
    I do agree that optimization is not for the faint of heart, as I have been reading through several optimization guides and most of it is such that you could spend a couple of years learning all the little tricks and proper way to do things, which often change between generations of chips. I am just saying that if there is a newbie who can't find a project that s/he wants to desperately work on, but is willing to spend alot of time on something, that they should learn the optimization as it can be very useful in increasing speed so that when you use some things that are slow in of themselves(such as dynamic loading of levels, which I still havent been able to see as an effective way of doing a game. I am personally inclined to load each "level" in one swoop, as both Dungeon Siege and Morrowind really made me get angry when you would be fighting something then accidently hop a "level" border and then you would be dead when the thing loaded up.)

    but I will agree with you that 99% of the programmers here and elsewhere really have no want/need for assembly as 10-20 FPS is not a problem if you can run your game at 100+ fps already. IMHO, however, the real reason I am interested in mastering assembly is for patching/manipulating already compiled code such as in the case of abandonware, where there are some really cool games, but the developers let them slide and never released patches.

  15. #45
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Quote Originally Posted by vNvNation
    Uhh, name an algorithm that you can't implement with C/C++ ? Because I really don't believe that there are any.
    I'm glad you asked that question!

    Most people here are throwing around the notion that most assembly in games is used for intensive 3D graphics. This has some truth, but they don't say why. The reason why is because there are many math calculations that can be done quicker in assembly than using an high level language (HLL from here on out). Reason being, is that any HLL will just use the processor op codes.

    Does anyone here know what the cycle count are for most of them? These numbers are off the top of my head, but for the Pentium 4, addition, subtraction and multiplication are around 5, which isn't going to get faster for the most part. Division is around 40, and square root calcs are hanging at about 56. These number are on integers, and as vBladeRunnervE said, floating point numbers are uglier. Sometimes you can get away with using some of your own bit operations in an HLL to lower these counts. However, one can use use bit rotations that are allowed in asm in order to get really quick calculations. Bit rotation cannot be done quickly without using asm commands.

    If you're working on a console system, you need to work under harsh memory constraints. To help out, it's best to make your own memory manager to handle the stack and the heap. If you do this purely in an HLL, you get pretty good results. When you go down to the asm level and manipulate the registers directly, things get even better.

    Those are just a few examples to think about, there are many other situations which are dependant on specific situations.

    Quote Originally Posted by EvBladeRunnervE
    I thought that programmers were supposed to accept challenges to better themselves and put themselves higher in the ranks of the computer world
    They should, and some do. Those that do and work in the game industry will probably stay there for quite some time, instead of the 4-5 years that an average programmer stays. But that doesn't mean that they should be asm masters. I think that in order to fully understand what any code is doing, one should understand asm, even if it's at a conceptual level. It takes a LONG time to get to the point where one can use asm to it's fullest.

    Quote Originally Posted by Bubba
    Quote:

    The only way to make any code faster is to use better algorithms.



    While I understand the concept this statement is not true in all cases.
    This concept is true for all cases unless you're testing different processors. Some processors are just plain faster, and some may work better with certain algorithms just because the curcuitry is built differently. However, that curcuitry is a giant algorithm on its lonesome.
    Last edited by skorman00; 06-21-2004 at 01:25 PM.

Page 3 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Learning Assembly
    By mrafcho001 in forum Tech Board
    Replies: 5
    Last Post: 03-12-2006, 04:00 PM
  2. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  3. Assembly Help PLease!
    By Tleggo in forum C Programming
    Replies: 2
    Last Post: 05-24-2002, 03:29 PM
  4. C,C++,Perl,Java
    By brusli in forum C Programming
    Replies: 9
    Last Post: 12-31-2001, 02:35 AM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21