当前位置 : 主页 > 编程语言 > java >

微机原理-虚拟仿真实验-ADC0809模数电路汇编代码

来源:互联网 收集:自由互联 发布时间:2022-10-26
微机原理-虚拟仿真实验-ADC0809模数电路汇编代码 data segment port equ 420h a db 8 dup(?) b db "IN?: ??? ?.?V$" ; s db "Read and display 8 simulation data. Press any key to exit ...",0dh,0ah,"$" data ends code segment assume


微机原理-虚拟仿真实验-ADC0809模数电路汇编代码

data segment
port equ 420h
a db 8 dup(?)
b db "IN?: ??? ?.?V$" ;
s db "Read and display 8 simulation data. Press any key to exit ...",0dh,0ah,"$"
data ends
code segment
assume cs:code,ds:data,es:data
start:mov ax,data
mov ds,ax
mov es,ax
mov dx,offset s ;显示提示
mov ah,9
int 21h
mov si,offset a
mov cx,8
mov dx,port
again:mov al,11h
out dx,al ;启动A/D转换
call delay ;延时等待
in al,dx
mov [si],al ;获取转换结果
inc dx
inc si
loop again ;判断8路输入量转换完否
mov cx,0
mov si,offset a
mov di,offset b
go: mov ch,cl
add ch,30h
mov [di+2],ch
call achange
call dchange
mov dx,offset b ;显示结果
mov ah,9
int 21h
mov ah,2
mov dl,0ah ;回车、换行
int 21h
mov dl,0dh
int 21h
inc si
inc cl
cmp cl,8
jnz go
LA: mov ah,0bh
int 21h ; 检测有无按键,返回AL=0FFh(有按键)或0(无按键)
cmp al,0
jz LA
mov ah,4ch
int 21h

delay proc ;延时程序
push bx
push cx
mov cx,05h
rrb: mov bx,800h
rra: dec bx
jnz rra
dec cx
jnz rrb
pop cx
pop bx
ret
delay endp

dchange proc ;将数字量的百位、十位、个位分离
mov al,[si]
mov ah,0
mov bl,100
div bl
push ax
add al,30h
mov [di+5],al
pop ax
mov al,ah
mov ah,0
mov bl,10
div bl
push ax
add al,30h
mov [di+6],al
pop ax
add ah,30h
mov [di+7],ah
ret
dchange endp

achange proc ;将数字量转换为模拟量以显示
mov bl,50
mov al,[si] ;模拟量0~5V对应于数字量0~255
mul bl
mov bl,255 ;模拟量=数字量*5/255
div bl
sub ah,128 ;;四舍五入
jc shequ
inc al
shequ: mov ah,0
mov bl,10
div bl
add al,30h
mov [di+11],al
add ah,30h
mov [di+13],ah
ret
achange endp
code ends
end start


网友评论