in_beep_illinois.S 726 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. Originally from: https://courses.engr.illinois.edu/ece390/books/labmanual/io-devices-speaker.html
  3. Same as the kernel version.
  4. */
  5. #include "common.h"
  6. BEGIN
  7. start:
  8. PUTC $'a
  9. mov $0xb6, %al
  10. out %al, $0x43
  11. mov $4560, %ax
  12. out %al, $0x42
  13. mov %ah, %al
  14. out %al, $0x42
  15. in $0x61, %al
  16. /* TODO why or, while Linux kernel sets it to 3? */
  17. or $0b00000011, %al
  18. out %al, $0x61
  19. /*
  20. Pause for duration of note.
  21. Busy loop of `25 * 2 ^ 16 - 1`
  22. */
  23. mov $25, %bx
  24. .pause1:
  25. mov $65535, %cx
  26. .pause2:
  27. dec %cx
  28. jne .pause2
  29. dec %bx
  30. jne .pause1
  31. in $0x61, %al
  32. /* TODO why Reset bits 1 and 0. */
  33. and $0b11111100, %al
  34. out %al, $0x61
  35. jmp start