How to access sound card on linux using nasm

hi i want to know how can i access soundcard from nasm build program using int 0x80. and also what values ​​should be entered into the registers when accessing the sound card.

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

I've done a lot of searching and there are a lot of c libraries, ALSA and OSS and the like, but I would like anyone to know about some resources about learning the basics about an assembly program that interacts with hardware.

and if anyone can give me a small list of codes on how access is done I would be very grateful.

0


a source to share


4 answers


As you noticed, the interface between user space and kernel space in Linux is INT 0x80.

On Unix, as a matter of philosophy, (almost) everything is a file, so sound cards are treated as "Symbol files". The core of syscalls conforms to the POSIX specification - thus "open", "closed", "ioctl", "read", "write".

The sound card is accessed through the driver interface as a file under "/ dev /". Some of the sample documentation is in the OSS documentation , but I'm not sure if its the current one.

To observe this message, you can use 'strace' to find out what system calls are in use by any existing application.

You will probably see a sequence like:



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

Usually you should "open" through the C library, but since you want to skip this, you can find syscalls in several ways - one way is

      objdump -d /usr/lib/libc.a

For example, you can find that open is syscall 0x5 by looking for < __libc_

open>: You will notice that eax is 5 and the rest of the parameters are in ebx, ecx and edx. (Usage and options are also listed on Linux Syscalls )

+1


a source


This is what sound card drivers do. They must be written for each custom sound card in order to implement a common API that can be used by O / S or applications. The same goes for other hardware devices. Equipment manufacturers tend to be less open about how to access their materials at this level (on the one hand).



Not that I'm a Linux expert, but this is a pretty fundamental problem for all O / S.

+1


a source


This won't work from user mode - you won't have direct access to audio hardware.

If you create a kernel mode driver, you can directly create the sound card hardware, but at this point I think most vendors have different implementations and do not follow an agreed upon standard. Newer sound cards may still be compliant with Adlib and SoundBlaster 16 - this was the WAY hardware standard when games were targeting DOS and directly using the hardware, but I wouldn't be surprised if that's no longer valid. A quick search should provide ways to directly access the interface for these legacy maps. Alternatively, you can run DOS inside a virtual machine and access the hardware - most virtual machines emulate this soundcard level.

0


a source


Depending on what you are trying to do, you are probably better off using an existing library to handle the interface on the soundcard, unless you intend to write a soundcard driver, which I doubt would be better done in C on linux.

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

FMOD seems great with game programmers, although it's not free.

sdl mixer is another one that is great with Linux game developers.

JACK is the world's largest pro-audio linux. (I think ardor is the linux answer for Protools.)

There is no point in trying to talk to audio equipment directly from user space.

0


a source







All Articles