微机原理与接口技术设计实验.docx
- 文档编号:12922353
- 上传时间:2023-04-22
- 格式:DOCX
- 页数:19
- 大小:16.76KB
微机原理与接口技术设计实验.docx
《微机原理与接口技术设计实验.docx》由会员分享,可在线阅读,更多相关《微机原理与接口技术设计实验.docx(19页珍藏版)》请在冰豆网上搜索。
微机原理与接口技术设计实验
实验一:
编写程序,比较两个字符串STRING1和STRING2所含的字符是否相同,若字符相同则显示“Match”,否则显示“NoMatch”
参考程序:
DATASEGMENT
STRING1DB'HAPPYASM'
LENEQU$-STRING1
STRING2DB'HAPPYASM'
MESSAGE1DB'MATCH',0DH,0AH,'$'
MESSAGE2DB'NOMATCH',0DH,0AH,'$'
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,ES:
DATA
START:
MOVAX,DATA
MOVDS,AX
MOVES,AX
LEASI,STRING1
LEADI,STRING2
MOVCX,LEN
COMPARE:
MOVAL,[SI]
MOVBL,[DI]
CMPAL,BL
JNEDISMATCH
INCSI
INCDI
LOOPCOMPARE
MATCH:
LEADX,MESSAGE1
JMPDISP
DISMATCH:
LEADX,MESSAGE2
DISP:
MOVAH,09H
INT21H
MOVAH,4CH
INT21H
CODEENDS
ENDSTART
实验二:
编写程序,从键盘输入一串字符,以‘$’或回车结束,将其中的小写字母转变为大写字母,其余字符不做转换,原样输出,结果显示在屏幕上。
参考程序:
DATASEGMENT
BUFDB50
DB?
DB50DUP(?
)
INPUTSTRINGDB'PLEASEINPUTASTRING:
','$'
OUTPUTSTRINGDB'OUTPUTSTRINGIS:
','$'
ENTERSTRINGDB0DH,0AH,'$'
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA
START:
MOVAX,DATA
MOVDS,AX
LEADX,INPUTSTRING
MOVAH,09H
INT21H
LEADX,BUF
MOVAH,0AH
INT21H
LEADX,ENTERSTRING
MOVAH,09H
INT21H
LEABX,BUF
ADDBX,2
NEXT1:
MOVAL,[BX]
INCBX
COMPARE:
CMPAL,24H
JZDISP
CMPAL,61H
JBNEXT1
CMPAL,7AH
JANEXT1
SUBAL,20H
MOV[BX-1],AL
JMPNEXT1
DISP:
LEADX,OUTPUTSTRING
MOVAH,09H
INT21H
LEADX,BUF+2
MOVAH,09H
INT21H
MOVAH,4CH
INT21H
CODEENDS
ENDSTART
实验三:
利用子程序方法编写程序,设有10个无符号数的字节序列,查找该序列中的最大值和最小值,并把结果显示在屏幕上。
参考程序1:
(针对一位10进制数)
STACKSEGMENTSTACK
DW256DUP(?
)
TOPLABELWORD
STACKENDS
DATASEGMENT
BUFDB00H,01H,02H,03H,04H
DB05H,06H,07H,08H,09H
COUNTEQU$-BUF
ENTERSTRINGDB0DH,0AH,'$'
MAXSTRINGDB'THEMAXIMUNNUMBERIS:
','$'
MINSTRINGDB'THEMINIMUNNUMBERIS:
','$'
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVAX,DATA
MOVDS,AX
MOVAX,STACK
MOVSS,AX
LEASP,TOP
MOVSI,OFFSETBUF
MOVCX,COUNT
CALLBRANCH
PUSHAX
LEADX,MAXSTRING
MOVAH,09H
INT21H
POPAX
MOVDL,AH
ADDDL,30H
PUSHAX
MOVAH,02H
INT21H
LEADX,ENTERSTRING
MOVAH,09H
INT21H
LEADX,MINSTRING
MOVAH,09H
INT21H
POPAX
MOVDL,AL
ADDDL,30H
MOVAH,02H
INT21H
MOVAH,4CH
INT21H
BRANCHPROCNEAR
JCXZNEXT4
PUSHSI
PUSHCX
PUSHBX
MOVBH,[SI]
MOVBL,BH
CLD
NEXT1:
LODSB
CMPAL,BH
JBENEXT2
MOVBH,AL
JMPNEXT3
NEXT2:
CMPAL,BL
JAENEXT3
MOVBL,AL
NEXT3:
LOOPNEXT1
MOVAX,BX
POPBX
POPCX
POPSI
NEXT4:
RET
BRANCHENDP
CODEENDS
ENDSTART
参考程序二:
(针对两位十六进制数或无符号数)
STACKSEGMENTSTACK
DW256DUP(?
)
TOPLABELWORD
STACKENDS
DATASEGMENT
BUFDB0FFH,55H,33H,44H,54H
DB45H,46H,47H,48H,1AH
COUNTEQU$-BUF
ENTERSTRINGDB0DH,0AH,'$'
MAXSTRINGDB'THEMAXIMUNNUMBERIS:
','$'
MINSTRINGDB'THEMINIMUNNUMBERIS:
','$'
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVAX,DATA
MOVDS,AX
MOVAX,STACK
MOVSS,AX
LEASP,TOP
MOVSI,OFFSETBUF
MOVCX,COUNT
CALLBRANCH
MOVDX,AX
PUSHDX
LEADX,MAXSTRING
MOVAH,09H
INT21H
POPDX
MOVAL,DH
PUSHDX
CALLDISPGAO4
POPDX
MOVAL,DH
PUSHDX
CALLDISPDI4
LEADX,ENTERSTRING
MOVAH,09H
INT21H
LEADX,MINSTRING
MOVAH,09H
INT21H
POPDX
MOVAL,DL
PUSHDX
CALLDISPGAO4
POPDX
MOVAL,DL
CALLDISPDI4
MOVAH,4CH
INT21H
BRANCHPROCNEAR
JCXZNEXT4
PUSHSI
PUSHCX
PUSHBX
MOVBH,[SI]
MOVBL,BH
CLD
NEXT1:
LODSB
CMPAL,BH
JBENEXT2
MOVBH,AL
JMPNEXT3
NEXT2:
CMPAL,BL
JAENEXT3
MOVBL,AL
NEXT3:
LOOPNEXT1
MOVAX,BX
POPBX
POPCX
POPSI
NEXT4:
RET
BRANCHENDP
DISPDI4PROCNERR;低四位
ANDAL,0FH
MOVDL,AL
CMPDL,9
JLENUM1
ADDDL,7
NUM1:
ADDDL,30H
MOVAH,02H
INT21H
RET
DISPDI4ENDP
DISPGAO4PROCNERR;高四位
SARAL,4
ANDAL,0FH
MOVDL,AL
CMPDL,9
JLENUM2
ADDDL,7
NUM2:
ADDDL,30H
MOVAH,02H
INT21H
RET
DISPGAO4ENDP
CODEENDS
ENDSTART
实验四:
8255交通灯
参考程序:
MY8255_AEQU288H;8255的A口地址
MY8255_BEQU289H;8255的B口地址
MY8255_CEQU28AH;8255的C口地址
MY8255_MODEEQU28BH;8255的控制寄存器地址
STACK1SEGMENTSTACK
DW256DUP(?
)
STACK1ENDS
DATASEGMENT
LADB?
;定义数据变量
LBDB?
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA
START:
MOVAX,DATA
MOVDS,AX
MOVDX,MY8255_MODE;定义8255工作方式
MOVAL,80H;工作方式0,A口和B口为输出
OUTDX,AL
L1:
MOVDX,MY8255_A;写A口发出的数据,1组绿灯亮,2组红灯亮
MOVAL,24H
OUTDX,AL
CALLDALLY1
MOVCX,05H
L2:
MOVDX,MY8255_A;写A口发出的数据,1组黄灯亮,2组红灯亮
MOVAL,44H
OUTDX,AL
CALLDALLY2
MOVDX,MY8255_A;写A口发出的数据,1组黄灯灭,2组红灯亮
MOVAL,04H
OUTDX,AL
CALLDALLY2
LOOPL2
L3:
MOVDX,MY8255_A;写A口发出的数据,1组绿灯亮,2组红灯亮
MOVAL,81H
OUTDX,AL
CALLDALLY1
MOVCX,05H
L4:
MOVDX,MY8255_A;写A口发出的数据,1组黄灯亮,2组红灯亮
MOVAL,82H
OUTDX,AL
CALLDALLY2
MOVDX,MY8255_A;写A口发出的数据,1组黄灯灭,2组红灯亮
MOVAL,80H
OUTDX,AL
CALLDALLY2
LOOPL4
L5:
MOVAH,01H;判断是否有按键按下,调用功能号1
INT16H;ROMBIOS功能调用
JZL1;无按键则跳回继续循环,有则退出
QUIT:
MOVAX,4C00H;结束程序退出
;INT21H;DOS系统功能调用
DALLY1PROCNEAR;软件延时子程序,东西方向红灯亮,南北方向绿灯亮
PUSHCX
PUSHDI
MOVCX,3FFH
Y1:
MOVDI,9000H
X1:
DECDI
JNZX1
LOOPY1
POPDI
POPCX
RET
DALLY1ENDP
DALLY2PROCNEAR;软件延时子程序,黄灯闪烁(即亮与灭)的时间间隔,
PUSHCX
PUSHDI
MOVCX,3FH
Y2:
MOVDI,9000H
X2:
DECDI
JNZX2
LOOPY2
POPDI
POPCX
RET
DALLY2ENDP
CODEENDS
ENDSTART
参考程序2:
流水灯
MY8255_AEQU288H;8255的A口地址
MY8255_BEQU289H;8255的B口地址
MY8255_CEQU28AH;8255的C口地址
MY8255_MODEEQU28BH;8255的控制寄存器地址
STACK1SEGMENTSTACK
DW256DUP(?
)
STACK1ENDS
DATASEGMENT
LADB?
;定义数据变量
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA
START:
MOVAX,DATA
MOVDS,AX
MOVDX,MY8255_MODE;定义8255工作方式
MOVAL,80H;工作方式0,A口和B口为输出
OUTDX,AL
MOVCX,0FFFFH
MOVBL,80H
L1:
MOVDX,MY8255_A;写A口发出的数据
MOVAL,BL
OUTDX,AL
CALLDALLY1
RORBL,1
LOOPL1
QUIT:
MOVAX,4C00H;结束程序退出
INT21H;DOS系统功能调用
DALLY1PROCNEAR;软件延时子程序,东西方向红灯亮,南北方向绿灯亮
PUSHCX
PUSHDI
MOVCX,3FH
Y1:
MOVDI,9000H
X1:
DECDI
JNZX1
LOOPY1
POPDI
POPCX
RET
DALLY1ENDP
CODEENDS
ENDSTART
实验五:
8254一赫兹方波输出
参考程序:
MY8254_COUNT0EQU280H;8254计数器0端口地址
MY8254_COUNT1EQU281H;8254计数器1端口地址
MY8254_COUNT2EQU282H;8254计数器2端口地址
MY8254_MODEEQU283H;8254控制寄存器端口地址
STACK1SEGMENTSTACK
DW256DUP(?
)
STACK1ENDS
CODESEGMENT
ASSUMECS:
CODE
START:
MOVDX,MY8254_MODE;初始化8254工作方式
MOVAL,37H;计数器0,方式3
OUTDX,AL
MOVDX,MY8254_COUNT0;装入计数初值
MOVAL,00;1000分频
OUTDX,AL
MOVAL,10
OUTDX,AL
MOVDX,MY8254_MODE;初始化8254工作方式
MOVAL,77H;计数器1,方式3
OUTDX,AL
MOVDX,MY8254_COUNT1;装入计数初值
MOVAL,00;1000分频
OUTDX,AL
MOVAL,10
OUTDX,AL
QUIT:
MOVAX,4C00H;结束程序退出
INT21H
CODEENDS
ENDSTART
实验六:
AD转换(0809)
参考程序:
CODESEGMENT
ASSUMECS:
CODE
START:
MOVDX,298H;启动A/D转换器
OUTDX,AL
MOVCX,0FFFFH
DELAY:
LOOPDELAY
MOVDX,298H
INAL,DX
PUSHDX
PUSHAX
CALLDISPGAO4
POPAX
POPDX
CALLDISPDI4
PUSHDX
MOVAH,06H
MOVDL,0FFH
INT21H
POPDX
JESTART
MOVAH,4CH
INT21H
DISPDI4PROCNERR;低四位
ANDAL,0FH
MOVDL,AL
CMPDL,9
JLENUM1
ADDDL,7
NUM1:
ADDDL,30H
MOVAH,02H
INT21H
RET
DISPDI4ENDP
DISPGAO4PROCNERR;高四位
SARAL,4
ANDAL,0FH
MOVDL,AL
CMPDL,9
JLENUM2
ADDDL,7
NUM2:
ADDDL,30H
MOVAH,02H
INT21H
RET
DISPGAO4ENDP
CODEENDS
ENDSTART
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 微机 原理 接口 技术设计 实验