1、汇编第一次实验计网 112 班 田凯飞 11073002151.实验题目:分别输入两组顺序排列的数组,合并在一起后逆序输出。2.实验代码:data segmentnum1 db 10 dup(?)num2 db 10 dup(?)num3 db 20 dup(?)num4 db 10 dup(?)shift db 13,10,$empt db ,$hint1 db Please enter the first group of number:,13,10,$hint2 db Please enter the second group of number:,13,10,$hint3 db The
2、 first group of number is:,13,10,$hint4 db The second group of number is:,13,10,$hint5 db The result is:,13,10,$data endscode segmentmain proc farassume ds:data,cs:codestart:push dssub ax,axpush axmov ax,datamov ds,axmov ah,9 ;提示输入第一组数lea dx,hint1int 21hmov cx,10 ;输入第一组数mov si,0l1:call inputmov num1
3、si,blinc siloop l1call huanhangmov ah,9 ;提示输出第一组数lea dx,hint3int 21hmov cx,10 ;输出第一组数mov si,0l2:mov al,num1sicall outputcall konggeinc siloop l2call huanhangmov ah,9 ;提示输入第二组数lea dx,hint2int 21hmov cx,10 ;输入第二组数mov si,0l3:call inputmov num2si,blinc siloop l3call huanhangmov ah,9 ;提示输出第二组数lea dx,hint
4、4int 21hmov cx,10 ;输出第二组数mov si,0l4:mov al,num2sicall outputcall konggeinc siloop l4call huanhangmov ah,9 ;提示合并排序后的数组为lea dx,hint5int 21hcall hebing ;合并数组call paixu ;重新排序mov cx,20 mov si,0l5:mov al,num3sicall outputcall konggeinc siloop l5ret main endpinput proc near ;输入函数push cxmov bl,0inp:mov ah,1
5、int 21hsub al,30hjl exit1cmp al,9jg exit1xchg al,blmov cl,10mul clxchg al,bladd bl,aljmp inpexit1:pop cxret input endpoutput proc near ;输出函数push cxmov di,0outp:mov ah,0mov cl,10div clmov num4di,ahcmp al,0jz printinc dijmp outpprint:mov dl,num4dior dl,30hmov ah,2int 21hdec dijns printexit2:pop cxret
6、output endphebing proc near ;合并数组mov cx,10mov si,0mov di,0haha:mov al,num1simov num3di,almov al,num2simov num3di+10,alinc siinc diloop haharethebing endppaixu proc near ;排序mov cx,19loop1:mov di,cxmov bx,0loop2:mov al,num3bx cmp al,num3bx+1jge continuexchg al,num3bx+1mov num3bx,alcontinue: add bx,1loop loop2mov cx,diloop loop1 retpaixu endphuanhang proc near ;换行mov ah,9lea dx,shiftint 21hrethuanhang endpkongge proc near ;空格mov ah,9lea dx,emptint 21hretkongge endpcode endsend start3.运行截图: