Proteus 8微机接口仿真模拟实验,8086,8255A,DAC0832输出四种波形
一、设计名称:
利用D/A、 A/D转换产生波形并显示
二、设计要求:
1、产生锯齿波、三角波、方波、正弦波。
2、将以上四种波形显示在屏幕上。
代码编写之后需要编译!
Build Project编译结果,下侧窗口显示Compiled successfully成功。
DATA SEGMENT
SIN_NUM DB 80H,8CH,98H,0A5H,0B0H,0BCH,0C7H,0D1H
DB 0DAH,0E2H,0EAH,0F0H,0F6H,0FAH,0FDH,0FFH
DB 0FFH,0FDH,0FAH,0F6H,0F0H,0EAH,0E2H,0DAH
DB 0D1H,0C7H,0BCH,0B0H,0A5H,98H,8CH,80H
DB 7FH,73H,67H,5AH,4FH,43H,38H,2EH
DB 25H,1DH,15H,0FH,09H,05H,02H,00H
DB 00H,02H,05H,09H,0FH,15H,1DH,25H
DB 2EH,38H,43H,4FH,5AH,67H,73H,7FH
DATA ENDS
CODE SEGMENT PUBLIC ‘CODE’
ASSUME CS:CODE,DS:DATA
START:
; Write your code here
MOV AX,DATA
MOV DS,AX
;--------------------------------------8255A初始化
MOV AL,90H ;方式控制字 10010000B
MOV DX,0906H
OUT DX,AL
;--------------------------------------检测8255端口
AGAIN: MOV DX,0900H
IN AL,DX
TEST AL,01H
JZ SQRW ;方波
TEST AL,02H
JZ TW ;三角波
TEST AL,04H
JZ STW ;锯齿波
TEST AL,08H
JZ SINW ;正弦波
JMP AGAIN
;--------------------------------------
SQRW: MOV AL,0FFH ;方波
MOV DX,0800H
OUT DX,AL
CALL DELAY
MOV AL,00H
MOV DX,0800H
OUT DX,AL
CALL DELAY
JMP AGAIN
;--------------------------------------
TW: MOV AL,00H ;三角波
MOV DX,0800H
OUT DX,AL
TWLP1: INC AL
OUT DX,AL
CMP AL,0FFH
JNZ TWLP1
TWLP2: DEC AL
OUT DX,AL
CMP AL,00H
JNZ TWLP2
JMP AGAIN
;--------------------------------------
STW: MOV AL,0FFH ;锯齿波
MOV DX,0800H
OUT DX,AL
STWLP: DEC AL
OUT DX,AL
CMP AL,00H
JNZ STWLP
JMP AGAIN
;--------------------------------------
SINW: MOV CX,0040H
MOV BX,OFFSET DS:[SIN_NUM]
SINWLP: MOV AL,DS:[BX]
MOV DX,0800H
OUT DX,AL
INC BX
LOOP SINWLP
JMP AGAIN
;-------------------
DELAY PROC
MOV CL,0FFH
LP: LOOP LP
RET
DELAY ENDP
CODE ENDS
END START