[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: life extension of old computers thanks to opensource Contiki
Peter de Vroomen wrote:
Learning to code in ARM assembler is by no means a useless skill, as it
is directly applicable to modern-day engineering tasks.
No, of course not, but optimizing for a RISC processor is simply more
challenging than optimizing for a CISC processor. If you want to learn
assembly, it's best to start with a CISC processor, learn the basics, and
then step up to the RISC processor.
Though I tend to agree with your conclusion about learning programming,
it is an error to think that optimization for a CISC machine is easier
than for a RISC machine.
RISC architecture was motivated by advanced compiler writers discovering
that straightforward use of CISC instructions was *not* optimal. Often,
much better speed could be achieved by ignoring the storage-to-storage
forms of CISC instructions entirely, and using, for example, register
loads and stores to move strings--not at all what the CISC architecture
suggests is appropriate.
Further, the procedure linkage instructions provided in CISC machines
were almost always either too much or too little for the job at hand
if optimality was the issue.
In virtually every case where the CISC architect had attempted to
close the mythical "semantic gap", an efficiency pitfall had been
created.
John Cocke proposed a RISC architecture precisely to regularize the
instruction set and match it to the hardware, so that an optimizer, in
generating code, would have fewer inefficient choices offered!
The demands that RISC makes of optimization is not combinatorial search
and simulation of all possible ways of doing a task, but simply the
repeated application of determinstic algorithms to allocate registers,
schedule instructions, etc.
Of course, as things have become more deeply pipelined, superscalar,
multi-level cached, etc., all machine architectures have become more
complex to program efficiently...
Hand-optimization will allways be needed, and a good programmer can probably
optimize the code better than a compiler can. But hand-optimization only
applies to small pieces of the code, like Interrupt Service Routines.
Generally a program consists of more than just an ISR :).
And about 'RISC architecture'... Of course these days the differences
between RISC and CISC are pretty muddy. A Pentium 4 processor has all the
characteristics of a RISC processor, but it still has a CISC instruction
set. So does the AVR. The PIC, however, has an instruction set that is
really RISC. Very limited, but every instruction is executed very fast.
Often you need more than one instruction to accomplish something a CISC
processor does in one instruction.
CISC processors have assumed the implementation character of RISC
processors, but there is still a huge difference in what can be
directly expressed in the machne language.
A CISC assembly language programmer has little recourse but to
re-compute effective addresses that the RISC programmer would have
saved in a register for re-use. And the CISC programmer will have
to allocate some variables to memory that a RISC programmer would
have kept in the register file.
These differences make a considerable difference in advanced
assembly programming on the two styles of machine.
-michael
Music synthesis for 8-bit Apple II's!
Home page: http://members.aol.com/MJMahon/
"The wastebasket is our most important design
tool--and it is seriously underused."