• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >汇编语言 > 汇编源代码之MAKE SOUNDS(发声)

汇编源代码之MAKE SOUNDS(发声)

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2017-06-28

匿名通过本文主要向大家介绍了make sounds,we can make sounds,vazquez sounds,sounds,sounds是什么意思等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
</div>

INTRODUCTION

This code example provides a set of keyboard routines to control sound output while waiting for a user to enter a keyboard character. The advantage to this method is that a main routine can call these sound routines to play a sound sequence, and the sound routines will return control back to the main routine whenever the user enters keyboard data so that the main routine can continue computing while the sound plays in the background. The code example has two different code entry points for getting keyboard data. One code entry point is a standard get_keyinput call which will wait for a key and update the sound data until a key code is found. The other code entry point is the get_keyinput_to call, which will wait a set amount of time for a key code and if none is found, return with a no key code found condition. The calling routine puts a timeout counter value in register AX on entry. The counter value is based on the system clock which ticks at 18.2 times per second. The entry point start_table_sound is used to begin a background sound sequence. On entry, the register BX indexes a table of sound data. The table has a format of four byte entries and is terminated by a data word of zero. The four bytes are used as two words: the first is a duration count and the second is a tone value. There are two code entry points for turning the background sound off and on. There is also a utility to flush out the keyboard buffer that can be executed with a call to flush_keyboard.

;Set of keyboard routines with sound outputs
.MODEL small
.STACK 500
.DATA
 ;define table for sound output
;sample_sounds   dw  8,45000  ;long low sound
;       dw  2,2000     ;short high sound
;       dw  0       ;end of sample sound table
sound_table  dw  0
sound_time_m  dw  0
sound_time_l  dw  0
sound_flag   db  0
sound_on_flag db  0,0
key_time_out_m dw  0
key_time_out_l dw  0
.CODE
;************ ^^^^^^^^^^ *************
;### code entry point #####
get_keyinput  proc near
;this routine checks for keyboard data in BIOS buffer
; and returns with data if there
;else it updates sound output data and loops to check for
; keyboard data again until keyboard data found
;on exit AX has keyboard data
   public  get_keyinput
   push bx
   push cx
   push dx
get_keyinput_loop:
     mov ah,1  ;set AH for scan
     int 16H  ;BIOS Call
      ;branch if no keyboard data
     jz  sound_update
     mov ah,0  ;set AH for get key
     int 16H  ;BIOS Call
   pop dx
   pop cx
   pop bx
   ret
;******* -------- *******
sound_update:
   cmp sound_flag,0    ;check for sound on????
   jz  get_keyinput_loop  ;branch out if sound off
   mov cx,sound_time_m   ;else check for sound update
   mov ax,sound_time_l
   call test_current_time  ;is it time for update ??
   jc  get_keyinput_loop  ;branch if not time
   mov bx,sound_table
   mov ax,[bx]       ;get next sound update value
   or  ax,ax        ;?? end of sound ??
   jz  turn_sound_off   ;branch if end sound
   call get_time_plus_ax  ;reset sound duration
   mov sound_time_m,cx
   mov sound_time_l,ax
   inc bx
   inc bx
   mov ax,[bx]
   inc bx
   inc bx
   mov sound_table,bx
   call sound_out_ax    ;go set sound frequency
   jmp get_keyinput_loop ;branch to keyboard loop
turn_sound_off:
   call sound_off
   mov sound_flag,0
   jmp get_keyinput_loop ;branch to keyboard loop
get_keyinput  endp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;************ ########## *************
;### code entry point #####
get_keyinput_to   proc near
;get keyboard data with timeout if no data available
;on entry AX has time duration in 18 ticks per second
;on exit if carry clear then AX has keyboard data
   public  get_keyinput_to
   push bx
   push cx
   push dx
   call get_time_plus_ax   ;add duration to current time
   mov key_time_out_m,cx  ;set timeout value
   mov key_time_out_l,ax
