DATAS SEGMENT
;此处输入数据段代码
DAC0832 equ 0C400h
IOY1 equ 0C480h
b8255 equ IOY1+01H*4
m8255 equ IOY1+03H*4
buffer dw 127,133,139,145,151,158,164,170,175,181;正弦波
dw 187,192,198,203,208,212,217,221,225,229
dw 233,236,239,242,245,247,249,251,252,253
dw 254,254,255,254,254,253,252,251,249,247
dw 245,242,239,236,233,229,225,221,217,212
dw 208,203,198,192,187,181,175,170,164,158
dw 151,145,139,133,127,120,114,108,102,95
dw 89,83,78,72,66,61,55,50,45,41
dw 36,32,28,24,20,17,14,11,8,6
dw 4,2,1,0,0,0,0,0,0,0
dw 1,2,4,6,8,11,14,17,20,24
dw 28,32,36,41,45,50,55,61,66,72
dw 78,83,89,95,102,108,114,120
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov di,offset buffer
mov dx,m8255
mov al,82h;B口输入
out dx,al
;判断输出信号的类型
Choose:
mov dx,b8255;输入信号
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:
mov al,0ffh
SIM:
mov dx,DAC0832
out dx,al
dec al
jnz SIM
jmp choose
;方波
Fangbo:
mov dx,dac0832
mov cx,0fffh
high_Fangbo:
mov al,00h
out dx,al
loop high_fangbo
mov cx,0fffh
Low_Fangbo:
mov al,0ffh
out dx,al
loop low_fangbo
jmp choose
;三角波
tri_begin:
mov al,01h
mov dx,dac0832
up:
inc al
out dx,al
cmp al,0ffh
jnz up
down:
dec al
out dx,al
cmp al,01h
jnz down
jmp choose
;正弦波
sin_begin:
mov bl,00h
mov dx,dac0832
mov di,00h
sin_show:
mov al,[di]
out dx,al
add di,2
inc bl
cmp bl,128
jnz sin_show
jmp choose
quit:
MOV AH,4CH
INT 21H
CODES ENDS
END START
可以输出不同的波形:
1.锯齿波:
2.方波:
3.三角波:
4.正弦波:
运行时使能信号参考。