微机原理实验程序中国石油大学华东.docx

上传人:b****4 文档编号:27258858 上传时间:2023-06-28 格式:DOCX 页数:29 大小:42.76KB
下载 相关 举报
微机原理实验程序中国石油大学华东.docx_第1页
第1页 / 共29页
微机原理实验程序中国石油大学华东.docx_第2页
第2页 / 共29页
微机原理实验程序中国石油大学华东.docx_第3页
第3页 / 共29页
微机原理实验程序中国石油大学华东.docx_第4页
第4页 / 共29页
微机原理实验程序中国石油大学华东.docx_第5页
第5页 / 共29页
点击查看更多>>
下载资源
资源描述

微机原理实验程序中国石油大学华东.docx

《微机原理实验程序中国石油大学华东.docx》由会员分享,可在线阅读,更多相关《微机原理实验程序中国石油大学华东.docx(29页珍藏版)》请在冰豆网上搜索。

微机原理实验程序中国石油大学华东.docx

微机原理实验程序中国石油大学华东

实验3循环程序设计

实验内容:

1.数组X,Y,Z,。

X=32,-43,76,95,-1;Y=-78,127,-128,-125,88。

计算两数之和,送入数组S。

DATASEGMENT

XDB32,-43,76,95,-1

YDB-78,127,-128,-125,88

SDB5DUP(0)

DATAENDS

CODESEGMENT

ASSUMECS:

CODE,DS:

DATA

START:

MOVAX,DATA

MOVDS,AX

MOVCX,5

MOVSI,0

FOR:

MOVAL,X[SI]

ADDAL,Y[SI]

MOVS[SI],AL

INCSI

LOOPFOR

CODEENDS

ENDSTART

2.两个多位十进制数,X=1357902468,Y=5790123467。

计算两数之和(BCD码)。

DATASEGMENT

XDB68H,24H,90H,57H,13H

YDB67H,34H,12H,90H,57H

SDB5DUP(0)

DATAENDS

CODESEGMENT

ASSUMECS:

CODE,DS:

DATA

START:

MOVAX,DATA

MOVDS,AX

MOVCX,5

MOVSI,0

CLC

FOR:

MOVAL,X[SI]

ADDAL,Y[SI]

DAA

MOVS[SI],AL

INCSI

LOOPFOR

CODEENDS

ENDSTART

实验4子程序调用变成设计

实验内容:

用子程序调用方法,现有数组X=32,-43,76,95,-1,-78,127,-128,-125,88

          编程按递增顺序排序输出。

DATASEGMENT

XDB32,-43,76,95,-1,-78,127,-128,-125,88

ENDSSEGMENT

CODESEGMENT

ASSUMECS:

CODE,DS:

DATA

START:

MOVAX,DATA

MOVDS,AX

CALLSUB1

MOVAH,4CH

INT21H

SUB1PROCNEAR

MOVCX,9

LP1:

MOVBX,0

MOVDX,CX

LP2;MOVAL,X[BX]

CMPAL,X[BX+1]

JLENEXT

XCHGAL,X[BX+1]

NEXT:

INCBX

DECDX

JNELP2

LOOPLP1

RET

SUB1ENDP

CODEENDS

ENDSTART

实验5DOS功能调用

实验内容:

1.从键盘连续输入五个单个字符,然后再反向输出这5个字符。

输入:

12345

输出:

54321

CODESEGMENT

ASSUMECS:

CODE

START:

MOVCX,5

LP1:

MOVAH,01

INT21H

PUSHAX

LOOPLP1

MOVDL,0AH

MOVAH,02

INT21H

MOVDL,0DH

MOVAH,02

INT21H

MOVCX,5

LP2:

POPDX

MOVAH,02

INT21H

LOOPLP2

MOVAH,4CH

INT21H

CODEENDS

ENDSTART

2.从键盘输入一串字符“abcde”,然后输出3次。

DATASEGMENT

MAXDB10

STRDB10DUP(‘S’)

DATAENDS

CODESEGMENT

ASSUMECS:

CODE,DS:

DATA

START:

MOVAX,DATA

MOVDS,AX

LEADX,MAX

MOVAH,10

INT21H

MOVCX,3

LP:

LEADX,STR

MOVAH,9

INT21H

MOVDL,0DH

MOVAH,02H

INT21H

MOVDL,0AH

MOVAH,2

INT21H

LOOPLP

MOVAH,4CH

INT21H

CODEENDS

ENDSTART

实验10简单的输出接口实验

实验内容;

