Assembler: suggestions?

Not for me. I greatly prefer RISC + orthogonal instruction sets. Even the AVR processor is a tiny bit too quirky for me (e.g. some instructions don't work with "low" registers). The limited number of registers, the special purposes, and the freakin' modes of the Intel x86 family just drive me batty. Having to get the right thing in the right register at the right time is just too distracting.

Another thing I can't stand are pipeline architectures (still in the context of assembly programming). Just try to guess how long an instruction will take to execute. I dare you. Will this pattern cause a stall? Did I miss a data alignment? Gurf! Just give me a good compiler!

Thank you for pointing that out to the ones who don't already know that :slight_smile:

... against a couple dozen when coded in pure asm ...

Well my 8 bytes of code in C++ is less than your "couple of dozen" in pure asm.

I really didn't want to make it a competion ... I'm still working out ... let's catch up when I'm fit enough to battle :astonished:

By all means learn assembler. I learned various variants of it over my life, and it is useful to know. But don't do it because you think you can write tighter code than the compiler. In most cases you can't.

That's more close to reality :slight_smile:

Cut a long story short, all the older timers (me included) appear to have a similar approach which is to write C/C++, but when you need to get things done quickly or do something at the hardware level - access the AVR Registers directly.

If you read through some of the libraries you will get a good feel for this style.

When you see this

DDRB |= (1 << 3);

Its accessing the data direction register directly to set a pin to output

Or this

PORTB ^= (1 << 3);

This is toggling pin 3 on portb much faster than digitalWrite.

See here for a starting point -

Also note the warnings

Duane B

rcarduino.blogspot.com

DuaneB:
Cut a long story short, all the older timers (me included) appear to have a similar approach which is to write C/C++, but when you need to get things done quickly or do something at the hardware level - access the AVR Registers directly.

I say! I totally agree with this point of view, I have not one single point against it.

Still, I will spend the next few months trying to grab the best out of this experience. I know it will pay off, it always does :slight_smile:

Btw ... this is one of the culprit that made me look into low level programming:

I know it's not about AVR at all ... but when I read those crystal clear examples ... I had to put my hands on asm at all costs!!!

robitabu:
Btw ... this is one of the culprit that made me look into low level programming:

Interesting! Had not ever run across one. Still available (and on sale) at Edmund Scientifics!

Also CARDboard Illustrative Aid to Computation - Wikipedia

Oh yeah! It's looks like a neat little game, it's a great educational tool instead ... despite the simplicity of the topics covered, I've found it mostly clarifying :slight_smile:

(slightly ot)

Speaking of compiler and assembly language...

http://www.linuxjournal.com/content/introduction-gcc-compiler-intrinsics-vector-processing