Microcomputer interface experiment 1: Seven-segment digital tube dynamic display 00~99

1. The purpose of the experiment

Master the principle of digital display of numbers.

2. Experimental principle and content

Insert picture description here

Three, programming tips

Insert picture description here

Four, circuit wiring diagram

Insert picture description here

Five, program design flow chart

Insert picture description here

Six, some explanation

  1. After 01h is sent to port C, then the data to be displayed is sent to port A, and the one digit is displayed.
  2. After 02h is sent to port C, the data to be displayed is sent to port A, and the display shows the tens place.
  3. Pay attention to judge the carry.

Seven, program source code

stack segment stack
    db 200 dup(0)
stack ends

data segment
    APORT equ 288h
    CPORT equ 28ah
    CTRL equ 28bh
    num db 3fh, 06h, 5bh, 4fh, 66h, 6dh, 7dh, 07h, 7fh, 6fh  ;0~9
data ends

code segment
    assume cs:code,ds:data,ss:stack

    delay MACRO
      local loop_delay
      local flag
      push cx
      push bx
      xor bx, bx
      flag:mov cx, 0ffffh
      loop_delay:loop loop_delay
      inc bx
      cmp bx, 10
      jnz flag
      pop bx
      pop cx
   ENDM

main: mov ax,data          
      mov ds,ax
      mov ax, stack
      mov ss, ax
      mov dx, CTRL
      mov al, 80h  ;写入控制字
      out dx, al
      xor si, si
      xor di, di
loop1:cmp si, 10  ;检查个位是否已经增加到10
      jz carry          ;进位
      mov dx, CPORT
      mov al, 02h
      out dx, al
      mov dx, APORT
      mov al, num[di]   ;显示十位
      out dx, al
      delay
      mov dx, CPORT
      mov al, 01h
      out dx, al
      mov dx, APORT
      mov al, num[si]   ;显示个位
      out dx, al
      inc si           ;个位+1
      delay
      jmp loop1  ;还没有进位个位继续增加
carry:xor si, si   ;进位后将个位清零
      cmp di, 10  ;十位增加到10就从00重新开始
      jz exit
      mov dx, CPORT
      mov al, 02h
      out dx, al
      mov dx, APORT
      mov al, num[di]
      out dx, al
      inc di   ;十位+1
      delay
      jmp loop1
 exit:xor di, di
      jmp loop1
      mov ah,4ch
      int 21h
code ends
     end main

Guess you like

Origin blog.csdn.net/Cyril_KI/article/details/110677530