资源描述:
《河北工业大学-汇编实验报告 实验三.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、汇编语言程序设计实验报告实验三算术运算与代码转换程序设计姓名:刘**班级:计15x学号:15****一、实验目的a)掌握算术运算程序的设计方法。b)掌握代码转换程序的设计方法。c)进一步掌握各种程序结构。d)熟练掌握和使用用DEBUG调试程序。二、实验内容a)编制两个多字节整数加法和减法程序,并将结果按十六进制形式显示在屏幕上。源代码:datasegmentmsgNum1db"inputthefirstnumber:$"msgNum2db"inputthesecondnumber:$"msgNum3db"choosetheoperation+/-:$"msgNum4db"thean
2、sweris:$"num1db20dup(?)num1Ldb?num2db20dup(?)num2Ldb10hcountdb0chadb0dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axleadx,msgNum1;接受输入movah,09hint21hmovnum1,0input1:movah,1int21hcmpal,0dhjeendinput1subal,30hmovnum1[si],alincsiincnum1Ljmpinput1endinput1:callpenterleadx,msgNum2m
3、ovah,09hint21hmovnum2L,0input2:movah,1int21hcmpal,0dhjeendinput2subal,30hmovnum2[di],alincdiincnum2Ljmpinput2endinput2:callpentermovsi,offsetnum1;输入结束,比较两个数的大小movdi,offsetnum2movah,num1Lmoval,num2Lmovcount,ahcmpah,aljaenext1xiao:xchgsi,dimovnum1L,almovnum2L,ahmovcount,alnext1:movah,num1Lmoval,
4、num2Lsubah,almovcha,ahmovch,0movcl,chalop0:;移位,使小数点对齐incsilooplop0operate:;接受运算符leadx,msgNum3movah,09hint21hmovah,1int21hcmpal,'+'jejiajian:;减法moval,[di]sbb[si],alincsiincdiloopjianjmpnext2jia:moval,[di];加法adc[si],alincsiincdiloopjianext2:movah,num1Lmoval,num2Lsubah,almovch,0movcl,ahlop2:;处理孤独
5、的高位adcbyteptr[si],0incsilooplop2next:movch,0movcl,num1Lmovsi,offsetnum1callpenterleadx,msgNum4movah,09hint21hlop3:;输出moval,[si]addal,30hmovdl,almovah,2int21hincsilooplop3over:movah,4chint21hpenterproc;换行movdl,0ahmovah,2int21hmovdl,0dhmovah,2int21hretpenterendpcodeendsendstartb)编写一通用过程用来将十进制数(从
6、键盘输入)转换为P(从键盘输入)进制数。源代码:datasegmentmessage1db"pleaseinputanumber:$"message2db"pleasechoosethescaleyouwant:$"message3db"theansweris:$"numdw0answerdb20dup(?)countdb0scaledb?dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axleadx,message1movah,09hint21hcallpentermovcx,5input:movah,1
7、int21hcmpal,0dhjeendinputandal,0fhshlnum,1movbx,numshlnum,1shlnum,1addnum,bxmovah,0addnum,axloopinputendinput:callpenterleadx,message2;接受进制movah,09hint21hcallpentermovah,1int21hsubal,30hmovscale,alcallpentermovax,nummovsi,offsetanswerlo