Skip to main content
gamedev.net
🔒 Locked

Assembly code vs C/C++

Started by KGB Jul 7, 2000 at 4:20 PM 5 replies 550+ views
Original Post
KGB
KGB
I already know some C and C++. I have a book on Assembly code and am I debating wether to read it or not. I am not a master of C and C++. So any feedback on Assembly code vs C++/C would be very much apprietiated. I need a spel chezquir!!!!!
JPG
Gladiator
Gladiator
I started laughing once I saw the title.. Of course if you''d like to learn ASM, it''d be useful in game programming to speed some uneffecient algos if there''s no other way out... if you know how to work out everything in ASM, you''ll be able to speed your code up quite a bit.,.. but it takes a while to learn ASM... and a pretty long time to master it...
tcs
tcs
Today, the algorithm is more important than its implementation. When you have a good engine and a bad engine. Then you recode the bad engine in ASM. The good one will still be faster...
A bubble sort in ASM is slower than a quicksort is C++. And a buggy, crappy engine like Ultima9 wouldn''t run mouch faster in ASM. I don''t think that doing something in ASM makes a big difference... unless you want to write a device driver ;-)

Tim

--------------------------
www.gamedev.net/hosted/glvelocity
glvelocity.gamedev.net
www.glvelocity.com
Tim--------------------------glvelocity.gamedev.netwww.gamedev.net/hosted/glvelocity
win32mfc
win32mfc
Well, I would suggest that you at least try it out. Go through some examples in the book and get an understanding of what registers and operations there are. You might try and implement some C/C++ functions with inline assembly, to get the hang of that. Then, if you''re ever in a pinch for speed, you''ll be at a good starting point.

It''s true though, assembly is no trivial thing to master and takes a lot of practice/coding. I think you''ll be much better off learning how to use it when necessary and sticking to the "application" instructions -- you don''t need to get into all the instructions for memory management (TLB''s, etc), security descriptors, etc.. Stick with the basics.. at least in the beginning.. moving, shifting, comparing, add/mul/div, loops, jumps, etc..

// CHRIS

// CHRIS [win32mfc]
Great Milenko
Great Milenko
well I started with c/c++ my self and about a year ago I started learning assembly... even when I have no plans for using assembly in a pice of code the knowlogo gained from my understanding of assembly has help an ungoddly amount... knowing roughly what is being done on the assembly level help alot in know if a pice of code is going to be fast or slow...(it might help to think that c/c++ compilers trancelate the code into assembly then compiles the assembly code... not realy how it works but until you know more it might help =)

also there are about 3-4 places in my current project where I''ve seen no way around using inline assembly to code it... so it does come in handy like that every now and then...

yes assembly... properly place can work wonders on speed if you know how and where to put it... theres some articals on here explainning the basics of this when your ready....

make no mistake about it... assembly is a bear to learn but after you get the basics it starts to go alot easier....

tcs: I don''t think that doing something in ASM makes a big difference... unless you want to write a device driver ;-)

and in writing your own operating system too =P

anyways good luck,

Great Milenko

Words Of Wisdom:
"Never Stick A Pretzel In Your Butt It Might Break Off In There."


http://www.crosswinds.net/~milenko
http://www.crosswinds.net/~pirotech

The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
Garr
Garr
Depends on how good you write your code, you can write in assembley but the algorithm itself can be slower than someone who is writing top notch c code. It all depends on how good you are at writing algorithms.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.