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/12/11 5:45 AM, Valeriy E. Ushakov wrote:
>> Frankly, I think it's pretty pointless.  I think that the target
>> audience for these examples is pretty much nonexistent.  People who
>> *think* they are the target audience are better off reading psABI &co
>> instead.
> 
> I agree with you that examples are not an excuse for not having
> documentation.  But having documentation is not an excuse for not having
> examples either: they serve two very different purposes.  Just look at
> any manpage describing an API: it probably contains a piece of code in
> it to demonstrate how to use it.  Or just look at any programming book;
> the problem is, though, that no programming book is going to talk about
> the specifics of NetBSD.
> 
> I'd certainly have hunted down and read tons and tons of documentation
> to come up with a trivial "hello world" myself, but I'd have spent
> hours, if not days, to get something extremely rudimentary working.
> It's only because I found a very similar program online that I'd
> understand the very basics in a few minutes.
> 
> Having a little piece of code that is working right away, that you can
> just copy/paste and tweak to experiment with something else that you
> want to try while learning, is valuable.  FYI, several other people,
> here and elsewhere, have expressed the same feeling.  (OK: this is most
> valuable if you already know another language because then you can draw
> parallels very quickly.)

You still haven't answered my question, who are the target audience?

I look at other files in /usr/share/examples and I do understand how
in the context of using netbsd our users (me included) can benefit
from them when they need to configure postfix, racoon or fstab just to
name a few at random.

If I squint at it just the right way I can, in principle, see the
purpose of the specific example you committed *provided* that there
are also a MI man page on our ELF notes and arch-specific SYS(2) pages
on syscall ABI (lib/libc/arch/*/SYS.h).  But your example as committed
fails to even use symbolic note and syscall names that netbsd headers
do provide!

In another forum you said that your guess is that I "already know
everything there is to know about assembly in all existing
architectures in the world" and made a conjecture that therefore I
think that "people that don't are stupid and don't deserve to have
some trivial code to start learning."  I think I can quote that
safely, since the comment was public.

Both allegations are false, so here is a hint from someone who doesn't
already know about all architectures and who had to learn about them:
gcc -S on simple C test programs, objdump and readelf on existing
binaries can already provide you with most of the examples you
conceivably need.  And you don't need to use absolutely bare-bones
manually crafted ELF binaries to (learn to) program in asm, you write
asm routines that you call from and that can call back into C
programs.  This way you can concentrate on learning the asm and not on
overcoming heroically unnecessary problems that are unrelated to what
you need to learn (soviet times joke about making love standing in a
hammock, wearing full scuba gear omitted).

I don't find examples "stupid" (I didn't use that word either, btw),
but I still have my doubts about target audience, hence my choice of
"pointless".  I also think that linuxish examples/howtos don't quite
become netbsd, so, as I said, if you want to provide documentation for
these areas, please, do it properly.

-uwe



Home | Main Index | Thread Index | Old Index