资源描述:
《汇编语言上机作业与答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、上机考试题型答案顺序结构程序1、对于三个8位无符号数86H、34H和21H,编写R=86H×34H-21H的程序。DATASSEGMENTNUMDB86H,34H,21HRESULTDW?DATASENDSSTACKSSEGMENTSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXLEASI,NUMLEADI,RESULTMOVAL,[SI]MOVBL,[SI+1]MULBL;乘法存入AX寄存器MOVBL,[SI+
2、2]MOVBH,0SUBAX,BXMOV[DI],AXMOVAH,4CHINT21HCODESENDSENDSTART;=6935(01B17H)2、将字节存储单元A中的内容左移4位,B中的内容右移一位。要求移位后的空位为0。DATASSEGMENTADB34HBDB0A2HDATASENDSSTACKSSEGMENTSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVCL,4SHLA,CLSHRB,1MOVA
3、H,4CHINT21HCODESENDSENDSTART分支结构程序1、设计字符比较程序,两个字符相同时,显示YES;不相国时,显示NO。DATASSEGMENTD1DB'A'D2DB'B'RES1DB'YES','$'RES2DB'NO','$'DATASENDSSTACKSSEGMENTSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVAL,D1MOVBL,D2CMPAL,BLJNENEXT1LEADX,
4、RES1JMPNEXT2NEXT1:LEADX,RES2NEXT2:MOVAH,09HINT21HMOVAH,4CHINT21HCODESENDSENDSTART2、设存储单元A和B各有一个无符号数,比较其大小,将较大数送A单元。DATASSEGMENTADB0DEHBDB0B4HDATASENDSSTACKSSEGMENTSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVAL,ACMPAL,BJNCNEXT
5、XCHGAL,BMOVA,ALNEXT:MOVAH,4CHINT21HCODESENDSENDSTART1、计算符号函数SNG(X)的值。已知符号函数SNG(X)的值Y有:1当X>0时Y=0当X=0时-1当X<0时DATASSEGMENTXDB-3YDB?DATASENDSSTACKSSEGMENTSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVAL,XMOVBL,YCMPAX,0JLNEXT2JZNEXT
6、1MOVY,1JMPRESNEXT1:MOVY,0JMPRESNEXT2:MOVY,1JMPRESRES:MOVAH,4CHINT21HCODESENDSENDSTART1、比较AX、BX、CX中带符号数的大小,将最大的数放在AX中。试编写程序.DATASSEGMENTDATASENDSSTACKSSEGMENTSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXCMPAX,BXJGENEXTXCHGAX,BXNEX
7、T:CMPAX,CXJGEDONEXCHGAX,CXDONE:MOVAX,AXMOVAH,4CHINT21HCODESENDSENDSTART2、设从STRING开始存放一个以#为结束标志的字符串,把字符串中的字符进行分类,数字送入NUM开始的内存区中,大写字母送入BCHAR开始的内存中,小写字母存入LCHAR开始的内存区中,其他字符存入OTHER开始的内存区中。DATASEGMENTSTRINGDB'abc123ABCDE#'NEQU$-STRING-1NUMDBNDUP(?)BCHARDBNDUP(?)LCHARDBN
8、DUP(?)OTHERDBNDUP(?)DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVSI,OFFSETSTRINGMOVDI,OFFSETNUMMOVBP,OFFSETBCHARMOVCX,OFFSETLCHARM