仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
8086源程序如下:
- DATAS SEGMENT
- DAC0832 equ 0C400h
- IOY1 equ 0C480h
- a8255 equ IOY1
- b8255 equ IOY1+01H*4
- m8255 equ IOY1+03H*4
- buff0 DB 128,168,203,232,250,255,250,232,203,168,128,88,53,24,6,0,6,24,53,88
- buff1 DB 102,134,162,185,200,204,200,185,162,134,102,70,42,19,5,0,5,19,42,70
- buff2 DB 77,101,121,139,150,153,150,139,122,101,77,53,32,14,3,0,3,14,32,53
- buff3 DB 51,67,81,93,100,102,100,93,81,67,51,35,21,10,2,0,2,10,21,35
- buff4 DB 26,33,41,46,50,51,50,46,41,34,26,18,11,5,1,0,1,5,11,18
- DATAS ENDS
- STACKS SEGMENT
- STACKS ENDS
- CODES SEGMENT
- ASSUME CS:CODES,DS:DATAS,SS:STACKS
- START:
- MOV AX,DATAS
- MOV DS,AX
- MOV DX,m8255
- MOV AL,92h;AB口输入
- OUT DX,AL
- ;判断输出信号的类型
- Choose:
- ;A口输入波形选择信号
- MOV DX,a8255
- in AL,DX
- CMP AL,0FEh
- je Sim_begin
- CMP AL,0FDh
- je Fangbo
- CMP AL,0FBh
- je tri_begin
- CMP AL,0f7h
- je sin_begin
- JMP choose
- ;锯齿波
- Sim_Begin:
- ;B口输入档位选择信号
- MOV DX,b8255
- IN AL,DX
- CMP AL,0FEH
- JE SW1
- CMP AL,0FDH
- JE SW2
- CMP AL,0FBH
- JE SW3
- CMP AL,0F7H
- JE SW4
- JNZ sw0
- ;默认0档即幅值最大,1234档依次为0.8,0.6,0.4,0.2倍幅值档
- JMP Sim_Begin
- SW0:
- MOV AL,0FFH
- JMP SIM
- SW1:
- MOV AL,0CCH
- JMP SIM
- SW2:
- MOV AL,99H
- JMP SIM
- SW3:
- MOV AL,66H
- JMP SIM
- SW4:
- MOV AL,33H
- JMP SIM
- SIM:
- MOV DX,DAC0832
- OUT DX,AL
- DEC AL
- JNZ SIM
- JMP choose
- ;方波
- Fangbo:
- ;设置高电平时长
- MOV CX,0ffh
- ;B口输入档位选择信号
- MOV DX,b8255
- IN AL,DX
- CMP AL,0FEH
- JE fb1
- CMP AL,0FDH
- JE fb2
- CMP AL,0FBH
- JE fb3
- CMP AL,0F7H
- JE fb4
- JNZ fb0
- JMP Fangbo
- fb0:
- MOV AL,00H
- JMP high_Fangbo
- fb1:
- MOV AL,033H
- JMP high_Fangbo
- fb2:
- MOV AL,66H
- JMP high_Fangbo
- fb3:
- MOV AL,99H
- JMP high_Fangbo
- fb4:
- MOV AL,0CCH
- JMP high_Fangbo
- high_Fangbo:
- MOV DX,dac0832
- OUT DX,AL
- LOOP high_fangbo
- MOV CX,0ffh
- ;设置低电平时长
- Low_Fangbo:
- MOV DX,dac0832
- MOV AL,0FFH
- OUT DX,AL
- LOOP low_fangbo
- JMP Fangbo
- ;三角波
- tri_begin:
- ;初始化
- MOV BL,00h
- up:
- inc BL
- MOV AL,BL
- MOV DX,dac0832
- OUT DX,AL
- MOV DX,b8255
- IN AL,DX
- CMP AL,0FEH
- JE TRI1
- CMP AL,0FDH
- JE TRI2
- CMP AL,0FBH
- JE TRI3
- CMP AL,0F7H
- JE TRI4
- JNZ TRI0
- JMP up
- TRI0:
- CMP BL,0ffh
- JNZ up
- ;到峰值下降否则持续上升
- jz down
- TRI1:
- CMP BL,0ccH
- JNZ up
- jz down
- TRI2:
- CMP BL,99H
- JNZ up
- jz down
- TRI3:
- CMP BL,66H
- JNZ up
- jz down
- TRI4:
- CMP BL,33H
- JNZ up
- jz down
- down:
- dec BL
- MOV DX,dac0832
- MOV AL,BL
- OUT DX,AL
- CMP BL,01h
- ;下降到最低值循环
- JNZ down
- JMP choose
- ;正弦波
- sin_begin:
- MOV BL,00h
- MOV DX,b8255
- IN AL,DX
- CMP AL,0FEH
- JE sin1
- CMP AL,0FDH
- JE sin2
- CMP AL,0FBH
- JE sin3
- CMP AL,0F7H
- JE sin4
- JNZ sin0
- JMP Sin_Begin
- sin0:
- lea di,buff0
- JMP sin_show
- sin1:
- lea di,buff1
- JMP sin_show
- sin2:
- lea di,buff2
- JMP sin_show
- sin3:
- lea di,buff3
- JMP sin_show
- sin4:
- lea di,buff4
- JMP sin_show
- sin_show:
- MOV AL,[di]
- MOV DX,dac0832
- OUT DX,AL
- inc di
- inc BL
- CMP BL,20
- JNZ sin_show
- JMP choose
- quit:
- MOV AH,04CH
- INT 21H
- CODES ENDS
- END START
复制代码
所有资料51hei提供下载:
8086 - 副本.zip
(27.05 KB, 下载次数: 78)
|