1.利用74LS75设计一个接口电路,使4个LED同时亮,同时灭,中间间隔1秒,共循环5次。

CODESEGMENT

ASSUMECS:

CODE

START:

MOVCX,5

LP;MOVDX,280H

MOVAL,0FH

OUTDX,AL

CALLDELAY

MOVDX,280H

MOVAL,0H

OUTDX,AL

CALLDELAY

LOOPLP

MOVAH,4CH

INT21H

DELAYPROCNEAR

PUSHCX

MOVBX,03FFH

FOR1:

MOVCX,0FFFFH

FOR2;LOOPFOR2

DECBX

JNZFOR1

POPCX

RET

DELAYENDP

CODEENDS

ENDSTART

2.利用74LS75设计一个接口电路,使8个LED循环点亮,中间间隔1秒,共循环3次

CODESEGMENT

ASSUMECS:

CODE

START:

MOVCX,3

MOVSI,8

LP1:

MOVDX,280H

MOVAL,01H

LP2:

OUTDX,AL

CALLDELAY

SHLAL,1

DECSI

JNZLP2

LOOPLP1

MOVAH,4CH

INT21H

DELAYPROCNEAR

PUSHCX

MOVBX,03FFH

FOR1:

MOVCX,0FFFFH

FOR2;LOOPFOR2

DECBX

JNZFOR1

POPCX

RET

DELAYENDP

CODEENDS

ENDSTART

实验11简单的输入接口实验

实验内容:

1.设计一个接口电路,当开关来回搬动1次后,在屏幕上输出‘1’,再来回搬动1次,输出‘2’,共搬动5次。

利用硬件消抖。

(D1)

CODESEGMENT

     ASSUMECS:

CODE

START:

MOVDL,31H

      MOVCX,5

   L1:

PUSHDX

      MOVDX,280H

      INAL,DX

      ANDAL,01H

      MOVAH,AL

   L2:

INAL,DX

      ANDAL,01H

      CMPAH,AL

      JZL2

   L3:

INAL,DX

      ANDAL,01H

      CMPAH,AL

      JNZL3

      POPDX

      MOVAH,02H

      INT21H

      INCDL

      LOOPL1

      MOVAH,4CH

      INT21H

CODEENDS

     ENDSTART

2.设计一个接口电路,当开关来回搬动1次后,在屏幕上输出‘1’,再来回搬动1次,输出‘2’,共搬动5次。

利用软件消抖。

(D1)

.

CODESEGMENT

ASSUMECS:

CODE

START:

MOVDL,31H

MOVCX,5

L1:

PUSHDX

MOVDX,280H

INAL,DX

ANDAL,01H

MOVAH,AL

L2:

INAL,DX

ANDAL,01H

CMPAH,AL

JZL2

CALLDELAY

L3:

INAL,DX

ANDAL,01H

CMPAH,AL

JNZL3

CALLDELAY

POPDX

MOVAH,02H

INT21H

INCDL

LOOPL1

MOVAH,4CH

INT21H

DELAYPROCNEAR

PUSHCX

MOVBX,03FH

FOR1:

MOVCX,0FH

FOR2:

LOOPFOR2

DECBX

JNZFOR1

POPCX

RET

DELAYENDP

CODEENDS

ENDSTART

3.设计一个接口电路,当开关搬动1次后,在屏幕上输出‘1’,再搬动1次,

 输出‘2’,共搬动5次。

(D4)

CODESEGMENT

ASSUMECS:

CODE

START:

MOVDL,31H

MOVCX,5

L1:

PUSHDX

MOVDX,284H

INAX,DX

ANDAX,10H

MOVSI,AX

L2:

INAX,DX

ANDAX,10H

CMPSI,AX

JZL2

POPDX

MOVAH,02H

INT21H

INCDL

LOOPL1

MOVAH,4CH

INT21H

CODEENDS

ENDSTART

实验12数码管显示实验

1.使2个七段显示管分别显示HP,字符保持5秒钟。

CODESEGMENT

ASSUMECS:

CODE

START:

MOVCX,03FFH

L1:

MOVDX,280H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,76H;H

OUTDX,AL

MOVDX,282H

MOVAL,02H

OUTDX,AL

CALLDONG

MOVDX,282H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,73H;P

OUTDX,AL

MOVDX,280H

MOVAL,01H

OUTDX,AL

CALLDONG

LOOPL1

MOVDX,280H

MOVAL,00H

OUTDX,AL

MOVAH,4CH

INT21H

DONGPROCNEAR

PUSHCX

PUSHBX

