📄
字号:
----------------------------------------------------------------
实验一 简单输入、输出实验
硬件连线:8个开关与74LS244的SI相连,地址译码输出CS0与74LS244的片选CS相连;
8个发光二极管与74LS273的SO相连,地址译码输出CS1与74LS273的片选CS相连
实验效果:开关输入微机,然后输出控制二极管发光。
地址译码:CS0为04A0H,CS1为04B0H
----------------------------------------------------------------
汇编程序:
;=====================================================================
;
; This program input from port(04A0H),then output to port(04B0H)
;
;=====================================================================
assume cs:code
code segment public
org 100h
start: mov dx,04a0h ;input port address
in al,dx
mov dx,04b0h ;output port address
out dx,al
jmp start ;cycle
code ends
end start
返回目录
---------------------------------------------------------------------
实验二 软件延时实验
硬件连线: 同实验一
实验效果: 软件延时控制发光二极管闪亮
---------------------------------------------------------------------
汇编程序:
;===========================================================
;
; This program use software delay show flash LED
;
;===========================================================
assume cs:code
code segment public
org 100h
start: mov dx,04b0h ;output port address
mov al,0aah ;10101010B or 0ffh:11111111B
out dx,al ;light
mov cx,0ffffh ;soft delay
wait1: nop
loop wait1
mov al,0 ;black : no light
out dx,al
mov cx,0ffffh ;soft delay
wait2: nop
loop wait2
jmp start ;cycle
code ends
end start
!设计实验1:用软件延时让二极管依次循环发亮,每次亮一个。
!设计实验2:两个二极管发亮,各向相反的方向循环移动,依次发亮。
!设计实验3:两个二极管发亮,各向相反的方向循环移动,依次发亮,移动速度不同。
返回目录
---------------------------------------------------------------------
实验三 软件延时实验模拟路口交通灯控制
硬件连线: 同实验一
实验效果: 软件延时控制A路口红灯、B路口绿灯亮5秒;
然后A路口不变、B路口绿灯闪3下、然后B路口黄灯亮;
再变为A路口绿灯、B红灯延时3秒;
然后A路口绿灯闪3下、再黄灯亮、B不变。再循环……
---------------------------------------------------------------------
汇编程序:
;=====================================================================
;
; This program use software delay to simulate traffic control light
;
;=====================================================================
assume cs:code
code segment public
org 100h
start:mov dx,04b0h ;output port address
again:mov al,21h ;100001B
out dx,al ;light
mov cx,10
ared:call delay1
loop ared
mov cx,3
aflash:mov al,1
out dx,al
call delay1
mov al,21h
out dx,al
call delay1
loop aflash
mov al,9
out dx,al
call delay1
mov al,12h
out dx,al
mov cx,6
bred:call delay1
loop bred
mov cx,3
bflash:mov al,2
out dx,al
call delay1
mov al,12h
out dx,al
call delay1
loop bflash
mov al,6
out dx,al
call delay1
jmp again
delay1 proc
push cx
mov cx,0ffffh ;soft delay
wait1: nop
loop wait1
pop cx
ret
delay1 endp
code ends
end start
!设计实验:进一步加上开关控制:K1=0时正常工作、K1=1时A、B全为红灯。
返回目录
-------------------------------------------------------------------
实验四 LED简单显示实验
硬件连接: 无
实验效果: LED显示数字8,软件延时控制8移位显示
-------------------------------------------------------------------
汇编程序:
;=============================================================
;
; This program show '8' in each LED roundly
;
;=============================================================
con8279 equ 0492h
dat8279 equ 0490h
assume cs:code
code segment public
org 100h
start: jmp start1
disbuf db 6 dup(0)
start1:mov di,offset disbuf
mov cx,6
kplay1:mov byte ptr es:[di],0
inc di
loop kplay1
mov di,offset disbuf
mov byte ptr es:[di],7fh
kplay2:call disply
call rdisp
call dislay
jmp kplay2
dislay:mov bx,2eeeh
disla2:dec bx
jnz disla2
mov ax,0c2h
mov dx,con8279
out dx,ax
ret
rdisp: mov di,offset disbuf
mov al,es:[di]
mov cx,5
inc di
rdisp1:mov ah,es:[di]
dec di
mov es:[di],ah
add di,2
loop rdisp1
dec di
mov es:[di],al
ret
disply:call black
mov ax,90h
mov dx,con8279
out dx,ax
mov dx,dat8279
mov cx,8
mov di,offset disbuf
dlo: mov al,es:[di]
mov ah,0
out dx,ax
inc di
loop dlo
ret
black: mov dx,con8279
mov ax,0d1h
out dx,ax
mov cx,80h
clsb: nop
nop
loop clsb
ret
code ends
end start
返回目录
--------------------------------------------------------------
实验五 8253定时器控制模拟交通灯实验
硬件连接: 8253OUT0接74LS244的SI0,地址译码输出CS0与8253的片选CS相连;
8个发光二极管与74LS273的SO相连,地址译码输出CS1与74LS273的片选CS相连
地址译码输出CS2与74LS244的片选CS相连
实验效果: 类似路口交通灯依一定时间亮灭
--------------------------------------------------------------
汇编程序:
;=====================================================================
;
; This program use 8253 timer for LED transfer
;
; LED : green/red to yellow/red to red/green to red/yellow to again
; 00100001(21H)--00001001(09H)--00010010(12H)--000000110(06H)
;=====================================================================
assume cs:code
code segment public
org 100h
start: mov dx,04a6h ; 8253 控制寄存器地址,因8253的片选cs连接到地址译码的cs0
mov al,36h ; ctc0 设置为模式3:16位循环方波输出
out dx,al
mov dx,04a0h ; 8253 ctc0 计数值寄存器地址
mov al,24h
out dx,al
mov al,0f4h
out dx,al ; 设置16位计数值
;---------------------------------cycle 1
next0: mov dx,04b0h ; LED 口地址
mov al,21h
out dx,al ; 输出状态1:一个路口绿灯、另一个红灯
mov cl,40 ; 计数值的外循环次数
mov dx,04c0h
in11: in al,dx ; 检测8253的ctc0输出
test al,1
jz in11
in12: in al,dx
test al,1
jnz in12
dec cl
jnz in11 ; 5秒定时到
;---------------------------------cycle 2
mov bl,5
mov dx,04b0h
flash1:mov al,01 ; 显示状态2:黄灯闪5下
out dx,al
mov cx,8fffh
wait11:nop
loop wait11
mov al,21h
out dx,al
mov cx,0ffffh
wait12:nop
loop wait12
dec bl
jnz flash1 ; flash
mov al,09h
out dx,al ; show state2
mov cl,10
mov dx,04c0h
in21: in al,dx
test al,1
jz in21
in22: in al,dx
test al,1
jnz in22
dec cl
jnz in21 ; timer 1 seconds
;---------------------------------cycle 3
mov dx,04b0h
mov al,12h
out dx,al ; show state3
mov cl,30
mov dx,04c0h
in31: in al,dx
test al,1
jz in31
in32: in al,dx
test al,1
jnz in32
dec cl
jnz in31 ; timer 4 seconds
;---------------------------------cycle 4
mov bl,5
mov dx,04b0h
flash2:mov al,2 ; flash 5 times
out dx,al
mov cx,8fffh
wait21:nop
loop wait21
mov al,12h
out dx,al
mov cx,0ffffh
wait22:nop
loop wait22
dec bl
jnz flash2 ; flash
mov al,06h
out dx,al
mov cl,10
mov dx,04c0h
in41: in al,dx
test al,1
jz in41
in42: in al,dx
test al,1
jnz in42
dec cl
jnz in41 ; times 1 seconds
;--------------------------------- end 1 cycle
jmp next0 ; again to state1
code ends
end start
返回目录
----------------------------------------------------------------
实验六 LED显示实验
硬件连线: 无
实验效果: LED显示特定的数字
----------------------------------------------------------------
汇编程序:
;===================================================================
;
; This program show "F86430" in LED digital display
;
;===================================================================
con8279 equ 0492h ;Intel 8279 Description
dat8279 equ 0490h
assume cs:code
code segment public
org 100h
start: jmp start1
disbuf db 6 dup(0)
start1:mov di,offset disbuf
mov byte ptr cs:[di],71h ;f
inc di
mov byte ptr cs:[di],7fh ;8
inc di
mov byte ptr cs:[di],7dh ;6
inc di
mov byte ptr cs:[di],66h ;4
inc di
mov byte ptr cs:[di],4fh ;3
inc di
mov byte ptr cs:[di],3fh ;0
kplay2:call disply
;call rdisp
call dislay
jmp kplay2
dislay:mov bx,2eeeh
disla2:dec bx
jnz disla2
mov ax,0c2h
mov dx,con8279
out dx,ax
ret
disply:call black
mov ax,90h
mov dx,con8279
out dx,ax
mov dx,dat8279
mov cx,8
mov di,offset disbuf
dlo: mov al,es:[di]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -