pc_speaker.S 714 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "common.h"
  2. BEGIN
  3. /* Chanel 2, square wave, load TODO?, binary */
  4. mov $0xb6, %al
  5. out %al, $0x43
  6. /* Set frequency of Channel 2. */
  7. .equ div, 1193181 / 1000
  8. mov div, %ax
  9. out %al, $0x42
  10. mov %ah, %al
  11. out %al, $0x42
  12. /* Dummy read of System Control Port B. TODO why? */
  13. in $0x61, %al
  14. /* Enable timer 2 output to speaker.
  15. * THIS is where the sound begins.
  16. */
  17. mov $0x03, %al
  18. out %al, $0x61
  19. /* Loop forever to keep hearing it. */
  20. loop:
  21. nop
  22. jmp loop
  23. /* This is how a sound can be stopped.
  24. * This code never reached in this example.
  25. * unless you hack it up.
  26. */
  27. in $0x61, %al
  28. mov $0x00, %al
  29. out %al, $0x61