北京理工大学cup与汇编实验五.docx
《北京理工大学cup与汇编实验五.docx》由会员分享,可在线阅读,更多相关《北京理工大学cup与汇编实验五.docx(12页珍藏版)》请在冰豆网上搜索。
![北京理工大学cup与汇编实验五.docx](https://file1.bdocx.com/fileroot1/2022-11/24/2f63b2d2-84c8-4c71-865a-5c7cf1971428/2f63b2d2-84c8-4c71-865a-5c7cf19714281.gif)
北京理工大学cup与汇编实验五
本科实验报告
实验名称:
子程序与模块化程序设计实验
课程名称:
课程设计I(cup与汇编)实验
实验时间:
第10周周二10-13节
任课教师:
张笈
实验地点:
10-102
实验教师:
高平
实验类型:
□√原理验证
□综合设计
□自主创新
学生姓名:
学号/班级:
组号:
学院:
信息与电子学院
同组搭档:
专业:
电子科学与技术
成绩:
1.
DATASSEGMENT
BUF1DB'data,name,time,file,code,path,user,exit,quit,text$';此处输入数据段代码
LENTHEQU$-BUF1
BUF2DB6
DB?
DB6DUP(?
)
BUF3DB'NOTFOUND$'
DATASENDS
STACKSSEGMENT
;此处输入堆栈段代码
STACKSENDS
CODESSEGMENT
ASSUMECS:
CODES,DS:
DATAS,SS:
STACKS
NF:
MOVDX,OFFSETBUF3
MOVAH,9H
INT21H
JMPEN
NO:
ADDSI,7H
SBBSI,BX
CMPSI,LENTH
JAENF
MOVBX,2H
JMPL
NEXTPROCNEAR
MOVAL,BUF2[BX]
CMPAL,BUF1[SI]
JNENO
INCBX
INCSI
RET
NEXTENDP
START:
MOVAX,DATAS
MOVDS,AX
MOVDX,OFFSETBUF2
MOVAH,0AH
INT21H
MOVBX,2H
L:
CALLNEXT
CALLNEXT
CALLNEXT
CALLNEXT
DECSI
DECBX
SBBSI,3H
MOVAL,'d'
MOVBUF1[SI],AL
INCSI
MOVAL,'i'
MOVBUF1[SI],AL
INCSI
MOVAL,'s'
MOVBUF1[SI],AL
INCSI
MOVAL,'k'
MOVBUF1[SI],AL
MOVDL,0AH
MOVAH,2H
INT21H
MOVDX,OFFSETBUF1
MOVAH,9H
INT21H
JMPEN
LOOPL
EN:
MOVAH,4CH
INT21H
CODESENDS
ENDSTART
3.
DATASSEGMENT
BUF1DB'data,name,time,file,code,path,user,exit,quit,text$';此处输入数据段代码
LENTHEQU$-BUF1
BUF2DB6
DB?
DB6DUP(?
)
BUF3DB'NOTFOUND$'
CDB0
DATASENDS
STACKSSEGMENT
;此处输入堆栈段代码
STACKSENDS
CODESSEGMENT
ASSUMECS:
CODES,DS:
DATAS,SS:
STACKS
NF:
MOVDL,0AH
MOVAH,2H
INT21H
MOVDX,OFFSETBUF3
MOVAH,9H
INT21H
JMPEN
NO:
ADDSI,7H
SBBSI,BX
CMPSI,LENTH
JAENF
MOVBX,2H
JMPL
NEXTPROCNEAR
MOVAL,BUF2[BX]
CMPAL,BUF1[SI]
JNENO
INCBX
INCSI
RET
NEXTENDP
START:
MOVAX,DATAS
MOVDS,AX
MOVDX,OFFSETBUF2
MOVAH,0AH
INT21H
MOVBX,2H
L:
CALLNEXT
CALLNEXT
CALLNEXT
CALLNEXT
INCSI
INCBX
SHANCHU:
MOVAL,BUF1[SI]
MOVBUF1[SI-5],AL
CMPSI,32H
JESHUCHU
INCSI
MOVAL,BUF1[SI]
MOVBUF1[SI-5],AL
INCSI
MOVAL,BUF1[SI]
MOVBUF1[SI-5],AL
INCSI
MOVAL,BUF1[SI]
MOVBUF1[SI-5],AL
INCSI
MOVAL,BUF1[SI]
MOVBUF1[SI-5],AL
INCSI
LOOPSHANCHU
SHUCHU:
MOVDL,0AH
MOVAH,2H
INT21H
MOVDX,OFFSETBUF1
MOVAH,9H
INT21H
JMPEN
LOOPL
EN:
MOVAH,4CH
INT21H
CODESENDS
ENDSTART
4.
DATASEGMENT
BUFDB5
DB?
DB5DUP(?
)
MINUSDW10
STOREDB6DUP(0)
PRINTDB10,13
STORE2DB5DUP(0),10,13,'$'
MINUS2DW2
ERORDB13,10,'INPUTERROR!
$'
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,ES:
DATA,DS:
DATA
MAINPROCFAR
MOVAX,DATA
MOVES,AX
MOVDS,AX
R:
CALLINPUT
CALLCHANGE
CALLOUTPUT
JMPR
MOVAX,4C00H
INT21H
MAINENDP
CHANGEPROC
MOVAX,WORDPTRBUF+2
XCHGAL,AH
CMPAH,39H
JBETO5
SUBAH,37H
JMPTP
TO5:
SUBAH,30H
TP:
CMPAL,39H
JBETO1
SUBAL,37H
JMPTP1
TO1:
SUBAL,30H
TP1:
MOVCL,4
SHLAH,CL
ORAH,AL
MOVAL,0
PUSHAX
MOVAX,WORDPTRBUF+4
XCHGAL,AH
CMPAH,39H
JBETO3
SUBAH,37H
JMPTP3
TO3:
SUBAH,30H
TP3:
CMPAL,39H
JBETO4
SUBAL,37H
JMPTP4
TO4:
SUBAL,30H
TP4:
MOVCL,4
SHLAH,CL
ORAL,AH
MOVAH,0
POPDX
ORAX,DX
RET
CHANGEENDP
INPUTPROC
LEADX,BUF
MOVAH,0AH
INT21H
CALLCHECK
RET
INPUTENDP
OUTPUTPROC
MOVCX,5
LEABX,STORE2+4
AGAIN4:
MOVDX,0
DIVMINUS
MOV[BX],DL
ORBYTEPTR[BX],30H
DECBX
LOOPAGAIN4
LEADX,PRINT
MOVAH,9
INT21H
RET
OUTPUTENDP
ERRORPROC
LEADX,EROR
MOVAH,9
INT21H
MOVAX,4C00H
INT21H
ERRORENDP
CHECKPROC
MOVCL,BUF+1
LEABX,BUF+2
AGAIN3:
CMPBYTEPTR[BX],41H
JBTO
CMPBYTEPTR[BX],46H
JATO
INCBX
DECCL
JNZAGAIN3
JMPTO2
TO:
CALLERROR
TO2:
RET
CHECKENDP
CODEENDS
ENDMAIN