On Wed, 2004-06-23 at 18:22, Sam Halliday wrote: > btw... maybe a totally wrong mailing list to be askign this question... but > i'd > really really like to do some assembly programming on my PPC. can anyone > reccomend a good book to learn PPC assembly? i have never done ANY assembly > before, so a beginners book would be best as i find learning by example (i.e. > gcc output) to be quite intimidating.
To start off, gcc output will vary. There are a couple options to make it more readable. As far as I know, you're pretty much stuck with the awful books from Motorola. You can get them from Motorola's web site in PDF format. Ones that are fairly recent (neither too old nor too new) can be ordered for free as paperback. Note that: The index is truly dreadful. Many instructions are alternate names for other ones, often with some of the arguments implied. None of these aliases may be found in the index. Motorola uses big-endian bit numbering. The bit used to represent 4 is number 61 on a 64-bit processor, and is number 29 on a 32-bit processor. Books that cover both 32-bit and 64-bit PowerPC thus have to show two ways to number each control or status bit. Watch out for register 0 in load/store ops. The good stuff, like AltiVec, isn't merged into the main book. There isn't one book covering all opcodes. To know what processors support an opcode, you'll have to look at all of the processor-specific manuals. It's not like the Pentium-4 book, where all the opcodes are listed along with when they were introduced. Intel even lists many of the old bugs and workarounds, but Motorola? Noooo.... You must dig through errata documents, many of which are secret. You'll have a hard time digging up info on the popular calling conventions. You can start with the SVR4 ELF ABI from SCO. That won't cover AltiVec or thread-local storage, and it leaves some other stuff poorly defined. The assembler itself is another matter, though at least with PowerPC you'll find that opcode syntax is mostly what you find Motorola using. Make good use of the rlw* and mulhw instructions. Watch what the compiler does using those when it must divide by a constant.