1汇编语言第二次作业内容:课本实验3,4,5实验3:2实验4:34-1代码:codesegmentassumecs:codestart:movax,0movds,axmovbx,23fhmovcx,3fhs:mov[bx],cldecbxloopsmovax,4c00hint21hcodeendsendstart截图:44-2代码:codesegmentassumecs:codestart:movax,0movds,axmovbx,23fhmovcx,3fhs:mov[bx],cldecbxloopsmovax,4c00hint21hcodeendsendstart5截图:64-3代码:assumecs:codecodesegmentmovax,cs;movds,axmovax,0020hmoves,axmovbx,0movcx,10h;s:moval,[bx]moves:[bx],alincbxloopsmovax,4c00hint21hcodeendsend截图:78实验5:5-1代码:assumecs:code,ds:data,ss:stackdatasegmentdw0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987hdataendsstacksegmentdw0,0,0,0,0,0,0,0stackendscodesegmentstart:movax,stackmovss,axmovsp,16movax,datamovds,axpushds:[0]pushds:[2]9popds:[2]popds:[0]movax,4c00hint21hcodeendsendstart截图:10(1)CPU执行程序,程序返回前,data段中的数据不变。(2)CPU执行程序,程序返回前,cs=076CH、ss=076BH、ds=076AH.(3)设程序加载后,code段的段地址为X,则data段的段地址为X-2,stack段的段地址为X-1。115-2代码assumecs:code,ds:data,ss:stackdatasegmentdw0123H,0456Hdataendsstacksegmentdw0,0stackendscodesegmentstart:movax,stackmovss,axmovsp,16movax,datamovds,axpushds:[0]pushds:[2]popds:[2]popds:[0]movax,4c00hint21hcodeendsendstart12截图:13(1)CPU执行程序,程序返回前,data段中的数据不变。(2)CPU执行程序,程序返回前,cs=076CH、ss=076BH、ds=076AH.(3)设程序加载后,code段的段地址为X,则data段的段地址为X-2,stack段的段地址为X-1。(4)对于如下定义的段:namesegment…nameends如果段中的数据占N个字节,则程序加载后,这段实际占有的空间为(N/16+1)*16。5-3代码:assumecs:code,ds:data,ss:stackcodesegmentstart:movax,stackmovss,axmovsp,16movax,datamovds,axpushds:[0]14pushds:[2]popds:[2]popds:[0]movax,4c00hint21hcodeendsdatasegmentdw0123H,0456Hdataendsstacksegmentdw0,0stackendsendstart截图:15(1)CPU执行程序,程序返回前,data段中的数据不变。(2)CPU执行程序,程序返回前,cs=076CH、ss=076BH、ds=076AH.(3)设程序加载后,code段的段地址为X,则data段的段地址为X+3,stack段的段地址为X+4。16(4)如果将(1)、(2)、(3)题中的最后一条伪指令“endstart”改为“end”(也就是说不指明程序的入口),则那个程序仍然可以正确执行?请说明原因。解:程序都可以正确执行,因为去掉start后,由于没有的标志,系统会将从code段的起始位置当作程序代码的开始处,然后一直执行下去,而这三个程序在start前没有其他的内容,去掉start也就不影响期功能了。5-5代码:assumecs:codeasegmentdb1,2,3,4,5,6,7,8aendsbsegmentdb1,2,3,4,5,6,7,8bendscsegmentdb0,0,0,0,0,0,0,0cendscodesegmentstart:movax,amovds,axmovbx,0movcx,8s:moval,ds:[bx]addal,ds:[bx+16]movds:[bx+32],alincbxloopsmovax,4c00hint21hcodeendsendstart17截图:185-6代码:assumecs:codeasegmentdw1,2,3,4,5,6,7,8,9,0ah,0bh,0ch,0dh,0eh,0fh,0ffhaendsbsegmentdw0,0,0,0,0,0,0,0bendscodesegmentstart:movax,amovds,axmovbx,0movax,bmovss,axmovsp,16movcx,8s:push[bx]addbx,2loopsmovax,4c00hint21hcodeends19endstart截图:20