tags:

views:

426

answers:

4

hello i want to know how i can access sound card from nasm assembly program using int 0x80. and also what values should i put in the registers when to access the sound card.

is there any manual or something that has details about the arguments that we have to pass to the kernel to access the sound card or other hardware devices, please if anyone know please tell me.

i had done alot of searching and well there alot of c libraries and ALSA and OSS and stuff like that, but what i would like is that if any one know of some resources about learning from the basics up about assembly program interfacing with the hardware.

and if any one could give me a small code listing as to how the access is done i would be very thankful.

A: 

From user mode, this won't work - you won't have direct access to the sound hardware.

If you create a kernel-mode driver, you'd be able to directly poke the sound card hardware, but at this point I think most vendors have different implementations and don't follow a consistent standard. Newer sound cards might still be Adlib & SoundBlaster 16 compatible - this was the hardware standard WAY back when games were targetting DOS and directly used the hardware, but I wouldn't be surprised if this is no longer valid. A quick search should yield ways to directly access the interface for these legacy cards. Alternatively, you could run DOS inside of a virtual machine and access the hardware - most virtual machines emulate this level of sound card.

Michael
+1  A: 

This is what sound card drivers do. They have to be custom written for each sound card, in order to implement a common API which can be used by the O/S or applications. The same goes for other hardware devices. Hardware manufacturers tend to be less than open about how to access their stuff at this level (for one thing).

Not that I'm a Linux expert, but this is a fairly fundamental issue with all O/S's.

Pontus Gagge
+1  A: 

As you've observed, the interface between user-space and kernel space in Linux is INT 0x80.

In Unix, as a matter of philosophy, (almost) everything is a file, thus sound cards are treated as "Character Files." The kernel syscalls are as per the POSIX specification - so "open","close","ioctl","read","write".

Access to the soundcard is done through the driver interface, as a file under "/dev/". Some sample documentation is at OSS documentation, but I'm not sure if its current.

To observe this communication, you can use 'strace' to see what system calls are being used by any existing application.

You will likely see a sequence like:

     open("/dev/dsp", ... ) 
     ioctl() 
     write() 
     ... 
     write()
     close()

Usually you'd get to "open" through the C library, but since you want to skip that, you can find the syscalls a few ways - one way would be

      objdump -d /usr/lib/libc.a

For example, you can find that open is syscall 0x5 by looking for <__libc_open>: You'll notice that eax is 5, and the rest of the parameters are in ebx, ecx and edx. (The usage and parameters are also listed on Linux Syscalls )

caffiend
A: 

Depending what you're trying to do, you're probably better off using an existing library to handle the interface to the sound card, unless you aim to write a sound card driver, which I doubt, and that would be best done in C on linux.

Portaudio is one (free) one that's relatively easy to use. one example lib using portaudio with a C interface (I'm the author of wwviaudio).

FMOD seems to be big with the game programming guys, though it's not free.

sdl mixer is another one that's big with the linux game developers.

JACK is big in the linux pro-audio world. (think ardour -- the linux answer to Protools.)

There's no sense in trying to talk to the audio hardware directly from user space.

smcameron