On Fri, Oct 12, 2001 at 08:27:30PM +0200, CeDeROM wrote:
> Paul Davis wrote:
> > Linux runs on at least a dozen h/w platforms. AFAIK, no device driver
> > directly includes assembler, and if they do, they are unlikely to be
> > part of the mainstream kernel. They certainly wouldn't be part of
> > ALSA, I would hope.

There is indeed no device driver written in assembly.

> a part of assembly-howto :)

Probably written as a proof of concept, not something that is generally
useful.

> Meanwhile, here's an example of a minimum dumb kernel module
> (module.asm)
> (source is based on example by mammon_ from APJ #8):

[snip]

> Small, huh? :)

It doesn't compile on my StrongARM, so what was your point again? If
you made the module in C, it would have worked. Why do you think
Thomson and Richie made the decision to rewrite the early UNIX kernel
in C?

> > You seem to be under the same mistaken impression as many people that
> > assembler is always quicker.
> 
> I'm writting programs for microcontrollers in assmbler - te final code
> fits in about 2000 lines and takes about 2kB... I know how much would it
> take, if I wrote it in C or BASIC...

I'm writing a bootloader for StrongARM in C because it allows me to
develop it *much* faster.

It's currently 800 lines of assembly to do the really dirty system
setup code (accounting for about 1kB of code), and 5000 lines of C to
do the more useful things like serial port I/O, downloading kernel
images, flash programming, and booting linux. Total binary size is
about 12 kB.

I'm going to add bootp+tftp support pretty soon. For that I'll need an
ethernet driver, a TCP/IP stack, a bootp implementation, and a tftp
implementation. My estimate is that it will take me about three days to
implement and test it in C. If I would do it in assembly, I think it'll
take me three weeks.

> I know how it looks from "very hardware" side / experience.

So do I, because I use C.

> C uses libc and some others... that takes time, so i think it's slower.

C programs don't need to use a C library. My bootloader can't use a C
library because there's no kernel running at that point. Yet it's
written in C and it still works.

You just fell into the pitfall of optimisation: Never *think* something
is slower, *measure* if it is slower. Optimisation is not about using
assembly. Optimisation is about profiling your program, recognising the
bottlenecks, fixing the obvious bugs, rethinking the design, using
faster algorithms, and only as a final resort coding *small* parts of
the program in assembly.

> Well, it not MUST be written in assembler... if C would be easier, i
> would
> use C... but I thought that asm would be simplier/faster.

You're severely misguided: C is easier.

> > If you've never written a kernel module, or even a time sensitive
> > program, its quite possible that the compiler will do a better than
> > you :)
> 
> I would have to call function, make everything i want and finish, before
> aprox. 22usec... would it be enough?

Toggle some lines on the parallel port and measure if it works.

> In uC I had timers, by which i could call an interput after demanded
> time.
> Is there something like this under linux?

Yes, the PC has some timers, but I'm not sure they go as fast as 44kHz.

> > See "Linux Device Drivers" by Rubini, A., published by O'Reilly. (...)
> 
> I would really love to, but i have no ability to buy this :((((
> There must be some online documentaion...?

The second edition can be downloaded for free from the O'Reilly
website.


Erik

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2783635  Fax: +31-15-2781843  Email: [EMAIL PROTECTED]
WWW: http://www-ict.its.tudelft.nl/~erik/

_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to