《2023年汇编实验报告新编.pdf》由会员分享,可在线阅读,更多相关《2023年汇编实验报告新编.pdf(34页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、实验三算术运算与代码转换程序设计一 实验目的1)掌握算术运算程序的设计方法。2)掌握代码转换程序的设计方法。3)进一步掌握各种程序结构。4)纯熟掌握和使用用D EBU G 调试程序。二 实验内容1)编制两个多字节整数加法和减法程序,并将结果按十六进制形式显示在屏幕上。2)编制程序实现二进制定点数与十进制数的ASC I I 码串之间转换,并将结果显示在屏幕上。3)编写程序计算从键盘输入两个不超过四位的十进制数的和、差、积、商,并以十进制形式输出。4)写程序把从键盘输入的四位十六进制数转换为压缩的BCD码,并显示输出。5)编写一通用过程用来将十进制数(从键盘输入)转换为P(从键盘输入)进制数。三、
2、实验设备PC机一台四、实验环节1)按 程 序 流 程 图 编 制 实 验 程 序。2)输 入 源 程 序。3)汇 编、连 接 程 序,执 行 程 序,检 查 结 果。4)程 序 的 执 行 可 用D E BUG的G命令,也可用T命 令 单 步 跟 踪 执 行o5)用D命 令 检 查 执 行 结 果。六、源程序实验一DATASEGMENTNUM1 DB 22H,33H,44H,5 5 H,66H,7 7 HNUM 1 LDB 6HNU M 2 DB 22 H,22H,22 H,22HNUM 2 LDB 4H0 UTC0ME1 DB 1 0 H DUP(O)OUTCOME 2 DB 10H DUP
3、(0)N DB OHDA TA ENDSSTA C KI S EGMEN T PARA STACKDW 2011 DUP(O)STAC KI ENDSCODE SEGMENTASSUME CS:C OD E,DS:DATA,SS:STACK1START:MOV AX,DATAMOV DS,AXMOV CH,0MOV SI,OFFSET NUM1MOV D I,OFFSETNUM2MOV AH,NUM1 LMOV AL,NUM2LC MP AH,ALJAE CHAXC HG SI,DIXCHG AH,ALCHA:SUB AH,ALoMOV CL,ALCLCMOV BX,OFF SETOUTCOM
4、E1LOP1:MOV AL,DIPU S H CXMOV CL,SIA DC CL,ALMOV BX,CLI NCBXI NC S IINC DIPOP CXLOOP LO PlMOV CL,AHJCXZ LOP3LOP 2 TUSH CXMOVCL,BY TEPTRS I ADC CL,0MOVBX,CLPOP e xINCBXINC SILOOP LOP2LOP3:MOV CH,0MOV SI,OFFSET NUM1MOV D I.OFFSETNUM 2MOV AH,NUM ILMOV AL,NUM 2LCM P AH,ALJAE CHA 1XCHG SI,DIXCHG AH,ALCHAI
5、:SUB AH,ALMOV CL,A LCLCMOV BX,OFFSET OUT C OME2LOPlkMOV AL,DIPUSHCXMOV CLJ S ISBB CL,ALMOV B X,C LI NC BXINC SII N C D IPOP e xLOOP LOP 11MOV C L,AHJCXZ L OP7LOP21:PU S H CXMOV CL,BYTE PTR SiSB B CL,0MOV BX,CLP 0 P CXINC BXINC SILOOP LOP21LOP7:MOV DI,OFFSET OUTCOME 1ADD DIJ 0 HMOV CX,11HLOP4:MOV DL,
6、D I DEC D ICM P N,0 HJNE LOP5CMP DL,0HJ ELOP9LOP5:PUSH DXPUSH CXMOV CL,4HSHR DL,CLPOP CXCMPDL,9HJ BELO P6A DDDL,7HLOP6:ADD DL,30HMOV AH,2INT 2 1 HMOV N,1HPOP DXAND DX,0FHCMP DL,9HJBE LOP8ADDDL,7HLOP8:ADD D L,30 HMO V AH,21 NT21HMOV D L,HMOV AH,2INT21HLOP9:LOOP LOP4MOV N,0MOV DI,OFF S ETOUTC OME2ADD
7、DI,1 OHMOV CX,11HLOP 1 4:M OVDL,DIDEC DICMP N,0 HJNELOP1 5CMPDL,0HJ E LO P 1 9LOP15:PUSH DXPUSH C XMOV CL,4 HSHR D L,CLPOP e xCMPDL,9HJ BE LOP16ADD DL,7HLOP1 6:ADD DL,30HMOV AH,2I NT 2 1 HM OVN,1HPOPDXAN D DX,0FHCMP DL,9HJ BE LOP 18AD D DL,7 HLOP 1 8:A DD DL,3 0 HM 0VAH,2INT21HMOV DL/HMOV AH,2INT 2
8、1 HLOP 1 9:LOOP LOP1 4MOV A H,4CHINT 2 1HCODE ENDSEND START实验2DATA SEGMENTTISHII DB 1 P Ie a s e e n ter t h e first n umber:1,$TISH I 2 DB 1Plea s e e n t e r th e seco nd n umber:,$J I A DB+*,$zJIAN D B-/$CHENG D B 咒$CHU DB7,DENGDB=*,$YUDB .VS,ADB 10BDW 10C D W 10 0 0 0FDW OHNUM1 DW OHNUM 2 DWOHN
9、DB OHN1 DB4HDATA ENDSSTACK1 SEGMENTS?ACKDW 3OH DUP(0)STACK 1 E NDSCODES SEGMENTASSUME C S C ODES,DS:DATAST ART:MOV AX,DATAMOV DS,AXMOV DX,OFFSET TIS HI 1MOV AH,0 9HINT21HLOOP2:MOV AX,NUM 1MUL BMOVBX,AXMOV AH,1INT 2 1HCMP AL,0 DHJE LOP1MOV NUM1,BXMOV AH,0SUB AL,30HADDNUM1,AXJM P LOOP2LOP1:MOV DL,OAH
10、输出换行和回车MOV AH,2INT 21 HMOV DL,0 DHMOVAH,2INT 2 1 HMOV DX,OFFSET TIS HI2MOV AH,09HI NT 21 HLOOP 1 :M O V AX,NUM2MUL B0MOV B X,AXMOV AH,1INT 2 1 HCMPALQDHJE LOP3MOV NUM2,BXMOVAH,0SUB AL,30HADD NUM2,AXJMPLOO P 1LOP3:MOV D L,OAH 输出换行和回车MOV AH,2INT 2 1HMOV D L,0 DHMOV A H,2INT21HMOV N,0MOV D X,NUM1M OVF,
11、DXLOP6:MOV DX,0 HM O V AX,FDIVBPUSH DXINCNC M P AX,0 HJ E LOP7MOV F,AXJM P LOP6LOP7:MOV CL,NMOV CH,0LOP16:POP DXAD D DX,3 OHMOV AH,2INT21HL O O P LOP 1 6MOV DX,NUM2MOVF,DXMOVN,0M OV DX,OFFSET JIAMOVAH,0 9H INT 2 1 HLOOOP6:MOVDX,OHMOV AX,FDIVBPUSH DXINC NCMP AX,0 HJE LOOOP7MOV F,AXJMPLOOOP6LOOOP7:MOV
12、 C L,NMOV CH,0LO OOP 1 6:POPDXADD DX,3 OHMOV AH,2INT2IHLO O PLO O O P1 6MOVDX,OFFSET DENGMOV AH,0 9HINT 21HM OVN,0LOOP 3:MOV AX,NUM1AD D AX,NUM2MO V F,AXLOOP4:MOVDX,OHMOV AX,FDIV BPUSH DXINCNCMP AX,OHJE LOOP5MOV F,AXJMP LOOP4LOOP5:MOV CL,NMOV CH,0LOOP 0:PO P D XADD DX,30HMOV AH,2INT21HLOOP LOOPOMOV
13、DL,0A H 输出换行和回车M OV AH,2I NT 2 1 HMOVDL,ODHMOV AH,2INT 2 1 HMOVN,0M OV DX,NUM 1MOVF,DXL 0 P61:MOVDX,OHMOV AX,FDIV BPUSH DXINCNCMP AX,OHJE LOP71MOV F,AXJMPLOP61LOP71:MOV CL,NMOV C H,0LOP161:POP DXA DD DX,3 0 HMOV AH,2INT 2 1 HLOO P LOP1 6 1M0VDX,NUM2MOVF,DXMOVN,0MOV DX,OF F SET JIANMOV AH,0 9 H INT 2
14、 1 HLOOOP61:MOV DX,0HMOVAX,FDIV BPUSH DXINC NCMP AX,OHJE LOOOP7 1MOV F,AXJMP L OOOP 6 1LO O O P7 1:MOV CL,NMOVCH,0LO OOP1 6 1:POPDXAD D DX,30HMOV AH,2I NT 2 1 HLOOP LOOOP161MOV DX,OFFSET DE NGM OVAH,09HIN T 2 1HMOV N,0MOV N,0MOV AX,NUMISUB AX,NUM 2MOV F,AXAND AX,1000000 OBCMP AX,1 0 0 00000BJN E L O
15、OP6NEGFLOOP6:MOV DX,0MOVAX,FDIV BPUSHDXINC NCMP AX,OHJE L 00P7MOV F,AXJMPLOOP6L0 0P7:M0V CL,NMOV CH,0LOOP16:PO P DXADD DX,30HMOV AH,2INT21HLOOP LOOP16MOV DL,OAH 输出换行和回车MOV AH,2INT21HMOV DL.ODHMOV AH,2INT21HMOVN,0MOV DX,NUM1MOV F,DXL O P 62:MOVDX,OHMOV AX,FDIVBPUSHDXINCNCMP AX,OHJ E LO P 7 2MOVF,AXJ
16、M PLO P62LOP72:MOVCL,NM OVCH,0L 0P1 6 2:POP DXADD DX,30HMOV AH,2INT 21HLOOPLOP162MOV DX,NUM2MOV F,DXMOV N,0MOV DX,OFFSET CHENGMOV A H,09HINT 2 1HLOOOP62:MOV DX,OHMOVAX,FDIV BPUSH DXINC NCMP AX,OHJE LOOOP72MOV F,AXJMPLOOO P 62L OOOP72:MOV CL,NMOV CH,0LOOOP 1 62:POP DXAD D DX,3 OHMOV AH,2I NT 21 HLO O
17、P LOOO P 1 62MOV DX,O F F S E T DENGMOV AH,0 9HI N T 2 1 HMOV N,0MOV AX,NUM1MU L NUM2DIVCPU SHDXMOV F,AXMOVN,0LOOP8:MOV DX,0MOV AX,FDIV BPUSH DXINC NCMP AX,OHJE LOOP9MOV F,AXJ MP LOOP8LOOP9:MOV CL,NMOV CH,0LOOP17:POP DXADDDX,3 0HMO V AH,2INT 2 1HLOOP LOOP17MOV N,0POPFLOOP1 0:MOV DX,0HMOVAX,FDIV BPU
18、SHDXINCNCMPAX,0HJ E LOOP1 1MOV F,AXJM P LOOPIOLOOPlkMOV AL,NCMP AL,4HJE L OOP2 0MOV A L,4HSUB AL,NMOV CL,ALMOV CH,0LOOP 1 9:MOVDX,OMOV AH,2INT21HLOOP LOOP1 9LOOP20:MOV CL,NMOV CH,0LOOP 18:POPDXADD DX,30HMOV AH,2INT 2 1HLOOP LOOP 18MOVDL,OAH 输出换行和回车MOV AH,2INT 2 1HMOV DL,ODHMOV AH,2I NT21HMOV N,0MOV
19、DX,NUM1MOVF,DXLOP64:MOV DX,0HMOV AX,FD I VBPU SH D XI NCNCMP AX,0 HJE LO P74MOV F,AXJMP LOP64LOP74:MOV C L,NMOV CH,0LOP1 6 4:POP DXADD DX,3 0 HMOV AH,2INT 2 1HLOO P LOP 1 64MOV DX,NUM2MOVF,DXM O V N,0MOV DX,OFFSET chuMOV AH,09HINT21HLOOOP6 4:MOV DX,OHMOVAX,FD I VBPUSH D XIN C NCMP AX,OHJELOOOP74M OV
20、F,AXJ MP LO 0 0 P 6 4L OOOP74:MOV C L,NMOV CH,0LOO OP1 6 4:POP D XADD DX,30HMOV AH,2INT 2 1 HLO OPLOOOP164MOV D X,OFFS E T DEN GMOV AH,09HINT 2 1HMOV N,0MOV AX,NUM 1MOV DX,0DIVNUM 2PUSH DXMOV F,AXMOV N,0LOOP1 5:MOV DX,0MOV AX,FD I V BPUSHDXINC NCMP AX,OHJE LOOP1 2MOV F,AXJ MP L 0 OP15LOOP1 2:MO V CL
21、,NMOV CH,0LOOP2 1:POP DXADD DX,30HMOV AH,2I NT 2 1 HLOOPLOOP2 1MOV D X,OFF S ET YUMOVAH,09HINT 2 1 HPOPFMOV N,0LOOP13:MOVDX,0MOV AX,FDIV BPUSH DXINCNCMP AX,OHJE LOOP 14MOV F,AXJMP LOOP1 3LOOP 14:MOV CL,NMOV CH,OHL OOP2 2:POP DXADDDX,3 OHMOV AH,2I NT 21 HLOOP LOOP22MOV AH,4CHINT 21HCO D ES ENDSEND ST
22、ART实验五输入输出程序设计一 实验目的1)掌握输入输出程序的编写方法。2)熟悉系统功能调用的方法。3)熟悉动画程序的编写方法。二 实验内容1)在C R T上每隔一秒连续显示字符0 9。编程提醒为了使输出的字符之间有空格,在每一个循环中输出一个0-9的字符和一个空格。为了输出09,置寄存器BL初值为0,每循环一次使其增量。为了保证输出是十进制,增量后用DAA调整指令。由于输出为一位十进制数,用AND 0FH指令屏蔽高4位。2)用系统功能调用将H E L L O 由键盘输入,再从屏幕输出,*HELLO*O3)编制在屏幕上画线的子程序,调用该子程序画一矩形。4)编制字母下落一行的子程序,调用该子程
23、序使字母从屏幕顶部下落到底部。5)创建一磁盘文献,保存从键盘输入的字符串。6)编写程序用设立系统时间,一方面从键盘以十进制数形式输入时间,然后修改系统时间,并重新以十进制形式显示时间。7)编写程序将屏幕分割成格状,每一格涂上不同颜色,格数从键盘输入。8)编写程序在屏幕上显示菜单,输入相应菜单的序号后,选种该菜单项。三 实验设备PC机一台四 实验环节 按程序流程图编制实验程序。2)输入源程序。3)汇编、连接程序,执行程序,检查结果。4)程序的执行可用DEBUG的G 命令,也可用T 命令单步跟踪执行。五、源程序实验五 EX A M5-1STACK SEGMENT STACKDB 102 4 DUP
24、(O)STACK E NDSCODE SEGM ENTAS S UME CS:CODE,SS:ST A C KSTART:MOV BL,0LP:MOVDL,2 OHMOVAH,2I NT2 IHMOVAL,BLADDAL,0DAAANDA L,OFHMOVBL,ALPUSHBXORAL,3 OHMOVD L,ALMOVAH,2INT21HMOVBX,3E8HLP2:MOVCX,1 76H;延 时 1msLP1:P U SHFPOPFLOOPLP1DECBXJNZLP2POPBXINCBLJMPLPCODE ENDSEND START执行程序EX AM 5-1 EXE,屏幕上依次循环显示一个数字
25、一个空格:0 1 23 4 5 6 7 8 9实验五E XAM5-2STACKSEGMENT STACKDB 1 0 24 DUP(O)STACKE N D SDATAS EGMENTB UFFDB 6,7DUP(?),$DATAENDSI NPUTMACR OBUFEMOVDX,OFFSET BUFEINTMOV21HENDMPUT CHAR MACROMOVMOVI NTENDMCODEAH,OAHCHARDL,CHARAH,21HSEGMENTASSUMESTART:MOVMOVINPUTPUT CHAR02HCS:CODE,DS:DATA,SS:STAC KAX,DATAD S,AXB
26、UFF;读取字符串TBUFFODHPUT CHAR OAH;光标另起一行MOVCX,000 3 HN E X T:PUTCHAR2 AHLOOPN EXTMOVCL,B UFF+1SUBCH,CHMOVBX,OFFSET BUFF+2BEGIN:MOVA L,BXPUTCHA RALI NCBXLOOPBEGINMOVCX,0 0 03HNEXT 1:PUTCHAR2 AHLOOPNEXT1MOVAH,4CHI NT2 1 HCODE ENDSENDSTART执行程序EXAM5-2-E X E,输 入 H E L L 0/屏幕上显示结果:*HELL 0*实 验 五EXAM5-5NAMEEXAM
27、 6SSTA C KSEGMENTSTACK stackSSTACKDATAASKNAMEDASKC ONTDB 1 02 4 DUP(?)ENDSSEGMENTBDBDBODH,OAH,Ent e r thede s t fi 1e name:$0DH,0 A H,Enter the st r i n g DBas f il e con te n t:Odh,Oah,$5FIL EBUFDB62,6 3DU P(?)HAND D DW?MSGMERDB ODH,OAH,OAHDB Directory ful 1,0DH,0 AH,$MSGWER DB 0DH,0AH,OAHD B D i s
28、 k ful 1 ,0DH,0AH,$,MS GSUCDB ODH,0AH,0AH,D B W r ite file i s Sue c es s fufDB ODH,0 AH,DATA ENDSD I SPLY MACR O TEXTMOV DX,OFFSET TE XTMOV AH,09HINT 2 1HENDMCRH A ND MA CRO PATH,ATTRMOV DX,OFFSET PATH;文献名MOV CL,A TTR;文献属性XOR CH,CHMOV AH,3CHINT 21HENDMWRHANDMACRO HAND,BUFF,BYTEMOV BX,HANDMOV DX,OFF
29、SET BUFFADD DX,2MOV CL,BYTEXOR CH,CHMOV AH,4 OHI NT 21HENDMCLHAND MACRO HANDMOV BX,HANDMOV AH,3EHINT 21HEN D MCODE SE GMENTP ROG PRO C FARA S SUME CS:CODE,DS:D ATA,SS:SSTA C KPUSH DSMOV AX,0PUSH AXMOV AX,DATAMOV DS,AXD I SP L Y ASKNA ME;提醒输入文献名MOV DX,OF F SE T F I LEBUFMOV AH,OAHINT 21HMOV DL OFFSET
30、 FILEB UF2MOV BL,F I LEBUF1XOR BH,BHMOV BYTE PTRBXDI,00HCRH AND F I LEBUF2,0;创建并打开新文献JC CRTE RRMOV HAN D_D,AX;存文献句柄DIS P L Y ASKCO NT;提醒键入文献内容MOV DX,OFFSET FILEBUFMOV AH,0AHINT 21HWRHAND HAND_D,FI LEBU F,FILEBU F 1 JC WRITE R RCLHAN D II AND_DD I SPL Y MSG SUCJM P EXITCRTER R:DISPLY MSGMERJ MP EXI TW R ITERR:DISPLY MSGWEREXIT:RETPROG EN DPCODEENDSEND PROG