If the OS sound driver is not connected to this device (and it looks like it is not the way it comes from the sound card device), you will have to go directly to it with the ASM code. You may even have to put it in the driver (user mode should work fine) to gain access to the hardware.
Assuming you are on X86 (I have never seen an ARM device with a speaker on the motherboard), then the code is no different from the code used by someone running some other OS (since you are heading directly to the hardware). A quick search for "x86 beep in asm" showed a couple of promises.
source share