assemblyx86nasmsine-wave

How to make sine wave using defined frequency on Linux Assembly


i tried to make a tone using sine wave form on NASM x86_32, which i already define the frequency like this:

C: DW 4560
D: DW 4063
E: DW 3619
F: DW 3416
G: DW 3043
A: DW 2711
B: DW 2415
C.: DW 2280

I'm new on Linux assembly, i really appreciate all the help thanks :)


Solution

  • The formula is:

    y(t) = A * sin(2 * PI * f * t + shift)

    (A is the amplitude, f the frequency (Given in Hz), t is the time, shift is the phase shift).

    What will you need for mathematical operations?

    You will need multiplication and sine.

    I will give you a few hints:

    For sine you can use FSIN, and for multiplication FMUL. Furthermore in x86_32, all parameters are passed on the stack. With this informations, you should be able to solve your task.

    Source for sine wave: https://stackoverflow.com/a/50366375/13912132