汇编语言课程设计报告(共9页).doc

上传人:飞****2 文档编号:5386503 上传时间:2022-01-05 格式:DOC 页数:9 大小:44.50KB
返回 下载 相关 举报
汇编语言课程设计报告(共9页).doc_第1页
第1页 / 共9页
汇编语言课程设计报告(共9页).doc_第2页
第2页 / 共9页
点击查看更多>>
资源描述

《汇编语言课程设计报告(共9页).doc》由会员分享,可在线阅读,更多相关《汇编语言课程设计报告(共9页).doc(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精选优质文档-倾情为你奉上课程设计一、课程设计题目:简易电子琴 二、课程设计目的:用汇编语言独立完成一个程序题,以达到熟练运用汇编语言编程实现有比较完整功能的系统的目的。三、课程设计内容:用汇编语言编写一个简易电子琴程序,基本功能:1、可以进行固定音乐演奏(两首以上);可以自行弹奏音乐。2、图形显示键盘界面;弹奏时键盘现实所按按键;可以调节音量。四、设计思路: ROM BIOS中的BEEP子程序能根据BL中给出的时间计数值控制8254定时器,产生持续声音。通过对BEEP的修改可以使其产生任一频率的声音。用汇编语言编写的程序GENSOUND,能使PC机发出指定频率和指定延迟时间的声音,它是一个很

2、好的通用发声程序。组成乐曲的每个音符的频率值和持续时间是乐曲发声程序所必须的两组数据,知道了音调及频率的关系后,就可以按照乐曲的乐谱将每个音符的频率和持续时间定义成两个数据表,然后编程依次取出表中的频率值和时间值,调用GENSOUND程序发出各种声音,本程序通过调用GENSOUND程序演奏乐曲。五、操作说明:运行时,按A键演奏乐曲”Two tigers”,按B键演奏乐曲”Happy Birthday”,按C键演奏乐曲” Snail And Oriole”,按P键自行弹奏音乐,按Q键退出。以上按键必须使用大写字母,否则显示出错信息。源程序(MUSIC.ASM)如下:DATA SEGMENT PA

3、RA DATAINFO1 DB 0DH,0AH,*$INFO2 DB 0DH,0AH,*-WELCOME YOU TO COME HERE!-*$INFO3 DB 0DH,0AH,*-This is a music program!-*$INFO4 DB 0DH,0AH,*$INFO5 DB 0DH,0AH,0DH,0AH,Please select!$INFO6 DB 0DH,0AH,0DH,0AH,Input Error! Please Input Again !$INFO7 DB 0DH,0AH,-$INFO9 DB 0DH,0AH,0DH,0AH,If you want to play

4、 piano,Please push P$MUSLIST DB 0DH,0AH,A Two tigers DB 0DH,0AH,B Happy Birthday DB 0DH,0AH,C Snail And Oriole DB 0DH,0AH,Q EXIT DB 0DH,0AH,$MUS_FREG1 DW 2 DUP(262,294,330,262) ;为演奏的乐曲定义一个频率表 DW 2 DUP(330,349,392) DW 2 DUP(392,440,392,349,330,262) DW 2 DUP(294,196,262),0ffffhMUS_TIME1 DW 10 DUP(2500

5、0),50000,25000,25000,50000 ;为演奏的乐曲定义一个节拍时间表 DW 2 DUP(12000,12000,12000,12000,25000,25000) DW 2 DUP(25000,25000,50000) MUS_FREG2 DW 262,262,294,262,349 DW 330,262,262,294,262 DW 392,349,262,262,523 DW 440,349,262,262,466 DW 466,440,262,392,349,-1 MUS_TIME2 DW 500,500,1000,1000,1000 DW 1000,1000,500,5

6、00,1000,1000 DW 1000,1000,1000,500,500,1000 DW 1000,1000,1000,1000,1000,500 DW 500,1000,1000,1000,1000,1000MUS_FREG3 DW 392,396,392,395,330,392,262,440,392,395 DW 392,395,392,330,294,262,330,294,297,330 DW 392,395,392,330,335,294,262,265,294,330 DW 262,265,220,196,220,196,392,395,392,395 DW 330,392,

7、262,440,292,392,395,392,395,330 DW 294,262,330,294,294,330,392,395,330,335 DW 294,262,265,294,330,262,265,220,196,220 DW 196,392,395,392,395,330,294,262,440,392 DW 395,440,262,294,262,294,330,294,262,-1 MUS_TIME3 DW 1 DUP(25,50,25,50,25,25,50,50,100,25) DW 1 DUP(50,25,50,25,25,50,50,100,75,25) DW 1

8、DUP(50,25,25,50,25,25,50,50,75,25) DW 1 DUP(50,25,25,50,50,100,25,50,25,50) DW 1 DUP(25,25,50,50,100,25,50,25,50,25) DW 1 DUP(25,50,50,100,75,25,50,50,50,25) DW 1 DUP(25,50,50,75,25,50,25,25,50,50) DW 1 DUP(100,25,50,25,50,25,25,50,50,50) DW 1 DUP(25,25,50,50,50,50,100,100,200) msg DB 0DH,0AH,0DH,0A

9、H, 1 2 3 4 5 6 7 DB 0DH,0AH, q w e r t y u DB 0DH,0AH,_ DB 0DH,0AH,9: EXIT DB 0DH,0AH,_,$ ;*音调*后面用到-1判断音乐播是否放完sound_0 DW -1sound_11 DW 441,-1 sound_12 DW 495,-1sound_13 DW 556,-1sound_14 DW 589,-1sound_15 DW 661,-1sound_16 DW 742,-1 sound_17 DW 833,-1 sound_1 DW 882,-1 sound_2 DW 990,-1 sound_3 DW 1

10、112,-1sound_4 DW 1178,-1 sound_5 DW 1322,-1 sound_6 DW 1484,-1 sound_7 DW 1655,-1time DW 25DATA ENDSSTACK SEGMENT PARA STACK STACK DB 300 DUP (STACK)STACK ENDSCODE SEGMENT ASSUME DS:DATA,SS:STACK,CS:CODEMAIN PROC FAR MOV AX,DATA MOV DS,AX MOV aH, 3 MOV AL,4 INT 10H MOV AH,09H MOV BH,6 MOV BL,4 INT 1

11、0H MOV AH,0BH MOV BH,09H MOV BL,00 INT 10H;*定义一个宏*SHOW MACRO b LEA DX,b MOV AH,9 INT 21H ENDM;* show INFO1 show INFO2 show INFO3 show INFO4 show INFO5 show infO9 show MUSLISTINPUT: MOV AH,01H INT 21H CMP AL,Q JZ retu CMP AL,P JZ RETU2 CMP AL,A JNZ B0 CALL MUSIC1 JMP EXIT1B0: CMP AL,B JNZ C0 CALL MUS

12、IC2 JMP EXIT1C0: CMP AL,C JNZ exit CALL MUSIC3EXIT1: show INFO7 JMP INPUT EXIT: call clear show INFO6 show INFO7 show INFO5 show MUSLISTSHOW INFO9 jmp inputRETU: MOV AH,4CH INT 21H MAIN ENDP RETU2: MOV AX,DATA MOV DS,AX ;*一个声音宏*onesound macro soundis,jumpis,letterisCMP AL,letteris JNZ jumpis LEA SI,

13、soundisLEA BP,DS:timeCALL MUSIC JMP inpu ENDM show msgINPU: MOV AH,01H INT 21H CMP AL,9 jnz gomov ah,4chint 21hgo: onesound sound_11,a1,qa1: onesound sound_12,b1,wb1: onesound sound_13,c1,ec1: onesound sound_14,d1,rd1: onesound sound_15,e1,te1: onesound sound_16,f1,yf1: onesound sound_17,g1,ug1: one

14、sound sound_1,h1,1h1: onesound sound_2,i1,2i1: onesound sound_3,j1,3j1: onesound sound_4,k1,4k1: onesound sound_5,l1,5l1: onesound sound_6,m1,6m1: onesound sound_7,n1,7n1: onesound sound_0,o1,alo1: jmp inpu;*发声 GENSOUND1 PROC NEAR ;-PUSH AX PUSH BX PUSH CX PUSH DX PUSH DI ;-MOV AL,0B6H OUT 43H,AL MO

15、V DX,12H MOV AX,348ch DIV DI OUT 42H,AL MOV AL,AH OUT 42H,AL IN AL,61H MOV AH,AL OR AL,3 OUT 61H,AL WAIT2: MOV CX,3314 call waitf DELAY1: DEC BX JNZ WAIT2 MOV AL,AH OUT 61H,AL ;-POP DI POP DX POP CX POP BX POP AX ;-RET GENSOUND1 ENDP ;* waitf proc near push ax waitf1: in al,61h and al,10h cmp al,ah

16、je waitf1 mov ah,al loop waitf1 pop ax ret waitf endp ;* MUSIC PROC NEAR PUSH DS SUB AX,AX PUSH AX FREG: MOV DI,SI CMP DI,-1JE END_MUS MOV BX,DS:BP CALL GENSOUND1 ADD SI,2 ADD BP,2 END_MUS: RET MUSIC ENDP MUSIC1 PROC NEAR PUSH DS SUB AX,AX PUSH AX LEA SI,MUS_FREG1 LEA BP,DS:MUS_TIME1FREG1: MOV DI,SI

17、 CMP DI,-1 JE END_MUS1 MOV DX,DS:BP MOV BX,2600 CALL GENSOUND ADD SI,2 ADD BP,2 JMP FREG1END_MUS1: RETMUSIC1 ENDPGENSOUND PROC NEAR 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 MOV AL,AH OUT 42H,AL IN AL,61H MOV AH,AL OR AL,3 OUT 61H,ALW

18、AIT1: MOV CX,8FF0HDELAY2: LOOP DELAY2 DEC BX JNZ WAIT1 MOV AL,AH OUT 61H,AL POP DI POP DX POP CX POP BX POP AX RETGENSOUND ENDPMUSIC2 PROC NEAR PUSH DS SUB AX,AX PUSH AX LEA SI,MUS_FREG2 LEA BP,DS:MUS_TIME2FREG2: MOV DI,SI CMP DI,-1 JE END_MUS2 MOV DX,DS:BP MOV BX,3500 CALL GENSOUND ADD SI,2 ADD BP,

19、2 JMP FREG1END_MUS2: RETMUSIC2 ENDPMUSIC3 PROC NEAR PUSH DS SUB AX,AX PUSH AX LEA SI,MUS_FREG3 LEA BP,DS:MUS_TIME3FREG3: MOV DI,SI CMP DI,-1 JE END_MUS3 MOV DX,DS:BP MOV BX,2000 CALL GENSOUND ADD SI,2 ADD BP,2 JMP FREG1END_MUS3: RETMUSIC3 ENDPclear proc near push ax push bx push cx push dx mov ah,6

20、mov al,0 mov ch,0 mov cl,0 mov dh,24 mov dl,79 mov bh,7 int 10h pop dx pop cx pop bx pop ax retclear endpCODE ENDS END MAIN六、所遇到的问题: 程序使用了学习过程中学到的各个知识点,但是由于对一些相关的知识点不能够合理的应用,所以实验要求的自我弹奏的功能不够完善,所实现的只能是单独弹一个音符,可以调节音量,希望在以后的学习中能够学会解决。七、运行结果:八、课程设计心得体会:通过本次课程设计,自己感悟颇深,整个设计中比较顺利地完成了相关设计中的主要部分,但实验中出现的一些平时实验中没有出现的问题,颇费周章。经过反复的修改及调试后,设计终于达到了预期目的,尽管相关功能还比较简单,但相信在自己的努力下,经过经验的一次次积累,希望在以后的学习中能够举一反三,做得更好。九、参考资料1、实验课中使用的实验指导例程。2、8086/8088汇编语言程序设计 王正智 电子工业出版社。3、IBM-PC汇编语言程序设计(第二版)沈美明 清华大学出版社。4、图书馆、相关网站可获取的参考资料。专心-专注-专业

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 教育教学

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