![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-15 00:47 |
47,812 topics / 349,917 posts / today 0 new / 48,268 members |
| DOS开发编程 & 发展交流 (开发室) » Question about making sound with the PC speaker (repost) |
| Printable Version 1,283 / 0 |
| Floor1 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
Sender: benky (Memory of Dreams), Area: DOS
Title: Question about making sound with the PC speaker (repost) Posted at: Shuimu Tsinghua BBS (Sun May 28 23:40:53 2000) Experts, I'm using assembly to write a piece that uses the PC sound system to play a tune. It compiles fine, and it can also run? But it just won't make any sound. Please help me take a look. Thanks. The article is too long, so please let the moderator keep it for a few days; I'll delete it myself. Thanks ;******************************* TITLE GENSOUND--THE SPEAKER BEEPER ;PRODUCES A TONE OF A SPECIFIED FREQUENCY ; AND DRUATION PUBLIC GENSOUND public gensound cseg segment para 'code' assume cs:cseg gensound proc far push ax push bx push cx push dx push di mov al,0b6h out 43h,al mov dx,12h mov ax,533h*896 div di out 42h,al in al,61h mov ah,al or al,3 waitl: mov cx,2801 delay: loop delay dec bx jnz waitl mov al,ah out 61h,al pop di pop dx pop cx pop bx pop ax ret gensound endp cseg ends end ;******************************************** ;********************************************** TITLE MUSIC--A MUSIC OF 'MARY HAD A LITTLE LAMB' extrn gensound:far stack segment para stack'stack' db 64 dup('stack....' ![]() stack ends ;--------------------------- dseg segment para 'data' mus_freq dw 330,294,262,294,3 dup(330) dw 3 dup(294),330,392,392 dw 330,294,296,294,4 dup(330) dw 29,294,330,294,262,-1 mus_time dw 6 dup(25),50 dw 2 dup(25,25,50) dw 12 dup(25),100 dseg ends ;----------------------------- cseg segment para 'code' assume cs:cseg,ss:stack,ds:dseg music proc far start: push ds sub ax,ax push ax mov ax,dseg mov ds,ax mov ax,stack mov ss,ax lea si,mus_freq lea di,ds:mus_time freq_mus: mov di, cmp di,-1 je exit mov bx,ds: call gensound add si,2 add bp,2 jmp freq_mus exit: ret music endp cseg ends end start -- ※ Source:·Shuimu Tsinghua BBS smth.org· (This article was copied using the S-Term article copy script) ================================================== |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |