笑傲心扬吧 关注:2贴子:91
  • 1回复贴,共1

微机0809实验源程序 模数转换

只看楼主收藏回复

第一种:
 .model tiny
            extrn display8:near
            PA  EQU  0F000H
            .stack 100
            .data
            buf DB 8 dup(10H)
            .code
            main proc far
start:
            mov ax,@data
            mov ds,ax
      
      
        MOV AX, 0
        CALL CONVERT
LOP1:
MOV AX, 0
MOV CX, 50
START1: 
   PUSH AX
        MOV DX,PA
        MOV AL, 0
        OUT DX, AL
        CALL DELAY
        IN AL, DX
        MOV BL, AL
        POP AX
        ADD AL, BL
        ADC AH, 0
        LOOP START1
        MOV BL, 50
        DIV BL
        
        CALL CONVERT
        JMP LOP1


   CONVERT PROC  NEAR
MOV BL, AL
MOV AH, AL
AND AL, 0fh
  MOV CL, 4
ROR AH, CL
AND AH, 0fh
LEA SI, BUF
MOV [SI+4], AL
MOV [SI+5], AH
MOV AX, 5000
MOV BH, 0ffh
DIV BH
MUL BL
MOV BL, 97
DIV BL
MOV BL, AH
MOV AH, 0
PUSH AX
MOV AL, BL
MOV BL, 10
DIV BL
MOV BH, AL
POP AX
DIV BL
MOV [SI], BH
MOV [SI+1], AH
MOV [SI+2], AL
CALL Display8
RET
  CONVERT    ENDP
     
            delay proc near
            push cx
            MOV CX,0FFFH
            LOOP $
            POP CX           
            ret
            delay endp            
            end start


IP属地:福建1楼2008-05-29 18:32回复
    第二种:
     .model tiny
     extrn display8:near
     PORTA EQU 0F000H
     ID EQU 00H
     .stack 100
     .data
     buf DB 8 dup(10H)
     .code
     main proc far
    start:
     mov ax,@data
     mov ds,ax
    init:
    rotate:
     call convert
     call delay 
     jmp rotate 
     
     main endp

     convert proc near
     mov al,ID
     mov dx,PORTA
     out dx,al
     call delay
     in al,dx
     mov cl,al
     and al,0FH
     mov buf,al
     mov al,cl
     and al,0F0H
     mov cl,4
     ROR al,cl
     mov buf+1,al
     lea si,buf
     call display8
     ret
     convert endp

     clear proc near
     push cx
     push si
     mov cx,8
     lea si,buf
    lop:
     mov byte ptr[si],10H
     inc si
     loop lop
     lea si,buf
     call display8
     pop si
     pop cx
     ret
     clear endp

     delay proc near
     push cx
     push bx
     mov bx,1
    again:
     mov cx,0
     loop $
     dec bx
     jnz again
     pop bx
     pop cx
     ret
     delay endp 
     end start


    IP属地:福建2楼2008-05-29 18:33
    回复