汇编实验10.docx

上传人:b****4 文档编号:4998034 上传时间:2022-12-12 格式:DOCX 页数:16 大小:221.35KB
下载 相关 举报
汇编实验10.docx_第1页
第1页 / 共16页
汇编实验10.docx_第2页
第2页 / 共16页
汇编实验10.docx_第3页
第3页 / 共16页
汇编实验10.docx_第4页
第4页 / 共16页
汇编实验10.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

汇编实验10.docx

《汇编实验10.docx》由会员分享,可在线阅读,更多相关《汇编实验10.docx(16页珍藏版)》请在冰豆网上搜索。

汇编实验10.docx

汇编实验10

汇编实验10

暨南大学本科实验报告专用纸

课程名称汇编语言程序设计成绩评定

实验项目名称字符串程序设计指导教师

一、实验目的和要求

实验目的

1)掌握串操作指令的使用方法。

2)掌握串处理程序的设计方法。

3)熟练使用各种程序结构。

实验内容

1)编写程序把从键盘输入的以回车为结束符的字符串中的空格去掉并按相反的顺序输出。

2)编写程序在字符串STRING1中指定位置插入字符串STRING2。

3)编写程序在字符串STRING1中指定位置删除子串。

4)输入一个字符串(以回车符作为结束),将其排序后输出到屏幕上。

二、程序流程图(每题分开写)

 

 

三、源程序(每题分开写)

DSEGSEGMENT'DATA'

bufferdb50

db0

db50dup('$')

STRINGdb'Pleaseenterthestring.',0dh,0ah,'$'

DSEGENDS

SSEGSEGMENTSTACK'STACK'

db256DUP(0)

SSEGENDS

CSEGSEGMENT'CODE'

STARTPROCFAR

;setsegmentregisters:

MOVAX,DSEG

MOVDS,AX

MOVES,AX

movah,09h

movdx,offsetSTRING

int21h

movah,0ah

movdx,offsetbuffer

int21h

movsi,offsetbuffer+2

movcx,0

outlp:

cmpbyteptr[si],0dh

jzdone

cmpbyteptr[si],''

jnznext

movdi,si

inlp:

incdi

moval,[di]

mov[di-1],al

cmpbyteptr[di],0dh

jnzinlp

jmpoutlp

next:

incsi

inccx

jmpoutlp

done:

movsi,offsetbuffer+2

addsi,cx

inccx

movdl,0dh

movah,02h

int21h

movah,02h

movdl,0ah

int21h

lop:

movdx,[si]

movah,02h

int21h

decsi

looplop

MOVAX,4C00h;exittooperatingsystem.

INT21h

STARTENDP

CSEGENDS

ENDSTART;setentrypoint.

 

2.

DSEGSEGMENT'DATA'

STRING1db50

db0

db50dup('$')

db'$'

STRING2db50

db0

db50dup('$')

db'$'

STRING3db'PleaseentertheSTRING1.'

db0dh,0ah,'$'

STRING4db0dh,0ah,'PleaseentertheSTRING2.'

db0dh,0ah,'$'

STRING5db0dh,0ah,'PleaseenterthelocationintheSTRING1youwant.'

db0dh,0ah,'$'

STRING6db50dup('$')

 

DSEGENDS

SSEGSEGMENTSTACK'STACK'

db256DUP(0)

SSEGENDS

CSEGSEGMENT'CODE'

STARTPROCFAR

;setsegmentregisters:

MOVAX,DSEG

MOVDS,AX

MOVES,AX

movdx,offsetSTRING3

movah,09h

int21h

movah,0ah

movdx,offsetSTRING1

int21h

movdx,offsetSTRING4

movah,09h

int21h

movah,0ah

movdx,offsetSTRING2

int21h

movdx,offsetSTRING5

movah,09h

int21h

movah,01h

int21h

subal,30h

movcx,0

movcl,al

movbl,al

movsi,offsetSTRING1+2

movdi,offsetSTRING6

first:

movdl,byteptr[si]

movbyteptr[di],dl