MOVBX,0100H

FOR1:

MOVCX,0100H

FOR2:

LOOPFOR2

DECBX

JNZFOR1

POPBX

POPCX

RET

DONGENDP

CODEENDS

ENDSTART

2.使2个七段显示管分别显示01,23,45,67,89,每两个字符保持2秒钟。

CODESEGMENT

ASSUMECS:

CODE

START:

MOVCX,01FFH

L1:

MOVDX,280H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,3FH;0

OUTDX,AL

MOVDX,282H

MOVAL,02H

OUTDX,AL

CALLDONG

MOVDX,282H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,06H;1

OUTDX,AL

MOVDX,280H

MOVAL,01H

OUTDX,AL

CALLDONG

LOOPL1

MOVCX,01FFH

L2:

MOVDX,280H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,5BH;2

OUTDX,AL

MOVDX,282H

MOVAL,02H

OUTDX,AL

CALLDONG

MOVDX,282H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,4FH;3

OUTDX,AL

MOVDX,280H

MOVAL,01H

OUTDX,AL

CALLDONG

LOOPL2

MOVCX,010FH

L3:

MOVDX,280H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,66H;4

OUTDX,AL

MOVDX,282H

MOVAL,02H

OUTDX,AL

CALLDONG

MOVDX,282H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,6DH;5

OUTDX,AL

MOVDX,280H

MOVAL,01H

OUTDX,AL

CALLDONG

LOOPL3

MOVCX,010FH

L4:

MOVDX,280H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,7DH;6

OUTDX,AL

MOVDX,282H

MOVAL,02H

OUTDX,AL

CALLDONG

MOVDX,282H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,07H;7

OUTDX,AL

MOVDX,280H

MOVAL,01H

OUTDX,AL

CALLDONG

LOOPL4

MOVCX,010FH

L5:

MOVDX,280H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,7FH;8

OUTDX,AL

MOVDX,282H

MOVAL,02H

OUTDX,AL

CALLDONG

MOVDX,282H

MOVAL,00H

OUTDX,AL

MOVDX,290H

MOVAL,6FH;9

OUTDX,AL

MOVDX,280H

MOVAL,01H

OUTDX,AL

CALLDONG

LOOPL5

 

MOVDX,280H

MOVAL,00H

OUTDX,AL

MOVAH,4CH

INT21H

DONGPROCNEAR

PUSHCX

PUSHBX

MOVBX,0100H

FOR1:

MOVCX,0100H

FOR2:

LOOPFOR2

DECBX

JNZFOR1

POPBX

POPCX

RET

DONGENDP

CODEENDS

ENDSTART

实验13可编程并行接口8255A芯片实验

实验内容:

1.由8255A方式0的A口输出数据,驱动2个LED,循环点亮5次,每个状态保留1秒。

CODESEGMENT

ASSUMECS:

CODE

START:

MOVAL,80H

MOVDX,283H

OUTDX,AL

MOVCX,5

MOVDX,281H

MOVAL,00

L1:

MOVAL,01

OUTDX,AL

CALLDELAY

MOVAL,02

OUTDX,AL

CALLDELAY

LOOPL1

MOVAH,4CH

INT21H

DELAYPROCNEAR

PUSHCX

MOVBX,400

FOR1:

MOVCX,0FFFFH

FOR2:

LOOPFOR2

DECBX

JNZFOR1

POPCX

RET

DELAYENDP

CODEENDS

ENDSTART

2.用8255A方式1,将两位开关量设置的二进制数,由B口选通输入CPU,三秒钟后,由A口选通输出送LED显示,要求通过对状态字IBFB和OBFA#的测试来控制程序运行。

STB#和ACK#由消抖电路产生。

CODESEGMENT

ASSUMECS:

CODE

START:

MOVAL,10100110B

MOVDX,283H

OUTDX,AL

L1:

MOVDX,282H

INAL,DX

ANDAL,02H

JZL1

MOVDX,281H

INAL,DX

CALLDELAY

MOVDX,280H

OUTDX,AL

L2:

MOVDX,282H

INAL,DX

ANDAL,80H

JZL2

JMPL3

LOOPSTART

L3:

MOVAL,00

MOVDX,280H

OUTDX,AL

MOVAH,4CH

INT21H

DELAYPROCNEAR

PUSHCX

MOVBX,3FFH

FOR1:

MOVCX,0FFFFH

FOR2:

LOOPFOR2

DECBX

JNZFOR1

POPCX

RET

DELAYENDP

CODEENDS

ENDSTART

