Sign in to follow this  
atonalpanic

assembly languages

Recommended Posts

Hello, I was wondering about which particular instruction set PCs run. Right now I'm studying MIPS instruction set architecture, but I can't write programs with it that run on my PC. Although, I can write programs that simulate running on my PC...that doesn't help me much. I'm taking a course using COMPUTER ORGANIZATION AND DESIGN by PATTERSON & HENNESSY, so I'm not entirely new to the concepts and general assembly syntax. I just want to be able to speed up my C++ code every now and then. I'm thinking I would use x86 instruction set architecture, but I don't know that. So can anyone recommend a good book that would explain the most common PC architecture set without it treating me too much like a baby? Basically since I already know the basics, I would just need to learn the language and peculiarities of it that say MIPS wouldn't have. Thank you, Ryan

Share this post


Link to post
Share on other sites
PC's typically use x86 based cpus (Intel or AMD). Check out The Art of Assembly. Here's a wikibook: x86 Assembly. Here's a list of other assembly books available online: Assembly Language. There's a better set of links to the Intel manuals here: x86 assembly language, those are a must have for any serious asm programming. Check out the AMD web site for their manuals. AMD chips are compatible but there are a few slight differences. And remember, [google] is your friend.

Share this post


Link to post
Share on other sites
Download reference manuals for various architectures, all the info you will probably ever need as a programmer is right there. Aside from x86 and MIPS, the usual suspects are ARM, POWER, SPARC, DEC Alpha. Some other interesting ones are Blackfin, SuperH, ColdFire.

Share this post


Link to post
Share on other sites
IMHO you don't actually need a book. If you are interested in the instruction set, just read the reference material provided by AMD and Intel. If you want to use inline assembly you need to consult your C++ compiler's manual. You'll probably find that it's not worth the hassle unless you want to take advantage of newer CPU features that are not integrated into your compiler yet.

However, the reference manuals and programming guides provided by the CPU manufactuers as well as the compiler's manual should be sufficient to use assembly code in your programs.

Best of luck,
Pat

Share this post


Link to post
Share on other sites
Thank you all! Well using MIPS sparked my intrest in low level code. I always wanted to learn to code in 0's and 1's, even if it was just one instruction. The reason I want to learn x86 is because I can assemble it on my PC and see results...instead of hex in a register of a simulated MIPS chip. I have always been interested in games, but in reality I'm going to need to work my way up. Seeing as how there are jobs for assembly coders, and it is fundamental to all machines and is the underlying hardware-software interface for higher-level languages..etc... it seems a necessity to learn. I'm not completely sure, but designing optimazation algorithms for C++ compilers that make the most advantage of local/global optimazations seems interesting to me.

I agree that compilers optimizes code better than most humans, but there is alot of room for improvement. Mainly because compilers won't optimize code if it assumes there might any error associated with that optimization. Even if other parts of the program ensure that that error won't happen, compilers won't optimize out of safety to preserve the function working in every case. Why can't we apply a pattern that determines if certain error-causing cases are prevented throughout the global scope of the code? I know there are research compilers out there that are testing this, but where are the results?

I hope this makes sense, and sorry if my explaination for learning assembly seems more of a rant. I just want to learn it possible to work in compiler design, work my way through various fields of computer science and see what I like best.

Regards,
Ryan M.

Share this post


Link to post
Share on other sites
Most compilers have switches to allow "unsafe" optimizations. Probably the most notable one is to assume that no aliasing is happening (where two variables might point to the same data) as this really lets the compiler get down and dirty with register juggling.

Relatively new techniques such as "whole program optimization" alieviate some of the need for "unsafe" optimizations because the compiler really can determine if its safe or not.

All in all though, most optimization "research" is directed at targeting the specifics of particular CPU architectures .. there is always more than one way to skin a cat and sometimes the "best" way for a specific CPU is deceptively non-intuitive (avoiding stalls related to partial updates of the flags register on modern x86's comes to mind .. "more" is often "less", and even more so these days)

You will want to check out Agner Fog's optimization guides.

Share this post


Link to post
Share on other sites
Quote:
Original post by atonalpanic
Even if other parts of the program ensure that that error won't happen, compilers won't optimize out of safety to preserve the function working in every case.

True, although in Visual C++ you can tell the compiler about these assumptions using the __assume-intrinsic. That enables the compiler to optimize stuff to the max, without the need to put in assembly.

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