实验6-1
原理图
源代码
io0809a equ 298h
code segment
assume cs:code
start:mov dx,io0809a ;启动A/D转换器
out dx,al
mov cx,0ffh ;延时
delay:loop delay
in al,dx ;从A/D转换器输入数据
mov bl,al ;将al保存在bl中
mov cl,4
shr al,cl ;将al右移四位
call disp ;调显示子程序显示其高四位
mov al,bl
and al,0fh
call disp ;调显示子程序显示其低四位
mov ah,02
mov dl,20h ;加回车符
int 21h
mov dl,20h
int 21h
push dx
mov ah,06h ;判断是否有键按下
mov dl,0ffh
int 21h
pop dx
je start ;若没有转START
mov ah,4ch ;退出
int 21h
disp proc near ;显示子程序
mov dl,al
cmp dl,9 ;比较DL是否>9
jle ddd ;若不大于则为'0'-'9',加30h为其ASCII码
add dl,7 ;否则为'A'-'F',再加7
ddd: add dl,30h ;显示
mov ah,02
int 21h
ret
disp endp
code ends
end start
结果
转换调节电压的旋钮,屏幕上的数字发生变化,从00~FF。
实验6-2
原理图
源代码
锯齿波:
io0832a equ 290h
code segment
assume cs:code
start:
mov cl,0;
mov dx,io0832a;
LLL:
mov al,cl
out dx,al
inc cl;
;需补
push dx
mov ah,06h ;判断是否有键按下
mov dl, 0ffh
int 21h
pop dx
jz LLL
mov ah, 4ch
int 21h
code ends
end start
三角波:
io0832a equ 290h
code segment
assume cs:code
start:
mov cl,0;
mov dx,io0832a;
LLL:
mov al,cl
out dx,al ;向转换器送入数据
inc cl;
cmp cl,0ffh ;判断是否到最大值
jnz lll ;
dec cl
LL:
mov al,cl
out dx,al
dec cl
cmp al,0
jnz LL
jmp start
;需补
push dx
mov ah,06h ;判断是否有键按下
mov dl, 0ffh
int 21h
pop dx
jz LLL
mov ah, 4ch
int 21h
code ends
end start
结果