get_keyinput_to_loop:
   mov ah,1        ;ready to scan keyboard data
   int 16H         ;BIOS Call
   jz  sound_update_to   ;branch if no keyboard data
   mov ah,0        ;ready to get key data
   int 16H          ;BIOS Call
   pop dx
   pop cx
   pop bx
   clc            ;set keyboard data flag
   ret
get_keyinput_to_1:
   mov cx,key_time_out_m   ;check for timeout
   mov ax,key_time_out_l
   call test_current_time
   jc  get_keyinput_to_loop ;branch if no timeout
   xor ax,ax         ;else timeout return condition
   pop dx
   pop cx
   pop bx
   stc            ;set no keyboard data flag
   ret
; ******** %%%%%%% ********
sound_update_to:
   cmp sound_flag,0    ;check for sound on????
   jz  get_keyinput_to_1  ;branch if sound off
   mov cx,sound_time_m   ;else check for sound update
   mov ax,sound_time_l
   call test_current_time
   jc  get_keyinput_to_1  ;branch if not ready for update
   mov bx,sound_table
   mov ax,[bx]
   or  ax,ax        ;test for end of table
   jz  turn_sound_off_to  ;branch if end of table data
   call get_time_plus_ax
   mov sound_time_m,cx
   mov sound_time_l,ax
   inc bx
   inc bx
   mov ax,[bx]
   inc bx
   inc bx
   mov sound_table,bx
   call sound_out_ax
   jmp get_keyinput_to_1
turn_sound_off_to:
   call sound_off
   mov sound_flag,0
   jmp get_keyinput_to_1
get_keyinput_to   endp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;************ @@@@@@@@@@ ************
;### code entry point #####
start_table_sound  proc near
;subroutine to start background sound output
;on entry BX indexes sound data table
   public  start_table_sound
   push ax
   push bx
   mov ax,[bx]
   call get_time_plus_ax
   mov sound_time_m,cx
   mov sound_time_l,ax
   inc bx
   inc bx
   mov ax,[bx]
   inc bx
   inc bx
   mov sound_table,bx
   call sound_out_ax
   mov sound_flag,0FFH
   pop bx
   pop ax
   ret
start_table_sound  endp
;************ ========== *************
;### code entry point #####
flush_keyboard proc near
 ;utility to flush contents of keyboard buffer
   public  flush_keyboard
   mov ah,1
   int 16H    ;BIOS Call ;scan for keyboard data
   jz  flush_keyboard_x   ;branch if no keyboard data
   mov ah,0         ;else get keyboard data
   int 16H    ;BIOS Call
   jmp flush_keyboard
flush_keyboard_x:
   ret
flush_keyboard endp
;************* ----------- **************
sound_out_ax  proc near
 ;set sound out frequency to data value in AX
   push ax
   push ax
   cmp sound_on_flag,0
   jne sound_out_1
   in  al,61H     ;input port 61h
   or  al,3
   out 61H,al     ;output port 61h
sound_out_1:
   mov al,0B6H
   out 43H,al     ;output port 43h
   pop ax
   out 42H,al     ;output port 42h
   xchg al,ah
   out 42H,al     ;output port 42h
   mov so

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 汇编源代码之MAKE SOUNDS(发声)

相关文章

  • 2017-06-28汇编语言编写DOS下的内存驻留程序
  • 2017-06-28汇编语言与C语言的接口技术
  • 2017-06-17循环程序设计
  • 2017-06-28汇编IDE的选择与配置
  • 2017-06-28新手必看-汇编语言超浓缩教程
  • 2017-06-28汇编教程:系统托盘中的快捷图标
  • 2017-06-28汇编教程:控制寄存器和系统地址寄存器
  • 2017-06-28详解驻留exe文件
  • 2017-06-17标志寄存器传送指令
  • 2017-06-28利用汇编从命令行提取文件名

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 扩展Int 13H调用规范
    • 汇编教程:控制转移(2)
    • 汇编源代码之硬盘保护锁
    • 标志位设置指令
    • 输入输出指令
    • (汇编源代码 )简单的取系统时间小程序
    • 汇编源码系列之brk
    • 汇编源码系列之basmain
    • 乘运算指令
    • CPU 状态控制指令

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有