組譯工具——擴音器發聲的控制

來源:互聯網
上載者:User

            今天寫了擴音器發聲控制的程式,可是在dos下運行,無錯誤無警告,就是不出聲。不知為何,想請教各位大蝦這是什麼情況,又該如何解決。小女子在此拜謝了!O(∩_∩)O

以下是我編寫的程式(用masm50編譯的):

.model small
.data
freq dw  2000
.stack
.code
start:          mov ax,@data
                mov ds,ax
  mov ax,freq
  call speaker ;設定擴音器音調
  call speakon ;開啟擴音器聲音
  mov ah,1 ;等待按鍵
  int 21h
  call speakoff ;關閉擴音器聲音
               
     speaker proc
  push ax
  mov al,0b6h    ;10110110B
  ; 計數器2、寫低高、方式3、二進位
  out 43h,al ;寫入控制字
  pop ax               ;ax中存放的計數值
  out 42h,al ;寫入低8位計數值
  mov al,ah
  out 42h,al ;寫入高8位計數值
  ret
    speaker endp
 speakon proc
  push ax
  in al,61h ;8255的相關設定
  or al,03h
 ;D1D0=PB1PB0=11B,其他位不變
  out 61h,al
  pop ax
  ret
speakon endp
speakoff proc
  push ax
  in al,61h
  and al,0fch
 ;D1D0=PB1PB0=00B,其他位不變
  out 61h,al
  pop ax
  ret
speakoff endp
                end start
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.