常见汇编程序源代码示例Word文档下载推荐.docx

上传人:b****6 文档编号:15976174 上传时间:2022-11-17 格式:DOCX 页数:38 大小:32.69KB
下载 相关 举报
常见汇编程序源代码示例Word文档下载推荐.docx_第1页
第1页 / 共38页
常见汇编程序源代码示例Word文档下载推荐.docx_第2页
第2页 / 共38页
常见汇编程序源代码示例Word文档下载推荐.docx_第3页
第3页 / 共38页
常见汇编程序源代码示例Word文档下载推荐.docx_第4页
第4页 / 共38页
常见汇编程序源代码示例Word文档下载推荐.docx_第5页
第5页 / 共38页
点击查看更多>>
下载资源
资源描述

常见汇编程序源代码示例Word文档下载推荐.docx

《常见汇编程序源代码示例Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《常见汇编程序源代码示例Word文档下载推荐.docx(38页珍藏版)》请在冰豆网上搜索。

常见汇编程序源代码示例Word文档下载推荐.docx

calldispsid

exit0

endstart

2.输入一个年份(调用readuid子程序),判断是否是闰年.

.data

yes_msgbyte'

isleap'

13,10,0

no_msgbyte'

noleap'

callreaduid

movedx,0

movecx,4

divecx

cmpedx,0

jefirst

jmpsecond

first:

movecx,100

jneleap

second:

movecx,400

jeleap

jmpnoleap

leap:

moveax,offsetyes_msg

calldispmsg

noleap:

moveax,offsetno_msg

3.输入三个无符号整数(调用readuid子程序),判断并输出这三个数是否能构成一个三角形的三条边。

若这三个数能构成一个三角形的三条边,输出三角形的形状:

斜三角形、等腰三角形、等边三角形。

msg_dengyaobyte'

dengyao'

13,10,0;

等腰三角形

msg_dengbianbyte'

dengbian'

13,10,0;

等边三角形

msg_zhijiaobyte'

zhijiao'

直角三角形

msg_xiesanjiaobyte'

xiesanjiaoxing'

13,10,0;

斜三角形

msg_wrongbyte'

wrong'

13,10,0;

无法构成三角形

sqrdword0

;

在ebx,ecx,edx分别保存三条边的长度

callreaduid;

读取第一个数和第二个数到ebx、ecx

movebx,eax

movecx,eax

cmpebx,ecx;

确保ebx<

=ecx

jggreat

jmpnext

great:

xchgebx,ecx

next:

;

读取第三个数到edx

movedx,eax

cmpebx,edx

jgthirdsmall;

如果第三个数最小

cmpecx,edx

jgthirdmid;

如果第三个数在最中间

jmporder

thirdsmall:

moveax,edx

movedx,ecx

movecx,ebx

thirdmid:

xchgecx,edx

执行至此,三个数(ebx,ecx,edx)已经从小到大排序

order:

moveax,ebx

addeax,ecx

cmpeax,edx;

最小的两边之和大于第三边

jlewrong

cmpebx,ecx

jeb_equal_c;

第一条边等于第二条边

jec_equal_d;

第二条边等于第三条边

jmpgeneral;

非等腰(等边)三角形

b_equal_c:

cmpecx,edx;

继续比较,确认是否为等边三角形

jedengbian

jmpdengyao

c_equal_d:

执行至此,能否构成三角形,以及三角形是否等边等腰已经确定,输出

判断是否为直角三角形

general:

imuleax,eax

movsqr,eax

moveax,ecx

addsqr,eax

cmpsqr,eax

jezhijiao

jmpxiesanjiao

xiesanjiao:

moveax,offsetmsg_xiesanjiao

jmplast

zhijiao:

moveax,offsetmsg_zhijiao

dengbian:

moveax,offsetmsg_dengbian

dengyao:

moveax,offsetmsg_dengyao

wrong:

moveax,offsetmsg_wrong

输出完毕,运行结束

last:

4.采用无条件和条件转移指令构造while和dowhile循环结构,完成下面的求和任务并输出sum(sum为双字)。

sumdword0

getsum:

cmpecx,0

jenext

addsum,ecx

dececx

jmpgetsum

moveax,sum

calldispuid

calldispcrlf

思考题:

假设sum为双字无符号整数,在和不溢出的情况下求出n的最大值;

输出sum和n的值。

movecx,1

moveax,sum;

备份sum的值

jcnext;

进位的话跳出循环,此时的eax中保存最大sum,而ecx=n+1

incecx

calldispuid;

输出sum

moveax,ecx;

输出n

5.编写程序,求0到100间所有偶数和并输出。

要求采用loop、while和dowhile三种不同的循环结构完成。

●以下采用loop循环

xoreax,eax

again:

loopagain

结果2550

●以下采用while循环

jldone

subecx,2

jmpagain

●以下采用dowhile循环

6.Fibonaccinumbers的定义:

f1=1,f2=1,fn=fn-1+fn-2n>

=3

编程输出Fibonaccinumbers的前30项。

spacebyte'

'

0;

输出空格

f1dword1;

fn-1

f2dword1;

fn-2

movecx,30

moveax,f1;

输出f1

calldisp

moveax,f2;

输出f2

moveax,f1

addeax,f2;

eax=fn-1+fn-2

movebx,f2

movf1,ebx;

fn-1=fn-2

movf2,eax;

fn-2=eax

dispproc

pusheax;

保护寄存器eax

moveax,offsetspace

popeax;

恢复寄存器eax

ret

dispendp

结果:

1123581321345589144233377610987159725844181676510946177112

86574636875025121393196418317811514229832040Pressanykeytocontinue

在不产生溢出的情况下n的最大值是多少?

0;

maxnbyte'

TheMaximumnis'

0

f1dword1;

f2dword1;

xorecx,ecx

moveax,f1;

ca

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1