tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Adding asm examples



Julio Merino <jmmv%netbsd.org@localhost> wrote:

> On 11/14/11 12:26 PM, David Holland wrote:
>> I'm not convinced that reading compiler output is a good way to get
>> started on anything.

I'm not referring to random compiler output.  I'm referring to
compiler output of small programs that demonstrate some specific
scenarios, like a function call, a structure member access, etc.  E.g.

  extern void bar(int, int, int);
  void foo() { bar(1, 2, 3); }

The mail that started the thread presupposes a book, which should
already provide enough background to read compiler output for such
test programs.  All books on assembler will cover calling conventions
&c anyway and psABI is not that hard to read either.

Actually, I would say that reading compiler output (in general) is not
that bad way to start, either.  As some linguist said, a very
effective way to really improve your $human_language (he was talking
about Sanskrit, iirc) is to prepare a critical edition of some text in
that language.  Immersion might seem tough, but it is effective.
Anyway, my advice was about simple programs which shouldn't unduly
strain anyone, really.


> Exactly my point.  I could also RTFS of things people have pointed out, 
> but that's not my idea of "learner-friendly" material; specially for a 
> complete newbie in a topic.

I understand your enthusiasm, but I still don't think teaching
complete newbies assembly programming to be something that netbsd
should consider a useful goal.  Especially so when the examples you
choose are hardly "learner-friendly".

As I said, you are not helping any newbies, yourself included, when
you start with completely standalone manually crafted binaries.  The
first example you start with is mostly just confusing (any perceived
"look ma, no libc" coolness factor notwithstanding) and irrelevant
(very very few people should even care, definitely not the newbies).

If you are excited about that coolness factor, make a blog post about
it or something, but it doesn't need to be in the repo.  It's like
vanity configs.

The other example you mentioned (taking arguments from a C call) is so
trivial/essential that your textbook and architecture manual should
already have it - duplicating that material in /usr/share/examples
hardly adds any value.  There are also a lot of permutations:
returning a struct, passing a struct, passing floating point values,
passing sufficiently many arguments to run out of registers and
different combinations of the above.  Asking compiler (with a suitable
test program) is easier and doesn't limit you to the few examples
manually crafted for you by someone.  There are also architectures
where you cannot just say: "oh passing arguments is easy, you just
load them to registers M to N (or push them into the stack)," - make a
nice looking example and feel good about it.  For VAX you will have to
explain the call frame layout as automagically created by call*
instructions.  For SPARC you will have to explain register windows.
For IA64 you will have to explain the version of register windows
created by Escher on a bad trip.  And all that is already done by
textbooks, manuals and standards.


PS: What's next, a C tutorial?

-uwe



Home | Main Index | Thread Index | Old Index