预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共17页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

1.将下面C语言程序的代码片段转换为功能等价的汇编语言代码片段,其中均为signch1与与sintegercaps均 双字变量。 if(sinteger==0)sign==0; elseIf(siteger>0) sign=1; else sign=-1; moveax,sinteger movedx,sign cmpeax,0 jnzL1 movebx,0 L1:cmpebx,0jlL2movebx,1 L2:movebx,-1 2.将下面C语言程序的代码片段转换为功能等价的汇编语言代码片段,其中为字 节变量。 if(ch1>='a'&&ch1<='z')caps==0; if(ch1>=A''&&ch1<='Z')caps==1; movax,ch1 movbx,caps cmpax,ajbnextcmpax,zjanextmovbx,0next:cmpax,Ajldonecmpax,Zjadone done: 3.将下面C语言程序的代码片段转换为功能等价的汇编语言代码片段,其中均为 双字变量。 sum=0; for(i=1;i<=100;i++) if(i%2==0)sum=sum+i; movecx,imovecx,1.while(ecx<=100) moveax,ecx xoredx,edx movebx,2 divebx cmpedx,0 jnznext addsum,ecx next:incecxsum与i变量 .endw 1.能被4整除但不能被100整除,或者年被400整除的年份是闰年。编程写一个完整的程序, 求出2012年〜2099年中的所有闰年年份,并把它们存放在数组Lyear中。 算法描述 esi=0;ecx=2012; while(ecx<2100) {if(yearmod4=0andyearmod100<>0)or(yearmod400=0)then{Lyear[esi]=ecx;esi++;} ;ecx++; .data Lyeardword100dup(?) Lcounterdword0 .code mainproc xoresi,esi;esi闰年个数计数器,兼做 movecx,2012;ecx年份计数器。 ;} ;Lcounter=esi;includeio32.inc moveax,ecx xoredx,edx movebx,400 divebx cmpedx,0 Lyear下标。 jzleap;ifyearmod400=0thengotoleap .while(ecx<2100) moveax,ecx xoredx,edx ebx,4 mov divebx edx,0 cmp next;ifyearmod4<>0thengotonext jnz moveax,ecx xoredx,edx ebx,100 mov divebx cmpedx,0 jznext;ifyearmod100=0thengotonext leap:movLyear[esi*4],ecx incesi moveax,ecx calldispuid;输出,用于验证。可以删掉 calldispcrlf;输出,用于验证。可以删掉 next:incecx .endw movLcounter,esi moveax,esi calldispuidcall;输出,用于验证。可以删掉;输出,用 dispcrlf 于验证。可以删掉 ret mainendp;endofmain ;endofassembly endmain 2.编程写一个完整的程序,求出2〜100之间的所有素数,并将它们存入Prime数组中,素数 的个数存入变量Pcounter中。 ;采用伪代码pseudocode描述算法 ;1.i=2to100do ;1.1ifiisprimenumberthenprinti ;细化1.1如下: ;1.1j=2toi/2do ;1.1.1ifimodj=0thengotonexti ;1.1.2printi ;合理分配寄存器,i=ebx,j=ecx,edxeax做被除数,ecx做除数. includeio32.inc .data msgbyte'Listofprimenumber',13,10,0 msg1byte'Lcounteris:',13,10,0blankbyte' ',0 primedword100dup(?) pcounterdword0 .code mainproc;主程序开始 movesi,0 moveax,offsetmsg calldispmsg movebx,2 iLoop:cmpebx,100;i循环入口 jadone movecx,eb