0

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 :)

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
AFOEK
  • 37
  • 8

1 Answers1

2

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

JCWasmx86
  • 3,473
  • 2
  • 11
  • 29
  • Thanks @JCWasmx86... but i still doesn't understand how to calculate the for the y(t) in assembly.. can you broke down how i do it ? Thanks :) – AFOEK Aug 03 '20 at 11:30
  • @felixmontalfu How far did you get? – JCWasmx86 Aug 03 '20 at 12:03
  • still figuring how i calculate sine wave, and how i push it to speaker driver – AFOEK Aug 03 '20 at 12:57
  • [Github](https://github.com/AFOEK/KeyPressASM/blob/master/key.asm) here on my GitHub sorry for the mess...:) @JCWasmx86 – AFOEK Aug 03 '20 at 13:03