集美大学计算机工程学院实验报告课程名称:汇编语言程序设计班级:软件0812实验成绩:指导教师:徐焕姓名:谭驹翔实验项目名称:查找电话号码学号2008813050上机实践日期:10.4.30实验项目编号:4组号:上机实践时间:4学时一、目的熟悉汇编程序设计的思想。二、实验内容与设计思想(1)建立电话表,包括名字表和号码表。输入结束后,对名字进行排序。(2)输入要查询的名字,并从电话表中查找出来,并打印出来。三、设计和编码DATASEGMENTmess1db13,10,'Inputname:','$'mess2db13,10,'Inputatelephonenumber:','$'mess3db13,10,'Doyouwanttoinputanothernumber?(Y/N)','$'mess4db13,10,'Doyouwanttoseachanumber?(Y/N)','$'mess5db13,10,'nametel.',13,10,'$'mess6db13,10,'notfind','$'tempdb30dup(?);暂时存放一条信息,交换信息时也用到stoknin_namelabelbyte;接收姓名max_namedb21act_namedb?temp_namedb21dup(?)stoknin_tellabelbyte;接收号码max_teldb9act_teldb?temp_teldb9dup(?)amountdb0;存放输入的信息数量tel_tabdb1500dup(?)DATAENDSSTACKSSEGMENT;此处输入堆栈段代码STACKSENDSCODESEGMENTmainprocfarassumecs:code,ds:data,es:dataSTART:MOVAX,DATAMOVDS,AXMOVES,AXSUBAX,AXLEABX,tel_tabget:LEADX,mess1MOVAH,09INT21Hcallinput_nameLEADX,mess2MOVAH,09INT21HcallinphonecallstoreINCamountcmpamount,1jenotsortcallname_sortnotsort:LEADX,mess3MOVAH,09INT21HMOVAH,1INT21HADDBX,30cmpAL,'Y'jegetcmpAL,'y'jegetseach:LEADX,mess4MOVAH,09INT21HMOVAH,1INT21HcmpAL,'N'jeexitcmpAL,'n'jeexitLEADX,mess1MOVAH,09INT21Hcallinput_namecallname_seachjmpseachexit:retmainendp;-----------------------------------------获取姓名input_nameprocnearPUSHAXLEADX,stoknin_nameMOVAH,0AHINT21HMOVAL,act_nameCBWMOVDI,AXfill1:;把后面的空间补上空格MOVtemp_name[DI],32INCDIcmpDI,21jea1jmpfill1a1:MOVCX,21SUBDI,DIintemp1:;存入tempMOVAL,temp_name[DI]MOVtemp[DI],ALINCDIloopintemp1POPAXretinput_nameendp;-----------------------------------------获取号码inphoneprocnearPUSHAXPUSHBXLEADX,stoknin_telMOVAH,0AHINT21HMOVCX,9SUBDI,DILEABX,tempADDBX,21intemp2:MOVAL,temp_tel[DI]MOV[BX+DI],ALINCDIloopintemp2POPBXPOPAXretinphoneendp;-----------------------------------------排序name_sortprocnearPUSHDIPUSHSIPUSHDXPUSHAXPUSHBXMOVDL,0a0:MOVDH,amountLEASI,tel_taba10:MOVCX,20MOVDI,SIADDDI,30MOVAX,DIMOVBX,SIrepecmpsbjbea20a20:MOVSI,AXDECDHcmpDH,1jnea10cmpDL,0jnea0POPBXPOPAXPOPDXPOPSIPOPDIretname_sortendp;-----------------------------------------将temp中存放的内容放进tel_tabstoreprocnearPUSHDIPUSHSIMOVDI,BXLEASI,tempMOVCX,30repMOVSBPOPSIPOPDIretstoreendp;----------------------------------------交换tel_tab中的两条记录h10xchgprocnearMOVCX,30LEADI,tempMOVSI,BXrepmovsbMOVCX,30MOVDI,BXrepmovsbMOVCX,30LEASI,temprepmovsbMOVDL,1reth10xchgendpname_seachprocnearPUSHBXPUSHAXLEADI,tel_tabMOVAL,amountseachnext:LEASI,tempMOVCX,21MOVBX,DIrepecmpsbjeprintMOVDI,BXADDDI,30DECALjenotfindjmpseachnextprint:LEADX,mess5MOVAH,09INT21HMOVCX,30SUBSI,SIa80:MOVDL,[BX+SI]MOVAH,02INT21HINCSIloopa80jmpfindnotfind:LEADX,mess6MOVAH,09INT21Hfind:POPAXPOPBXretname_seachendpCODEENDSENDSTART四、实验步骤和调试过程五、实验小结这个程序花了我两天的时间,发现某些细节上的逻辑错误,增强了我对汇编的兴趣。对排序子程序h10xchg依然非常困惑,明明书上一摸一样的代码,我详细的看过许多遍修改了一小部分后用到这个程序中。本程序中有进行排序的检测,但是检测到需要排序时不调用h10xchg。