『楼 主』:
 请教用PC喇叭发声问题 (转载)
 
使用 LLM 解释/回答一下
  
发信人: benky (梦的记忆), 信区: DOS 
标  题: 请教用PC喇叭发声问题 (转载) 
发信站: BBS 水木清华站 (Sun May 28 23:40:53 2000) 
 
【 以下文字转载自 Programming 讨论区 】 
【 原文由 benky 所发表 】 
各位大虾,我在用汇编写一段用PC发声系统演奏一段乐曲,编译通过,也能运行? 
但就是发不出声音来。请各位帮帮忙看一下。谢谢。 
文章太长,请斑竹保留几天,我会自己删的。谢谢 
 
;******************************* 
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 
 
-- 
※ 来源:·BBS 水木清华站 smth.org· 
 
(本文采用S-Term文章拷贝脚本拷贝) 
================================================== 
 
 
    
 
  
  |