微机原理实验程序设计集锦

实验一
(1)1.将给定的一个二进制数,转换成二-十进制(BCD)码:
要求将AX拆为三个BCD码,并存入result开始的三个单元。
data segment
result db 3 dup(?)
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov ax,345
mov cl,100
div cl
mov result,al
mov al,ah
mov ah,0
mov cl,10
div cl
mov result+1,al
mov result+2,ah
jmp $
code ends
end start

(2)2.将给定的一个BCD数,将其转换成ASCII值:
将AX拆为两个ASCII码,并存入result开始的两个单元
data segment
result db 2 dup(?)
ASCIIab:
db"0123456789ABCDEF"
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov ax,23h
mov bl,al
shr bl,4
mov bh,0
mov ah,byte ptr ASCIIab[bx]
mov result,ah
or al,00h
mov bl,al
mov ah,byte ptr ASCIIab[bx]
mov result+1,ah
jmp $
code ends
end start

实验二
(1)742451.利用板上的集成电路插座,扩展一片74LS245,来读入开关状态。
data segment
result db 3 dup(?)
data ends
code segment
assume cs:code
start:mov dx,200h
in al,dx
not al
mov dx,208h
out dx,al
jmp start
code ends
end start

(2)74273。用74LS273作为输出口,控制八个LED灯循环左移点亮。
data segment
result db 3 dup(?)
data ends
code segment
assume cs:code
start:mov dx,200h
mov cx,20000
mov al,0FEh
begin:out dx,al
delay:loop delay
mov cx,20000
rol al,01
jmp begin
code ends
end start

实验三8253
(1)1.利用8088/8086外接8253可编程定时器/计数器,可以实现对外部事件进行计数:
要求计数5个外部脉冲后,小灯亮。
code segment
assume cs:code
start:mov al,00010000B
out 8000h,al
mov al,5
out 8000h,al
again:mov al,00000000B
out 8000h,al
in al,8000h
mov bl,al
in al,8000h
mov bh,al
jmp again
code ends
end start
code segment
assume cs:code
start:proc near
mov al,00110000B
mov dx,8003h
out dx,al
mov al,5
mov dx,8000h
out dx,al
mov al,0
out dx,al
code ends
end start
(2)应用8253定时器来实现小灯每一秒钟输出状态发生一次反转。
c1 equ 08003h
c2 equ 08000h
c3 equ 08001h
c4 equ 08002h
code segment
assume cs:code
start:proc near
mov al,36h
mov dx,c1
out dx,al
mov ax,1000
mov dx,c2
out dx,al
mov al,ah
out dx,al
mov al,76h
mov dx,c2
out dx,al
mov ax,2000
mov dx,c3
out dx,al
mov al,ah
out dx,al
jmp $
code ends
end start
实验四8255
(1)利用8255可编程并行口芯片,实现输入/输出实验,实验中用PB口输入

全部预览完毕

相关推荐

随机推荐

其他