微机原理基础电子琴,有8255,8253芯片
- ;;;===Create By XuHe 2018 1.10===;;;
- ;;;===电子琴设计===;;;
- DATAS SEGMENT
- CTR EQU 0206H
- T0 EQU 82H ;10000010B
- DATAS ENDS
- STACKS SEGMENT STACK
- DW 128 DUP(?)
- TOP EQU $-STACKS
- STACKS ENDS
- CODE SEGMENT PUBLIC 'CODE'
- ASSUME CS:CODE,DS:DATAS,SS:STACKS
- START:
- ;===初始化===
- MOV AX,DATAS
- MOV DS,AX
- MOV AX,STACKS
- MOV SS,AX
- MOV SP,TOP
- MOV AL,T0
- MOV DX,CTR
- OUT DX,AL
- MOV DX,0200H
- MOV AL,0FFH
- OUT DX,AL
- ;===按键扫描===
- K1:
- MOV DX,0202H
- IN AL,DX
- CMP AL,0FEH
- JNZ K2
- MOV DI,247
- JMP DDD
- K2:
- MOV DX,0202H
- IN AL,DX
- CMP AL,0FDH
- JNZ K3
- MOV DI,277
- JMP DDD
- K3:
- MOV DX,0202H
- IN AL,DX
- CMP AL,0FBH
- JNZ K4
- MOV DI,311
- JMP DDD
- K4:
- MOV DX,0202H
- IN AL,DX
- CMP AL,0F7H
- JNZ K5
- MOV DI,330
- JMP DDD
- K5:
- MOV DX,0202H
- IN AL,DX
- CMP AL,0EFH
- JNZ K6
- MOV DI,370
- JMP DDD
- K6:
- MOV DX,0202H
- IN AL,DX
- CMP AL,0DFH
- JNZ K7
- MOV DI,415
- JMP DDD
- K7:
- MOV DX,0202H
- IN AL,DX
- CMP AL,0BFH
- JNZ K8
- MOV DI,466
- JMP DDD
- K8:
- MOV DX,0202H
- IN AL,DX
- CMP AL,07FH
- JNZ K1
- MOV DI,495
- JMP DDD
- ;有键按下
- DDD:
- MOV DX,0200H
- OUT DX,AL
- CALL OUTTONE
- ;是否弹起,按的时间长短决定拍长
- DELAY:
- MOV DX,0202H
- IN AL,DX
- CMP AL,0FFH
- JNZ DELAY
- ;停止
- MOV DX,0200H
- MOV AL,0FFH
- OUT DX,AL
- CALL STOP
- JMP K1
- ;发声子程序
- OUTTONE PROC NEAR
- MOV DX,0406H
- MOV AL,10010110B
- OUT DX,AL
- MOV DX,00H
- MOV AX,5000
- DIV DI
- AND AX,00FFH
- MOV DX,0404H
- OUT DX,AL
- RET
- OUTTONE ENDP
- ;停止子程序
- STOP PROC NEAR
- MOV AL,10110001B
- MOV DX,0406H
- OUT DX,AL
- MOV AX,5000
- MOV DX,0404H
- OUT DX,AL
- MOV AL,AH
- OUT DX,AL
- RET
- STOP ENDP
- CODE ENDS
- END START
复制代码
Keil代码与Proteus仿真下载:
8086设计--电子琴.7z
(63.2 KB, 下载次数: 16)
|