Am i Mad?!: PowerPC Assembler

hyph-n

Registered
I'm a professional C/C++ programmer, but i fancy something that will stimulate the old grey matter......

.....i've done some Z80, 68000, & 8086 (spit) assembly in the past - i think it is about time i have a go with some PowerPC assembly :D

Can anyone recommend an assembler & a good reference guide..?
 
what do you mean? Are you saying that you've been programming for 68K's for years and now you want to switch to programming for PowerPC's????

-whitesaint
 
I actually mean that i have done some 68k on an Amiga 500/1200/2000/4000 using the DevPac(?) assembler, more specifically using the 68000/68020/68030.... but that was a long time ago (10+ years!) Also did some Z80 on a ZX Spectrum 48 (which would have been around 1982!)

I'm not scared of Assembly, I understand
generally how CPUs work (registers etc..)..

What I need is a good guide to how the PowerPC (74xx?) is constructed & a reference of the Instruction Set - Also, all of the previous CPUs I've hacked have been CISC, whereas PowerPC is RISC - what practical difference does that make?

Assuming that i can get the reference material, is there a defacto Assembler to use (console based is cool, but can live with GUI solution as well)

...
 
Originally posted by hyph-n
Assuming that i can get the reference material, is there a defacto Assembler to use (console based is cool, but can live with GUI solution as well)

...

When you install the developer tools, you will have an assembler installed. For info on it, just do a man as.
 
great stuff! - I had already installed the Developer Tools & have indeed got the 'as' command :)

-cheers!-

guess all i need now is the reference material
:)
 
I realise that this was posted long ago, but I wanted to answer anyway...


according to my SE/CS-teachers, it's virtually impossible to write assembler for PPC as for any true RISC-processor, because of the minimal instruction set and the fact that the processor doesn't execute the instructions in a somewhat non-deterministic manner. it would be nice though to see some code...


theo
 
thanks for the top-tip iconara....

... guess i must be Mad then?! ;-)

.... i'll update you when i've written something... (even if it just adds 2 integers together!)
 
I'd be interested in seeing some working code, too. I thought I needed to write some awhile ago and found a few resources, which I've now lost. I recall that apple had a page explaining the mnemonics, as did motorola. Google is your friend.

By the way, I wound up not needing assembly, so this panned out to nothing for me. Whooo....
 
an easy way to get a feel for ppc asm is to compile a simple C app with gcc -static -S bleh.c ..it'll give you a .s file with the (sometimes obfscuated) att syntax ppc asm that you can simplify and make faster (not usually possible unless you're really smart)
 
Well, writing PPC Asm is actually nicer than writing in 68k or x86 Asm (IMO, I have tinkered a bit, back in the 601/603/604 heyday), BUT... the teacher who said writing it was nearly impossible got a little confused.

It is EASY to write PPC Asm... writing GOOD PPC Asm is nearly impossible (but doable). These days a C compiler can produce faster code for a P4, Athlon, or PPC than a human can at the asm level. The difference between the two only starts adding up and being noticeable in the larger apps though.
 
Originally posted by Krevinek
Well, writing PPC Asm is actually nicer than writing in 68k or x86 Asm (IMO, I have tinkered a bit, back in the 601/603/604 heyday), BUT... the teacher who said writing it was nearly impossible got a little confused.

Talking out of his rear end would be closer to the truth.

It is EASY to write PPC Asm... writing GOOD PPC Asm is nearly impossible (but doable). These days a C compiler can produce faster code for a P4, Athlon, or PPC than a human can at the asm level.

You are talking about a good, optimizing with deep and intimate knowledge of target processor internal pipeline architecture C compiler here. Sadly, gcc is not such a compiler. TANSTAAFL, I guess.
 
ladavacm: I have never seen the acronym "TANSTAAFL" before, I'm curious.

I was under the illusion that GCC was the best there is, is this not so? (My world is falling apart =) ).


theo
 
I still stand by the fact that a C compiler can produce better code than most humans these days. GCC needs work, yes (especially for a pure RISC chip like the PPC series) but the issue comes down to general optimization.

A human tends to think in linear terms, even some of the better programmers. With multiple Integer, Floating Point, and (possibly) Vector units available in the recent G4s, it becomes real difficult to keep that all straight AND think non-linearly.

As I also said, the difference becomes more noticeable as the project gets larger, as you have more lines of code to tweak and analyze in a fashion that you don't have to do with C.

Asm isn't bad for small projects, but I have seen some time-critical apps (written for MetroWerk's compiler) gain a little better performance by moving from Asm to highly speed-optimized C.

