资源描述:
《汇编语言作业》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、作业1:用汇编语言实现下列C功能:……chars[16];printf(“Whatisyourname?”);scanf(“%s”,s);printf(“Mynameis%s”,s);……程序:stcksegmentstack'stack'dw32DUP(?)stckendsdatasegmentXDB16,0,16DUP(?)YDB0AH,'Whatisyourname?$'ZDB0AH,'Mynameis:$'dataendscodesegmentbeginprocfarassume
2、ss:stck,cs:code,ds:datapushdssubax,axpushaxmovax,datamovds,axMOVDX,OFFSETY;显示Whatisyourname?并回车换行MOVAH,9INT21HMOVDX,OFFSETX;键入并显示字符串MOVAH,10INT21HMOVBL,X+1;将’$’送入字符串后MOVBH,0MOVBX[X+2],'$'MOVDX,OFFSETZMOVAH,9INT21HMOVDX,OFFSETX+2;显示出结果MOVAH,9INT21Hretbe
3、ginendpcodeendsendbegin作业2.从键盘上键入0~9中任意自然数N,将其立方值送显示器显示程序:stcksegmentstackdw32dup(?)stckendsdatasegmentINPUTDB'PLEASEINPUTN(0~9):$'OUTPUTDB0DH,0AH,'THERESULTIS:$'LFBDW00H,01H,08H,27H,64H,125H,216H,343H,512H,729HNDB?dataendscodesegmentbeginprocfarassume
4、ss:stck,ds:data,cs:codepushdssubax,axpushaxmovax,datamovds,axMOVDX,OFFSETINPUT;显示输入提示信息MOVAH,9INT21HMOVAH,1;键入并回显NINT21HMOVN,AL;保留NANDN,0FH;立方表中的偏移量SHLN,1MOVBL,NMOVBH,0MOVCX,LFB[BX];查表得N立方的BCD形式MOVDX,OFFSETOUTPUT;输出提示信息MOVAH,9INT21HANDCH,0FH;将百位转化ADDCH
5、,30HMOVDL,CHMOVAH,2INT21HMOVBL,CL;将十位转化SHRCL,4ADDCL,30HMOVDL,CLMOVAH,2INT21HANDBL,0FH;将个位转化ADDBL,30HMOVDL,BLMOVAH,2INT21Hretbeginendpcodeendsendbegin作业3从键盘输入一个无符号的十进制数(0~255),得到其实际数值后保存到bl中。为:在显示器上以二进制/十六进制显示做准备。stcksegmentstackdw32dup(?)stckendsdatase
6、gmentINPUTDB4,0,4DUP(0)OUTPUTdb'PleaseinputN(0-255):$'dataendscodesegmentbeginprocfarassumess:stck,ds:data,cs:codepushdssubax,axpushaxmovax,datamovds,axMOVDX,OFFSETOUTPUT;输出输入提示MOVAH,9INT21HMOVDX,OFFSETINPUTMOVAH,10INT21HMOVBL,INPUT+1;BL储存十进制个数MOVBH,0M
7、OVINPUT[BX+2],'$';存入输入的十进制数并在尾端存入'$'MOVDL,0DHMOVAH,2INT21HMOVDL,0AHMOVAH,2INT21H;换行MOVDL,'N'MOVAH,2INT21HMOVDL,'='MOVAH,2INT21HMOVDX,OFFSETINPUT+2MOVAH,9INT21HMOVDL,'='MOVAH,2INT21H;输出部分的十进制输出MOVSI,OFFSETINPUT+2MOVCL,INPUT+1MOVCH,0MOVAX,0MOVDL,10AGAIN:
8、MULDLANDbyteptr[SI],0FH;ASCLL码处理成二进制ADDAL,[SI]ADDAH,0INCSILOOPAGAIN;十进制处理成了二进制,结果在al中MOVBL,ALMOVAH,AL;AH和BL中均备份ANDAH,0F0HMOVCL,4SHRAH,CL;AH中用二进制的高四位CMPAH,10JBK1ADDAH,7K1:ADDAH,30Hmovdl,AHmovAH,2INT21HMOVAL,BLANDAL,0FH;AL只要低四位CMPAL,10JBK