微机实验汇编代码.docx
- 文档编号:25808900
- 上传时间:2023-06-15
- 格式:DOCX
- 页数:13
- 大小:305.24KB
微机实验汇编代码.docx
《微机实验汇编代码.docx》由会员分享,可在线阅读,更多相关《微机实验汇编代码.docx(13页珍藏版)》请在冰豆网上搜索。
微机实验汇编代码
微机实验
1.将ASCII码表示的十进制数转换为二进制数
DATASEGMENT
DATAENDS
STACKSEGMENTSTACK'STACK'
DW50DUP(?
)
STACKENDS
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
CODESEGMENT
START:
MOVSI,3500H
MOVDI,3510H
MOVAH,0
MOVBX,0AH
MOVCX,04H
MOVAL,BYTEPTR[SI]
SUBAL,30H
NEXT:
MULBX
MOVSI,01H
SUBBYTEPTR[SI],30H
CLC
ADDAL,BYTEPTR[SI]
ADCAH,0
LOOPNEXT
EXIT:
MOV[DI],AX
MOVAX,4C00H
INT21H
CODEENDS
ENDSTART
2.将从键盘输入的五位十进制数的ASCII码已存在3500起始的内存单元中。
把它转换成BCD码后,再按位分别存入350A起始的内存单元内。
若输入的不是十进制的ASCII码,则显示FF.
STACKSEGMENTSTACK'STACK'
DW50DUP(?
)
STACKENDS
DATASEGMENT
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVCX,0005H
MOVSI,3500H
MOVDI,350AH
NEXT1:
MOVBL,30H
MOVBH,39H
MOVDL,0FFH
MOVAH,BYTEPTR[SI]
CMPAH,BH
JANEXT2
CMPAH,BL
JNAENEXT2
SUBAH,BL
MOV[DI],AH
JMPEXIT
NEXT2:
MOV[DI],DL
EXIT:
ADDSI,01H
ADDDI,01H
LOOPNEXT1
MOVAX,4C00H
INT21H
CODEENDS
ENDSTART
3.将十六位二进制数转换为ASCII码表示的十进制数。
十六进制数的值域为0~65535,最大可转换为五位十进制数。
4.十六进制数转换为ASCII码
STACKSEGMENTSTACK'STACK'
DW50DUP(?
)
STACKENDS
DATASEGMENT
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVBL,30H
MOVSI,3500H
MOVDI,350AH
MOVCX,0004H
MOVDX,[SI]
NEXT:
MOVBH,09H
MOVAX,DX
ANDAX,000FH
CMPAL,BH
JNAENEXT1
JMPNEXT2
NEXT1:
ADDAL,BL
JMPEXIT
NEXT2:
ADDAL,37H
EXIT:
MOV[DI],AL
ADDDI,01H
PUSHCX
MOVCL,04H
SHRDX,CL
POPCX
LOOPNEXT
MOVAX,4C00H
INT21H
CODEENDS
ENDSTART
5.BCD码转换为二进制码
STACKSEGMENTSTACK'STACK'
DW50DUP(?
)
STACKENDS
DATASEGMENT
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVSI,3500H
MOVDI,3510H
MOVCX,0008H
NEXT:
MOVBL,0AH
MOVAL,BYTEPTR[SI]
MULBL
XORAH,AH
ADDSI,01H
MOVDL,BYTEPTR[SI]
ADDAL,DL
MOV[DI],AX
ADDSI,01H
ADDDI,02H
LOOPNEXT
MOVAX,4C00H
INT21H
CODEENDS
ENDSTART
设计一数据块间的搬移程序。
STACKSEGMENTSTACK
DW64DUP(?
)
STACKENDS
DATASEGMENT
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVSI,3100H
MOVDI,3200H
MOVCX,0010H
CMPSI,DI
JANEXT2
ADDSI,CX
ADDDI,CX
DECSI
DECDI
NEXT1:
MOVAL,[SI]
MOV[DI],AL
DECSI
DECDI
DECCX
JNENEXT1
JMPNEXT3
NEXT2:
MOVAL,[SI]
MOV[DI],AL
INCSI
INCDI
DECCX
JNENEXT2
NEXT3:
RET
CODEENDS
ENDSTART
2.计算S=1+2×3+3×4+4×5+…+N(N+1),直到N(N+1)项大于200为止。
STACKSEGMENTSTACK
DW64DUP(?
)
STACKENDS
DATASEGMENT
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVDX,0001H
MOVBH,02H
NEXT1:
MOVAL,BH
ADDBH,01H
MULBH
ADDDX,AX
CMPAX,00C8H
JNANEXT1
NEXT2:
JMPNEXT2
CODEENDS
ENDSTART
求某个数据区内负数的个数
STACKSEGMENTSTACK
DW64DUP(?
)
STACKENDS
DATASEGMENT
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVDI,3000H
MOVCL,[DI]
XORCH,CH
MOVBL,CH
ADDDI,01H
NEXT1:
MOVAL,[DI]
TESTAL,80H
JENEXT2
ADDBL,01H
NEXT2:
ADDDI,01H
LOOPNEXT1
MOV[DI],BL
NEXT3:
JMPNEXT3
CODEENDS
ENDSTART
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 微机 实验 汇编 代码
![提示](https://static.bdocx.com/images/bang_tan.gif)