3.由8255A的A接口输出数据,驱动4个LED,使其顺序显示0--F的二进制状态,

 每个状态保持1秒钟。

CODESEGMENT

     ASSUMECS:

CODE

START:

MOVDX,283H

      MOVAL,80H

      OUTDX,AL

      MOVCX,16

      MOVAL,00H

   L1:

MOVDX,280H

      OUTDX,AL

      CALLDELAY

      INCAL

      LOOPL1

      MOVAH,4CH

      INT21H

DELAYPROCNEAR

      PUSHCX

      MOVBX,299H

 FOR1:

MOVCX,0FFFFH

 FOR2:

LOOPFOR2

      DECBX

      JNZFOR1

      POPCX

      RET

DELAYENDP

CODEENDS

     ENDSTART

实验148253编程测试实验

实验内容:

8253方式0测试,用消抖电路产生的脉冲作为CLK0输入信号,OUT0接LED。

运行程序5秒将计数器的显示在屏幕上,分析读取的计数常数与CLK0信号的关系。

方式0波形图

CODESEGMENT

     ASSUMECS:

CODE

START:

MOVAL,90H

      MOVDX,283H

      OUTDX,AL

      MOVAL,05H

      MOVDX,282H

      OUTDX,AL

      CALLDELAY

      MOVAL,00H

      MOVDX,283H

      OUTDX,AL

      MOVDX,282H

      INAL,DX

      MOVCH,AL

      MOVCL,4

      ANDAL,0F0H

      ROLAL,CL

      MOVDL,AL

      ADDDL,30H

      MOVAH,02H

      INT21H

      ANDCH,0FH

      MOVDL,CH

      ADDDL,30H

      MOVAH,02H

      INT21H

      MOVAH,4CH

      INT21H

DELAYPROCNEAR

      PUSHCX

      MOVBX,999H

 FOR1:

MOVCX,0FFFFH

 FOR2:

LOOPFOR2

      DECBX

      JNZFOR1

      POPCX

      RET

DELAYENDP

CODEENDS

     ENDSTART

2.8253方式1测试。

编程使计数器1工作在方式1,CLK1和GATE1信号由消抖电路产生,OUT1接LED,验证CLK1,GATE1,OUT1三者关系。

方式1波形图

CODESEGMENT

ASSUMECS:

CODE

START:

MOVAL,52H

MOVDX,283H

OUTDX,AL

MOVAL,05H

MOVDX,281H

OUTDX,AL

MOVAH,4CH

INT21H

CODEENDS

ENDSTART

实验158259A可编程中断控制器

设计中断过程,连续输出“AREYOUREADY?

”产生中断时,执行中断服务程序,中断服务程序是使两个LED灯亮灭3次,间隔一秒。

中断结束后,继续执行主程序,等待下次中断。

DATASEGMENT

ABCDB'AREYOUREADY?

',0DH,0AH,'$'DATAENDS

CODESEGMENT

ASSUMECS:

CODE,DS:

DATA

START:

MOVAX,CS

MOVDS,AX

MOVDX,OFFSETZD10

MOVAX,2572H

INT21H

CLI

INAL,21H

ANDAL,0FBH

OUT21H,AL

INAL,0A1H

ANDAL,0FBH

OUT0A1H,AL

STI

MOVCX,20

LOOP1:

PUSHCX

MOVAX,DATA

MOVDS,AX

LEADX,ABC

MOVAH,9

INT21H

CALLDELAY

POPCX

LOOPLOOP1

MOVDX,21H

INAL,DX

ORAL,4

OUT21H,AL

MOVDX,0A1H

INAL,DX

ORAL,4

OUT0A1H,AL

MOVAH,4CH

INT21H

ZD10PROCNEAR

PUSHAX

PUSHBX

PUSHCX

PUSHDX

MOVCX,3

AGAIN:

PUSHCX

MOVDX,280H

MOVAL,0FH

OUTDX,AL

CALLDELAY

MOVDX,280H

MOVAL,00H

OUTDX,AL

CALLDELAY

POPCX

LOOPAGAIN

POPDX

POPCX

POPBX

POPAX

MOVAL,20H

OUT20H,AL

MOVAL,20H

OUT0A0H,AL

IRET

ZD10ENDP

DELAYPROCNEAR

MOVBX,02FFH

FOR1:

MOVCX,0FFFFH

FOR2:

LOOPFOR2

DECBX

JNZFOR1

RET

DELAYENDP

CODEENDS

ENDSTART

 

74LS75控制电路

74LS273控制电路

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1