All this is academic of course, since programmers are lazy and leave stuff unoptimized...
 
I hear that wordperfect was written mostly in assembler... and fast it was, but not in development.... (may it's soul rest in peace)



has anyone tried Java-assembler, that's one cool thing (never seen it though), talk about poinlessity!



coolness == pointlessity
 
Also note that WordPerfect was written before the age of multiple instruction units and the pipeline-crazy development of the past few years.
 
I am amazed at some of the reply's here..

People saying that its impossible to write PPC assembler...

Thats mental. Alitvec is unreal.

You guys should checkout forums.3ivx.com and www.macdvd.org/cgi-bin/Ultimate.cgi where all they do is talk about writing more altivec to get a few for fps when decoding/encoding MPEG2 and MPEG4 stuff.

checkout MacMPEG2Decoder (MM2D) on Sourceforge.. there are files and files of Altivec (mostly for the iDICT routines)

Talk to Stux (lead programmer of 3vix) about Altivec.. he's been optmizing the encoder of the codec for ages now, says he writes nothing but Altivec.

There is a reference page somewhere at apple.com that explains every altivec command and what they do.. can't remember it tho, see if you can find it.

hope this keeps you interested.
-Dan
 
well Altivec is not PPC. They are two separate beings (PPC is the CPU, Altivec is a slave/helper processor).

You cannot write more efficient PPC assembler than GCC, but you can probably hack good Altivec assembler if you're into it.

It's not just PPC assembler in particular, it's assembler for any RISC-processor (excluding Pentium, since it runs CISC instructions). You can still hack 68K for PPC, as far as I know, but the instructions are emulated and won't run faster than a Quadra...



Theo
 
Originally posted by iconara
ladavacm: I have never seen the acronym "TANSTAAFL" before, I'm curious.

I was under the illusion that GCC was the best there is, is this not so? (My world is falling apart =) ).


theo

There Ain t No Such Thing As A Free Lunch

ladavacm, i was also under the impression that gcc was the finest compiler ever. is that only true for x86? is it even true at all? is gcc not designed for RISC processors? i was also under the impression that the RISC/CISC designation was anachronistic and no longer accurate. i m no expert though

i know that motorola released a patch for gcc to give it altivec support. i ve also seen that a lot of altivec is being merged into the main tree. i would expect apple to also want to do a lot of work on gcc to make it work well on the PPC architecture, including, but not limited to, improving altivec support.

so is this the case?

and, if there really is no such thing as a free lunch, what is a good compiler for PPC or altivec? the only other compiler that i have ever used is codewarrior. does it stack up?
 
Originally posted by lethe


There Ain t No Such Thing As A Free Lunch

ladavacm, i was also under the impression that gcc was the finest compiler ever. is that only true for x86? is it even true at all? is gcc not designed for RISC processors? i was also under the impression that the RISC/CISC designation was anachronistic and no longer accurate. i m no expert though

i know that motorola released a patch for gcc to give it altivec support. i ve also seen that a lot of altivec is being merged into the main tree. i would expect apple to also want to do a lot of work on gcc to make it work well on the PPC architecture, including, but not limited to, improving altivec support.

so is this the case?

and, if there really is no such thing as a free lunch, what is a good compiler for PPC or altivec? the only other compiler that i have ever used is codewarrior. does it stack up?

gcc is a far cry from a good optimizing compiler; the only compiler that I know to be generating worse code is Visual C++ version 5 (the last version at which I have actually taken a deep look)--I cannot comment on others.
gcc is (un)fortunately, free. It also pretty much killed the market for UNIX (C) compilers. It is adequate for most tasks.

By todays terms, the internal architecture of gcc is quite antiquated. It (at least, used to) models an unlimited register machine which is closer to CISC than RISC (if, indeed, there ever were such things; not even the original SPARC was really RISC). With the current processors being more akin to data flow engines emulating CISC or RISC, one really has to know the internals of every CPU generation to keep internal execution units as busy as possible at all times, even though all these generations (claim to) implement the same external programming model. gcc tries to implement such optimizations at a relatively late stage, with insufficient knowledge of the CPU internals (these being the crown jewels of the respective manufacturers)

Improving gcc has become somewhat difficult, and is hampered by the gcc's design goal to be easily re-targettable (i.e. it must be possible to support many different CPUs; therefore the inability to support them really well).

I cannot comment on CodeWarrior, since I have never owned or used it; you must have guessed so far that my background did not include Macs until they became UNIX boxes :) But, I would expect Motorola being able to create better compiler than gcc, especially because they are using it for SPEC benchmark suite.
 
Back
Top