incsi

incdi

loopfirst

movsi,offsetSTRING2+2

second:

cmpbyteptr[si],0dh

jzthird

next2:

movdl,byteptr[si]

movbyteptr[di],dl

incsi

incdi

jnzsecond

third:

movsi,offsetSTRING1+2

movbh,0

addsi,bx

third1:

cmpbyteptr[si],'$'

jzforth

next3:

movdx,[si]

mov[di],dx

incsi

incdi

jnzthird1

forth:

movsi,offsetSTRING1

movdi,offsetSTRING6

forth1:

cmpbyteptr[di],'$'

jzover

next4:

movdl,byteptr[di]

movbyteptr[si],dl

incsi

incdi

jnzforth1

over:

movdl,0dh

movah,02h

int21h

movdl,0ah

movah,02h

int21h

movdx,offsetSTRING1

movah,09h

int21h

MOVAX,4C00h;exittooperatingsystem.

INT21h

STARTENDP

CSEGENDS

ENDSTART;setentrypoint.

3.

 

DSEGSEGMENT'DATA'

STRING1db50

db0

db50dup('$')

STRING2db'PleaseentertheSTRING1.',0dh,0ah,'$'

STRING3db0dh,0ah,'Pleaseenterthestartingposition.',0dh,0ah,'$'

STRING4db0dh,0ah,'Pleaseenterthelengthyouwanttodelete.',0dh,0ah,'$'

adw0

bdw0

DSEGENDS

SSEGSEGMENTSTACK'STACK'

db256DUP(0)

SSEGENDS

CSEGSEGMENT'CODE'

STARTPROCFAR

;setsegmentregisters:

MOVAX,DSEG

MOVDS,AX

MOVES,AX

movdx,offsetSTRING2

movah,09h

int21h

movdx,offsetSTRING1

movah,0ah

int21h

movdx,offsetSTRING3

movah,09h

int21h

movah,01h

int21h

movah,0

mova,ax

suba,30h

movdx,offsetSTRING4

movah,09h

int21h

movah,01h

int21h

movah,0

movb,ax

subb,30h

movsi,offsetSTRING1+2

addsi,a

movdi,offsetSTRING1+1

movch,0

movcl,byteptr[di]

lop:

movdi,si

adddi,b

movax,[di]

mov[si],ax

incsi

looplop

movdl,0dh

movah,02h

int21h

movdl,0ah

movah,02h

int21h

movdx,offsetSTRING1+2

movah,09h

int21h

MOVAX,4C00h;exittooperatingsystem.

INT21h

STARTENDP

CSEGENDS

ENDSTART;setentrypoint.

4.

DSEGSEGMENT'DATA'

STRINGdb50

db0

db50dup('$')

STRING1db'PleaseentertheSTRING.',0dh,0ah,'$'

STRING2db0dh,0ah,'Thestringis:

','$'

DSEGENDS

SSEGSEGMENTSTACK'STACK'

db256DUP(0)

SSEGENDS

CSEGSEGMENT'CODE'

STARTPROCFAR

;setsegmentregisters:

MOVAX,DSEG

MOVDS,AX

MOVES,AX

movdx,offsetSTRING1

movah,09h

int21h

movdx,offsetSTRING

movah,0ah

int21h

movsi,offsetSTRING+2

movcl,STRING+1

movch,0

deccx

outlp:

movdx,cx

movbx,si

inlp:

moval,[bx]

cmpal,[bx+1]

jnanext

xchgal,[bx+1]

mov[bx],al

next:

incbx

decdx

jnzinlp

loopoutlp

movdx,offsetSTRING2

movah,09h

int21h

movdx,offsetSTRING+2

movah,09h

int21h

 

MOVAX,4C00h;exittooperatingsystem.

INT21h

STARTENDP

CSEGENDS

ENDSTART;setentrypoint.

4、结果分析(对输入\输出部分截屏)

5、实验总结

尝试用绘图工具画图,有点不习惯

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

当前位置:首页 > 求职职场 > 简历

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

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