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 10:34 PM, Valeriy E. Ushakov wrote:
>> [...]
>> 
>> You still haven't answered my question, who are the target audience?
> 
> Me, for example: someone who is reading a book on architecture X, finds
> something interesting that wants to try (like inspecting some particular
> register values) and has no trivial way to do so right away because all
> the examples in the book are written for a different assembler and I
> have no idea how to manually construct a pure assembler binary for
> NetBSD that performs the correct syscalls.  (My memories vaguely include
> dos x86 code, which is very different as you may know.  E.g. I wouldn't
> know how to write an x86 hello world for NetBSD right now.)

I don't think that constructing standalone binaries is a good way,
didactically, to learn an assembler.

> Some other people in this thread have expressed why they think this
> would be valuable to them.  Granted, in the current form, the code does
> not cover their "use cases" yet.  The most obvious of these is having an
> example that shows how to write an asm function that can be called from C.

As I said, cc -S is your friend here.  It will give you infinite
examples of exactly what you want, where you use C to express what you
want.  Throw in -fpic, -fomit-frame-pointer etc for more fun.

-uwe



Home | Main Index | Thread Index | Old Index